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

5 lines
1.7 KiB
JavaScript

function inputPhoneContact(a,b){this.container=a;this.add_button=b}inputPhoneContact.prototype={container:this.container,add_button:this.add_button,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 input[type="submit"]');for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.handler()},!1),a[c].addEventListener("click",function(a){b.handler()},
!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;var b=this;this.add_button.addEventListener("click",function(){b.handler()},!1);this.storageToFields()};