Correction de la selection des valeurs du <select>

This commit is contained in:
xdrm-brackets 2016-04-27 12:25:42 +02:00
parent 26bee734ab
commit d84f3b9363
8 changed files with 145 additions and 94 deletions

File diff suppressed because one or more lines are too long

View File

@ -54,7 +54,7 @@ miniFicheBuilder.setLayout(
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\t<span class='select-container'><select data-name='job'>\n"+
"\t\t<span class='select-container'><select data-name='job' value='@job'>\n"+
"\t\t\t<option value='.' disabled>Dernière profession exercée:</option>\n"+
"\t\t\t<option value='0'>Inconnue</option>\n"+
"\t\t\t<option value='1-' disabled>Agriculateur exploitants</option>\n"+
@ -264,7 +264,7 @@ ficheBuilder.setLayout(
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_@uid' data-name='reltype' id='reltype5_@uid'><label for='reltype5_@uid'>Voisin</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_@uid' data-name='reltype' id='reltype6_@uid'><label for='reltype6_@uid'>Ami</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_@uid' data-name='reltype' id='reltype7_@uid'><label for='reltype7_@uid'>Copain</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_@uid' data-name='reltype' id='reltype8_@uid'><label for='reltype8_@uid'>Autre : <input type='text' id='reltypeSpecial' placeholder='coéquipier de tennis, ..'></label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_@uid' data-name='reltype' id='reltype8_@uid'><label for='reltype8_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..'></label><br>\n"+
"\t</h5>\n"+
"\t<h4 data-icon='m'>Où habite t-elle/il ?</h4>\n"+
@ -328,10 +328,10 @@ ficheBuilder.setLayout(
"\t<h5 class='nobold color0'>\n"+
"\t\tSMS, et équivalents<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2 id='freq21_@uid'><label for='freq21_@uid'>plusieurs fois par semaine</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2 id='freq22_@uid'><label for='freq22_@uid'>1 fois par semaine</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2 id='freq23_@uid'><label for='freq23_@uid'>1 fois par mois</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2 id='freq24_@uid'><label for='freq24_@uid'>1 fois par an ou moins</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2' id='freq21_@uid'><label for='freq21_@uid'>plusieurs fois par semaine</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2' id='freq22_@uid'><label for='freq22_@uid'>1 fois par semaine</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2' id='freq23_@uid'><label for='freq23_@uid'>1 fois par mois</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='freq2_@uid' data-name='freq2' id='freq24_@uid'><label for='freq24_@uid'>1 fois par an ou moins</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
@ -354,38 +354,38 @@ ficheBuilder.setLayout(
"\t<h4 data-icon='r'>Comment êtes-vous « connecté » à cette personne ?</h4>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tSes coordonnées sont dans votre carnet dadresse<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect1_@uid' data-name='connect1' id='connect11_@uid'><label for='connect11_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect1_@uid' data-name='connect1' id='connect12_@uid'><label for='connect12_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect1_@uid' data-name='connect0' id='connect11_@uid'><label for='connect11_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect1_@uid' data-name='connect0' id='connect12_@uid'><label for='connect12_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tSon numéro de mobile est enregistré sur votre mobile (ou vous-mêmes êtes sur le sien)<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect2_@uid' data-name='connect2' id='connect21_@uid'><label for='connect21_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect2_@uid' data-name='connect2' id='connect22_@uid' checked><label for='connect22_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect2_@uid' data-name='connect1' id='connect21_@uid'><label for='connect21_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect2_@uid' data-name='connect1' id='connect22_@uid' checked><label for='connect22_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tElle figure parmi vos amis facebook<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect3_@uid' data-name='connect3' id='connect31_@uid'><label for='connect31_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect3_@uid' data-name='connect3' id='connect32_@uid' checked><label for='connect32_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect3_@uid' data-name='connect2' id='connect31_@uid'><label for='connect31_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect3_@uid' data-name='connect2' id='connect32_@uid' checked><label for='connect32_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tElle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif régulièrement<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect4_@uid' data-name='connect4' id='connect41_@uid'><label for='connect41_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect4_@uid' data-name='connect4' id='connect42_@uid' checked><label for='connect42_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect4_@uid' data-name='connect3' id='connect41_@uid'><label for='connect41_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect4_@uid' data-name='connect3' id='connect42_@uid' checked><label for='connect42_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tVous le suivez sur Twitter<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect5_@uid' data-name='connect5' id='connect51_@uid'><label for='connect51_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect5_@uid' data-name='connect5' id='connect52_@uid' checked><label for='connect52_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect5_@uid' data-name='connect4' id='connect51_@uid'><label for='connect51_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect5_@uid' data-name='connect4' id='connect52_@uid' checked><label for='connect52_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\tVous communiquez avec cette personne sur Twitter<br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect6_@uid' data-name='connect6' id='connect61_@uid'><label for='connect61_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect6_@uid' data-name='connect6' id='connect62_@uid' checked><label for='connect62_@uid'>Non</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect6_@uid' data-name='connect5' id='connect61_@uid'><label for='connect61_@uid'>Oui</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='connect6_@uid' data-name='connect5' id='connect62_@uid' checked><label for='connect62_@uid'>Non</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+

View File

@ -1,10 +1,13 @@
function inputPhoneFiche(a,c){this.container=a;this.nav_container=c}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate();console.log(b);var d=lsi.get("fiches","form"+b.uid.value);!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("fiches","form"+b.uid,b)}};
inputPhoneFiche.prototype.add=function(a){console.log("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+=ficheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age});$('[data-name="uid"][value="'+
a.uid+'"] ~ h5>span>select').value=a.job;for(var c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)a.sexe[b]?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)a.loc[b]?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi.keys("fiches");this.container.innerHTML="";for(var c=[],b=0;b<a.length;b++){var d=lsi.get("fiches",a[b]);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});c.push(d.uid)}this.updateNavBar(c)};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),c=0;c<a.length&&9>c;c++){var b=lsi.get("contacts",a[c]),d=lsi.get("fiches",a[c]);null==d?lsi.set("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("fiches",a[c],d))}};
inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var c=$$("#nav-fiche > span.active"),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1;a=$$("article.relation-panel .fiche-relation.active");for(b=0;b<a.length;b++)a[b].remClass("active");this.container.children[this.selected].addClass("active")};
inputPhoneFiche.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var c=0;c<a.length;c++){var b=parseInt(a[c])+1;this.nav_container.innerHTML+="<span>"+b+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneFiche.prototype.check=function(){for(var a=lsi.keys("fiches"),c=0;c<a.length;c++){var b=lsi.get("fiches",a[c]),d=!0;(d=(d=d&&!isNaN(parseInt(b.age)))&&"."!=b.job)?this.nav_container.children[b.uid].addClass("done"):this.nav_container.children[b.uid].remClass("done")}};
inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var c=this,c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler()},!1)};
function inputPhoneFiche(b,c){this.container=b;this.nav_container=c}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var b=$$("article.relation-panel .fiche-relation"),c=0;c<b.length;c++){var a=(new FormDeflater(b[c],["input","select"],["data-name"])).deflate();console.log(a);var d=lsi.get("fiches","form"+a.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");a={uid:a.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:[a.sexe[0].status,a.sexe[1].status],age:a.age.value,
job:a.job.value,famsit:[a.famsit[0].status,a.famsit[1].status,a.famsit[2].status],studies:a.studies.value,reltype:[a.reltype[0].status,a.reltype[1].status,a.reltype[2].status,a.reltype[3].status,a.reltype[4].status,a.reltype[5].status,a.reltype[6].status,a.reltype[7].status,a.reltype[8].status],reltypeSpecial:a.reltypeSpecial.value,city:a.city.value,loc:[a.loc[0].status,a.loc[1].status,a.loc[2].status,a.loc[3].status],duration:[a.duration[0].value,a.duration[1].value],context:[a.context[0].status,
a.context[1].status,a.context[2].status,a.context[3].status,a.context[4].status,a.context[5].status,a.context[6].status,a.context[7].status,a.context[8].status,a.context[9].status,a.context[10].status,a.context[11].status,a.context[12].status,a.context[13].status],contextSpecial:[a.contextSpecial[0].value,a.contextSpecial[1].value,a.contextSpecial[2].value],freq:[[a.freq0[0].status,a.freq0[1].status,a.freq0[2].status,a.freq0[3].status],[a.freq1[0].status,a.freq1[1].status,a.freq1[2].status,a.freq1[3].status],
[a.freq2[0].status,a.freq2[1].status,a.freq2[2].status,a.freq2[3].status],[a.freq3[0].status,a.freq3[1].status,a.freq3[2].status,a.freq3[3].status],[a.freq4[0].status,a.freq4[1].status,a.freq4[2].status,a.freq4[3].status]],connect:[[a.connect0[0].status,a.connect0[1].status],[a.connect1[0].status,a.connect1[1].status],[a.connect2[0].status,a.connect2[1].status],[a.connect3[0].status,a.connect3[1].status],[a.connect4[0].status,a.connect4[1].status],[a.connect5[0].status,a.connect5[1].status]],connectSpecial:[a.connectSpecial[0].value,
a.connectSpecial[1].value]};lsi.set("fiches","form"+a.uid,a)}};
inputPhoneFiche.prototype.add=function(b){console.log("FICHE: ADD");if(null==b.uid)return!1;b.firstname=null!=b.firstname?b.firstname:"";b.lastname=null!=b.lastname?b.lastname:"";b.username=null!=b.username?b.username:"";b.age=null!=b.age?b.age:"";b.sexe=null!=b.sexe?b.sexe:[!0,!1];b.job=null!=b.job?b.job:".";b.loc=null!=b.loc?b.loc:[!0,!1,!1,!1];this.container.innerHTML+=ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:b.username,uid:b.uid,age:b.age});$('[data-name="uid"][value="'+
b.uid+'"] ~ h5>span>select').value=b.job;for(var c=$$('[data-name="uid"][value="'+b.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),a=0;a<c.length;a++)b.sexe[a]?c[a].setAttribute("checked","checked"):c[a].removeAttribute("checked");c=$$('[data-name="uid"][value="'+b.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(a=0;a<c.length;a++)b.loc[a]?c[a].setAttribute("checked","checked"):c[a].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var b=lsi.keys("fiches");this.container.innerHTML="";for(var c=[],a=0;a<b.length;a++){var d=lsi.get("fiches",b[a]);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});c.push(d.uid)}this.updateNavBar(c)};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var b=lsi.keys("contacts"),c=0;c<b.length&&9>c;c++){var a=lsi.get("contacts",b[c]),d=lsi.get("fiches",b[c]);null==d?lsi.set("fiches",b[c],{uid:a.uid,firstname:a.firstname,lastname:a.lastname,username:a.username,sexe:[!0,!1],age:"",job:".",loc:[!0,!1,!1,!1]}):(d.firstname=a.firstname,d.lastname=a.lastname,d.username=a.username,lsi.set("fiches",b[c],d))}};
inputPhoneFiche.prototype.nav=function(b){if("undefined"==typeof b||isNaN(b.innerHTML))return!1;for(var c=$$("#nav-fiche > span.active"),a=0;a<c.length;a++)c[a].remClass("active");b.addClass("active");this.selected=parseInt(b.innerHTML)-1;b=$$("article.relation-panel .fiche-relation.active");for(a=0;a<b.length;a++)b[a].remClass("active");this.container.children[this.selected].addClass("active")};
inputPhoneFiche.prototype.updateNavBar=function(b){this.nav_container.innerHTML="";for(var c=0;c<b.length;c++){var a=parseInt(b[c])+1;this.nav_container.innerHTML+="<span>"+a+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneFiche.prototype.check=function(){for(var b=lsi.keys("fiches"),c=0;c<b.length;c++){var a=lsi.get("fiches",b[c]),d=!0;(d=(d=d&&!isNaN(parseInt(a.age)))&&"."!=a.job)?this.nav_container.children[a.uid].addClass("done"):this.nav_container.children[a.uid].remClass("done")}};
inputPhoneFiche.prototype.attach=function(b){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=b;var c=this,c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler()},!1)};

View File

@ -21,11 +21,11 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
console.log('FICHE: FIELDS TO STORAGE');
// {1} Pour chaque formulaire de contact présent //
var existingMiniFiches = $$('article.relation-panel .fiche-relation');
for( var i = 0 ; i < existingMiniFiches.length ; i++ ){
var existingFiches = $$('article.relation-panel .fiche-relation');
for( var i = 0 ; i < existingFiches.length ; i++ ){
// {2} On initialise notre deflater pour récupérer les valeurs //
var deflater = new FormDeflater(existingMiniFiches[i], ['input', 'select'], ['data-name']);
var deflater = new FormDeflater(existingFiches[i], ['input', 'select'], ['data-name']);
// {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom //
var deflated = deflater.deflate();
@ -57,11 +57,74 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
],
age: deflated.age.value,
job: deflated.job.value,
famsit: [
deflated.famsit[0].status, // VRAI si choix 1
deflated.famsit[1].status, // VRAI si choix 2
deflated.famsit[2].status // VRAI si choix 3
],
studies: deflated.studies.value,
reltype: [
deflated.reltype[0].status, // VRAI si choix 1
deflated.reltype[1].status, // VRAI si choix 2
deflated.reltype[2].status, // VRAI si choix 3
deflated.reltype[3].status, // VRAI si choix 4
deflated.reltype[4].status, // VRAI si choix 5
deflated.reltype[5].status, // VRAI si choix 6
deflated.reltype[6].status, // VRAI si choix 7
deflated.reltype[7].status, // VRAI si choix 8
deflated.reltype[8].status // VRAI si choix 9
],
reltypeSpecial: deflated.reltypeSpecial.value,
city: deflated.city.value,
loc: [
deflated.loc[0].status, // VRAI si choix 1
deflated.loc[1].status, // VRAI si choix 2
deflated.loc[2].status, // VRAI si choix 3
deflated.loc[3].status // VRAI si choix 4
],
duration: [
deflated.duration[0].value, // Durée de la relation en mois
deflated.duration[1].value // Durée de la relation en années
],
context: [
deflated.context[0].status, // VRAI si choix 1
deflated.context[1].status, // VRAI si choix 2
deflated.context[2].status, // VRAI si choix 3
deflated.context[3].status, // VRAI si choix 4
deflated.context[4].status, // VRAI si choix 5
deflated.context[5].status, // VRAI si choix 6
deflated.context[6].status, // VRAI si choix 7
deflated.context[7].status, // VRAI si choix 8
deflated.context[8].status, // VRAI si choix 9
deflated.context[9].status, // VRAI si choix 10
deflated.context[10].status, // VRAI si choix 11
deflated.context[11].status, // VRAI si choix 12
deflated.context[12].status, // VRAI si choix 13
deflated.context[13].status // VRAI si choix 14
],
contextSpecial: [
deflated.contextSpecial[0].value, // Valeur du contexte si context[11]
deflated.contextSpecial[1].value, // Valeur du contexte si context[12]
deflated.contextSpecial[2].value // Valeur du contexte si context[13]
],
freq: [
[ deflated.freq0[0].status, deflated.freq0[1].status, deflated.freq0[2].status, deflated.freq0[3].status ],
[ deflated.freq1[0].status, deflated.freq1[1].status, deflated.freq1[2].status, deflated.freq1[3].status ],
[ deflated.freq2[0].status, deflated.freq2[1].status, deflated.freq2[2].status, deflated.freq2[3].status ],
[ deflated.freq3[0].status, deflated.freq3[1].status, deflated.freq3[2].status, deflated.freq3[3].status ],
[ deflated.freq4[0].status, deflated.freq4[1].status, deflated.freq4[2].status, deflated.freq4[3].status ]
],
connect: [
[ deflated.connect0[0].status, deflated.connect0[1].status ],
[ deflated.connect1[0].status, deflated.connect1[1].status ],
[ deflated.connect2[0].status, deflated.connect2[1].status ],
[ deflated.connect3[0].status, deflated.connect3[1].status ],
[ deflated.connect4[0].status, deflated.connect4[1].status ],
[ deflated.connect5[0].status, deflated.connect5[1].status ]
],
connectSpecial: [
deflated.connectSpecial[0].value,
deflated.connectSpecial[1].value
]
};
@ -155,7 +218,7 @@ inputPhoneFiche.prototype.storageToFields = function(){
console.log('FICHE: STORAGE TO FIELDS');
// {1} Pour chaque contact du 'localStorage' //
var existingMiniFiches = lsi.keys('fiches');
var existingFiches = lsi.keys('fiches');
// On réinitialise le HTML
this.container.innerHTML = '';
@ -163,9 +226,9 @@ inputPhoneFiche.prototype.storageToFields = function(){
// On récupère les UIDS
var UIDs = [];
for( var i = 0 ; i < existingMiniFiches.length ; i++ ){
for( var i = 0 ; i < existingFiches.length ; i++ ){
// {2} On récupère les informations du contact //
var ficheData = lsi.get('fiches', existingMiniFiches[i]);
var ficheData = lsi.get('fiches', existingFiches[i]);
// {3} On ajoute un contact à la liste //
this.add({

View File

@ -1,10 +1,10 @@
function inputPhoneMini(a,c){this.container=a;this.nav_container=c}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
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);!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)}};
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});$('[data-name="uid"][value="'+
a.uid+'"] ~ h5>span>select').value=a.job;for(var c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)a.sexe[b]?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)a.loc[b]?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.keys("mini-fiches");this.container.innerHTML="";for(var c=[],b=0;b<a.length;b++){var d=lsi.get("mini-fiches",a[b]);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});c.push(d.uid)}this.updateNavBar(c)};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");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.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var c=$$("#nav-mini > span.active"),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1;a=$$("article.mini-relation-panel .mini-fiche-relation.active");for(b=0;b<a.length;b++)a[b].remClass("active");this.container.children[this.selected].addClass("active")};
inputPhoneMini.prototype.updateNavBar=function(a){this.nav_container.innerHTML="";for(var c=0;c<a.length;c++){var b=parseInt(a[c])+1;this.nav_container.innerHTML+="<span>"+b+"</span>"}this.check();this.nav(this.nav_container.children[this.selected])};inputPhoneMini.prototype.check=function(){for(var a=lsi.keys("mini-fiches"),c=0;c<a.length;c++){var b=lsi.get("mini-fiches",a[c]),d=!0;(d=(d=d&&!isNaN(parseInt(b.age)))&&"."!=b.job)?this.nav_container.children[b.uid].addClass("done"):this.nav_container.children[b.uid].remClass("done")}};
inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var c=this,c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler()},!1)};
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};
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,age:c.age.value,job:c.job.value,loc:c.loc};
lsi.set("mini-fiches","form"+c.uid,c)}};
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:[{status:!0},{status:!1}];a.job=null!=a.job?a.job:".";a.loc=null!=a.loc?a.loc:[{status:!0},{status:!1},{status:!1},{status:!1}];this.container.innerHTML+=miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,
uid:a.uid,age:a.age,job:a.job});console.log(a.job);var b=$('[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select>option[value="'+a.job+'"]');console.log(b);null!=b&&b.setAttribute("selected","selected");for(var c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<
c.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};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(){console.log("MINI FICHE: SYNC");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?d={uid:c.uid,firstname:c.firstname,lastname:c.lastname,username:c.username,sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}:(d.firstname=c.firstname,d.lastname=c.lastname,d.username=c.username);lsi.set("mini-fiches",a[b],d)}};
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||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;a=$$("article.mini-relation-panel .mini-fiche-relation.active");for(c=0;c<a.length;c++)a[c].remClass("active");this.container.children[this.selected].addClass("active")};
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.check();this.nav(this.nav_container.children[this.selected])};inputPhoneMini.prototype.check=function(){for(var a=lsi.keys("mini-fiches"),b=0;b<a.length;b++){var c=lsi.get("mini-fiches",a[b]),d=!0;(d=(d=d&&!isNaN(parseInt(c.age)))&&"."!=c.job)?this.nav_container.children[c.uid].addClass("done"):this.nav_container.children[c.uid].remClass("done")}};
inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler()},!1)};

View File

@ -30,7 +30,6 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
// {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom //
var deflated = deflater.deflate();
// {4} On récupère les données du LSI si elles existent //
var existingData = lsi.get('mini-fiches', 'form'+deflated.uid.value);
@ -48,18 +47,10 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
firstname: existingData.firstname,
lastname: existingData.lastname,
username: existingData.username,
sexe: [
deflated.sexe[0].status, // VRAI SI HOMME
deflated.sexe[1].status // VRAI SI FEMME
],
sexe: deflated.sexe, // [0] Homme, [1] Femme
age: deflated.age.value,
job: deflated.job.value,
loc: [
deflated.loc[0].status, // VRAI si choix 1
deflated.loc[1].status, // VRAI si choix 2
deflated.loc[2].status, // VRAI si choix 3
deflated.loc[3].status // VRAI si choix 4
]
loc: deflated.loc // [0] Choix 1 -> [3] Choix 4
};
// {6} On enregistre les données dans le 'localStorage' //
@ -98,9 +89,9 @@ inputPhoneMini.prototype.add = function(objectData){
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : '';
objectData.username = (objectData.username != null) ? objectData.username : '';
objectData.age = (objectData.age != null) ? objectData.age : '';
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : [true, false];
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : [{status:true}, {status:false}];
objectData.job = (objectData.job != null) ? objectData.job : '.';
objectData.loc = (objectData.loc != null) ? objectData.loc : [true, false, false, false];
objectData.loc = (objectData.loc != null) ? objectData.loc : [{status:true}, {status:false}, {status:false}, {status:false}];
// {1} Création physique //
@ -109,31 +100,27 @@ inputPhoneMini.prototype.add = function(objectData){
lastname: objectData.lastname,
username: objectData.username,
uid: objectData.uid,
age: objectData.age
// sexe: objectData.sexe[0] ? 'true' : 'false',
// job: objectData.job,
// loca: objectData.loc[0] ? 'true' : 'false',
// locb: objectData.loc[1] ? 'true' : 'false',
// locc: objectData.loc[2] ? 'true' : 'false',
// locd: objectData.loc[3] ? 'true' : 'false'
age: objectData.age,
job: objectData.job
});
/* (2) On sélectionne la valeur dans le select (manuellement) */
var createdSelect = $('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select');
createdSelect.value = objectData.job;
var selectedOption = $('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select>option[value="'+objectData.job+'"]');
if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected');
/* (3) On sélectionna la valeur des boutons <radio> pour le SEXE */
var sexeCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
for( var i = 0 ; i < sexeCreated.length ; i++ )
if( objectData.sexe[i] ) sexeCreated[i].setAttribute('checked', 'checked');
else sexeCreated[i].removeAttribute('checked');
if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked');
else sexeCreated[i].removeAttribute('checked');
/* (4) On sélectionna la valeur des boutons <radio> pour la LOCATION */
var locCreated = $$('[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
for( var i = 0 ; i < locCreated.length ; i++ )
if( objectData.loc[i] ) locCreated[i].setAttribute('checked', 'checked');
else locCreated[i].removeAttribute('checked');
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
else locCreated[i].removeAttribute('checked');
};
@ -216,16 +203,16 @@ inputPhoneMini.prototype.sync = function(){
if( miniData == null ){
// On crée la MINI fiche
lsi.set('mini-fiches', contactUIDs[i], {
miniData = {
uid: contactData.uid,
firstname: contactData.firstname,
lastname: contactData.lastname,
username: contactData.username,
sexe: [true, false], // valeur par défaut
age: '', // valeur par défaut
job: '.', // valeur par défaut
loc: [true, false, false, false] // valeur par défaut
});
sexe: [{status:true}, {status:false}], // valeur par défaut
age: '', // valeur par défaut
job: '.', // valeur par défaut
loc: [{status:true}, {status:false}, {status:false}, {status:false}] // valeur par défaut
};
/* (6) Cas 2 : la MINI fiche existe déja */
@ -236,12 +223,12 @@ inputPhoneMini.prototype.sync = function(){
miniData.lastname = contactData.lastname;
miniData.username = contactData.username;
// On met à jour la MINI fiche
lsi.set('mini-fiches', contactUIDs[i], miniData);
}
/* (7) On met à jour la MINI fiche */
lsi.set('mini-fiches', contactUIDs[i], miniData);
}
};

View File

@ -1,5 +1,3 @@
function updateListener(b,a,c){b.removeEventListener(a,c);b.addEventListener(a,c)}var importCallLog=$('input#call_log-import[type="file"]'),ficheContainer=$("article.relation-panel"),subjectManager,contactManager,miniManager,ficheManager;
function dynamicUpdate(){console.log("DYNAMIC UPDATE: UPDATING");miniManager.fieldsToStorage();ficheManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.sync();ficheManager.sync();miniManager.storageToFields();ficheManager.storageToFields();contactManager.storageToFields()}
function updateListener(b,a,c){b.removeEventListener(a,c);b.addEventListener(a,c)}var importCallLog=$('input#call_log-import[type="file"]'),ficheContainer=$("article.relation-panel"),subjectManager,contactManager,miniManager,ficheManager;function dynamicUpdate(){console.log("DYNAMIC UPDATE: UPDATING");miniManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.sync();miniManager.storageToFields();contactManager.storageToFields()}
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate)})})})});
importCallLog.addEventListener("change",function(b){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);0==a.ModuleError&&importCallLog.addClass("active")})},!1);
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate)})})})});importCallLog.addEventListener("change",function(b){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);0==a.ModuleError&&importCallLog.addClass("active")})},!1);

View File

@ -53,7 +53,7 @@ function dynamicUpdate(){
miniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
ficheManager.fieldsToStorage();
// ficheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
contactManager.fieldsToStorage();
@ -62,11 +62,11 @@ function dynamicUpdate(){
miniManager.sync();
/* (5) On synchronise les FICHE avec les CONTACTS */
ficheManager.sync();
// ficheManager.sync();
/* (6) On affiche le tout */
miniManager.storageToFields();
ficheManager.storageToFields();
// ficheManager.storageToFields();
contactManager.storageToFields();
}
@ -141,13 +141,13 @@ include('/js/includes/input-phone-fiche.js', function(){
/* [6] Gestion des fiches relation
=========================================================*/
/* (1) On crée une instance du gestionnaire des fiches relation */
ficheManager = new inputPhoneFiche(
$('article.relation-panel'),
$('#nav-fiche')
);
/* (2) On le démarre */
ficheManager.attach(dynamicUpdate);
// ficheManager = new inputPhoneFiche(
// $('article.relation-panel'),
// $('#nav-fiche')
// );
//
// /* (2) On le démarre */
// ficheManager.attach(dynamicUpdate);