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

6 lines
2.0 KiB
JavaScript

function inputPhoneContact(a,c){this.container=a;this.add_button=c}inputPhoneContact.prototype={container:this.container,add_button:this.add_button};
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={number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value},lsi.set("contacts",
"form"+d,b),e=lsi.get("mini-fiches","form"+d),!1===e?lsi.set("mini-fiches","form"+d,{uid:d,firstname:b.firstname,lastname:b.lastname,username:b.username,age:"",sexe:[!0,!1],job:".",location:[!0,!1,!1,!1]}):(e.firstname=b.firstname,e.lastname=b.lastname,e.username=b.username,lsi.set("mini-fiches","form"+d,e))}this.storageToFields()};
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 c=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){c.fieldsToStorage()},!1),a[d].addEventListener("click",function(a){c.fieldsToStorage()},
!1)};inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var c=0;c<a.length;c++){var d=lsi.get("contacts",a[c]);this.add(d)}this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");var a=this;this.add_button.addEventListener("click",function(c){a.fieldsToStorage()},!1);this.storageToFields()};