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

9 lines
2.3 KiB
JavaScript

function inputPhoneMini(a){this.container=a}inputPhoneMini.prototype={container:this.container};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),d=lsi.get("mini-fiches","form"+b.uid.value);console.log("deflated");console.log(b);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");b={uid:b.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:[b.sexe[0].status,
b.sexe[1].status],age:b.age.value,job:b.job.value,loc:[b.loc[0].status,b.loc[1].status,b.loc[2].status,b.loc[3].status]};lsi.set("mini-fiches","form"+b.uid,b)}this.storageToFields()};
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.username=null!=a.username?a.username:"";a.age=null!=a.age?a.age:"";a.sexe=null!=a.sexe?a.sexe:[!0,!1];a.job=null!=a.job?a.job:".";a.loc=null!=a.loc?a.loc:[!0,!1,!1,!1];console.log(a);this.container.innerHTML+=miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,sexea:a.sexe[0]?
"true":"false",sexeb:a.sexe[1]?"true":"false",job:a.job,loca:a.loc[0]?"true":"false",locb:a.loc[1]?"true":"false",locc:a.loc[2]?"true":"false",locd:a.loc[3]?"true":"false"})};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.keys("mini-fiches");this.container.innerHTML="";for(var c=0;c<a.length;c++){var b=lsi.get("mini-fiches",a[c]);this.add({uid:b.uid,firstname:b.firstname,lastname:b.lastname,username:b.username,age:b.age,sexe:b.sexe,job:b.job,loc:b.loc})}};
inputPhoneMini.prototype.sync=function(){for(var a=lsi.keys("contacts"),c=0;c<a.length;c++){var b=lsi.get("contacts",a[c]),d=lsi.get("mini-fiches",a[c]);null==d?lsi.set("mini-fiches",a[c],{uid:b.uid,firstname:b.firstname,lastname:b.lastname,username:b.username,sexe:[!0,!1],age:"",job:".",loc:[!0,!1,!1,!1]}):(d.firstname=b.firstname,d.lastname=b.lastname,d.username=b.username,lsi.set("mini-fiches",a[c],d))}};
inputPhoneMini.prototype.attach=function(){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields()};