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

10 lines
3.2 KiB
JavaScript
Raw Normal View History

function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=lsi.get("mini-fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:[c.sexe[0].status,c.sexe[1].status],age:c.age.value,
job:c.job.value,loc:[c.loc[0].status,c.loc[1].status,c.loc[2].status,c.loc[3].status]};lsi.set("mini-fiches","form"+c.uid,c)}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];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",loca:a.loc[0]?"true":"false",locb:a.loc[1]?"true":"false",locc:a.loc[2]?"true":"false",locd:a.loc[3]?"true":"false"});var b=$('[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select');console.log(b);b.value=a.job};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.keys("mini-fiches");this.container.innerHTML="";for(var b=[],c=0;c<a.length;c++){var d=lsi.get("mini-fiches",a[c]);this.add({uid:d.uid,firstname:d.firstname,lastname:d.lastname,username:d.username,age:d.age,sexe:d.sexe,job:d.job,loc:d.loc});b.push(d.uid)}this.updateNavBar(b)};
inputPhoneMini.prototype.sync=function(){for(var a=lsi.keys("contacts"),b=0;b<a.length;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("mini-fiches",a[b]);null==d?lsi.set("mini-fiches",a[b],{uid:c.uid,firstname:c.firstname,lastname:c.lastname,username:c.username,sexe:[!0,!1],age:"",job:".",loc:[!0,!1,!1,!1]}):(d.firstname=c.firstname,d.lastname=c.lastname,d.username=c.username,lsi.set("mini-fiches",a[b],d))}};
inputPhoneMini.prototype.show=function(){for(var a=$$("article.mini-relation-panel .mini-fiche-relation.active"),b=0;b<a.length;b++)a[b].remClass("active");this.container.children[this.selected].addClass("active")};inputPhoneMini.prototype.nav=function(a){if(isNaN(a.innerHTML))return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1;this.show()};
inputPhoneMini.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var b=0;b<a.length;b++){var c=parseInt(a[b])+1;this.nav_container.innerHTML+="<span>"+c+"</span>"}this.nav(this.nav_container.children[this.selected])};inputPhoneMini.prototype.attach=function(){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();var a=this;this.nav_container.addEventListener("click",function(b){a.nav(b.target)},!1)};