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

6 lines
1.5 KiB
JavaScript

function inputPhoneContact(a){this.container=a}inputPhoneContact.prototype={container:this.container,handler:null};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),c=0;c<a.length;c++){var d=a[c].parentNode.children.indexOf(a[c]),b=(new FormDeflater(a[c],["input"],["data-name"])).deflate(),e=0<b.number.value.length;if(e=e&&0<b.username.value.length+b.firstname.value.length+b.lastname.value.length)b={uid:d,number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value},b.hash=
crc32(JSON.stringify(b)),lsi.set("contacts","form"+d,b)}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var c=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){c.handler(a.target)},!1),a[d].addEventListener("click",function(a){c.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var c in a)this.add(a[c]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a};