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

5 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"),b=0;b<a.length;b++){var c=a[b].parentNode.children.indexOf(a[b]),d=(new FormDeflater(a[b],["input"],["data-name"])).deflate(),e=0<d.number.value.length;(e=e&&0<d.username.value.length+d.firstname.value.length+d.lastname.value.length)&&lsi.set("contacts","form"+c,{uid:c,number:d.number.value,username:d.username.value,firstname:d.firstname.value,lastname:d.lastname.value})}};
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 b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var b=0;b<a.length;b++){var c=lsi.get("contacts",a[b]);this.add(c)}this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a;this.storageToFields()};