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

5 lines
1.5 KiB
JavaScript
Raw Normal View History

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