NxTIC/js/includes/input-phone-contact-min.js

9 lines
2.6 KiB
JavaScript
Raw Normal View History

function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return 0<=a.username.length};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(c.uid),
d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=pContactBuilder.build(a);a=$$('[data-sublink="phone"] article.contact-panel .new-contact');for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);
b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("p_contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("p_contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar()};
inputPhoneContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-contact > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("p_contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))};
inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("p_contacts");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};