On n'enregistre plus `username`, `firstname` et `lastname` dans `mini` ni dans `fiche`, on les récupère de `contacts`

This commit is contained in:
xdrm-brackets 2016-05-03 15:39:16 +02:00
parent 30e5f1fc08
commit 818f06d452
9 changed files with 83 additions and 98 deletions

File diff suppressed because one or more lines are too long

View File

@ -48,6 +48,13 @@ miniFicheBuilder.setLayout(
"\t<span data-space></span>\n"+ "\t<span data-space></span>\n"+
"\t<h4 data-icon='a' class='color2'>@firstname @lastname @username</h4>\n"+ "\t<h4 data-icon='a' class='color2'>@firstname @lastname @username</h4>\n"+
"\t<h5 class='nobold color0'>"+
"\t\t10 appels"+
"\t</h5>"+
"\t<h5 class='nobold color0'>"+
"\t\t15 sms"+
"\t</h5>"+
"\t<h5 class='nobold color0'>\n"+ "\t<h5 class='nobold color0'>\n"+
"\t\t<input type='radio' name='sexe_min_@uid' data-name='sexe' id='sexeH_min_@uid'><label for='sexeH_min_@uid'>Homme</label>\n"+ "\t\t<input type='radio' name='sexe_min_@uid' data-name='sexe' id='sexeH_min_@uid'><label for='sexeH_min_@uid'>Homme</label>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='sexe_min_@uid' data-name='sexe' id='sexeF_min_@uid'><label for='sexeF_min_@uid'>Femme</label>\n"+ "\t\t&nbsp&nbsp&nbsp<input type='radio' name='sexe_min_@uid' data-name='sexe' id='sexeF_min_@uid'><label for='sexeF_min_@uid'>Femme</label>\n"+

View File

@ -1,22 +1,20 @@
function inputPhoneFiche(a,b){this.container=a;this.nav_container=b} function inputPhoneFiche(a,b){this.container=a;this.nav_container=b}
inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",famsit:[{status:!0},{status:!1},{status:!1}],studies:".",reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",city:"",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],loc2:[{status:!0},{status:!1},{status:!1}, inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:[{status:!0},{status:!1}],age:"",job:".",famsit:[{status:!0},{status:!1},{status:!1}],studies:".",reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",city:"",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],loc2:[{status:!0},{status:!1},{status:!1},{status:!1}],duration:["",""],context:[{status:!0},
{status:!1}],duration:["",""],context:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!1}, {status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!1},{status:!0}],[{status:!1},{status:!0}],
{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}]],connectSpecial:["",""],timestamp:0,valid:!1}}; [{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}]],connectSpecial:["",""],timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(c)),e=lsi.get("fiches",c.uid.value);!1===e&&(e.username="inconnu",e.firstname="inconnu",e.lastname="inconnu");if(null!=e.hash&&e.hash==d)break;console.warn("> FICHE UPDATE");c={uid:c.uid.value,firstname:e.firstname,lastname:e.lastname,username:e.username, inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(c)),e=lsi.get("fiches",c.uid.value);if(!1!==e){if(null!=e.hash&&e.hash==d)break;console.warn("> FICHE UPDATE");c={uid:c.uid.value,sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,
sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,loc2:c.loc2,duration:[c.duration[0].value,c.duration[1].value],context:c.context,contextSpecial:[c.contextSpecial[0].value,c.contextSpecial[1].value,c.contextSpecial[2].value],freq:[c.freq0,c.freq1,c.freq2,c.freq3,c.freq4],connect:[c.connect0,c.connect1,c.connect2,c.connect3,c.connect4,c.connect5],connectSpecial:[c.connectSpecial[0].value, city:c.city.value,loc:c.loc,loc2:c.loc2,duration:[c.duration[0].value,c.duration[1].value],context:c.context,contextSpecial:[c.contextSpecial[0].value,c.contextSpecial[1].value,c.contextSpecial[2].value],freq:[c.freq0,c.freq1,c.freq2,c.freq3,c.freq4],connect:[c.connect0,c.connect1,c.connect2,c.connect3,c.connect4,c.connect5],connectSpecial:[c.connectSpecial[0].value,c.connectSpecial[1].value],hash:d};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("fiches",c.uid,c)}}};
c.connectSpecial[1].value],hash:d};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("fiches",c.uid,c)}}; inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]: a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;
this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0]; a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.loc2=null!=a.loc2?a.loc2:this.defaultData.loc2;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("contacts",a.uid);if(!1===b)return!1;this.container.innerHTML+=
a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.loc2=null!=a.loc2?a.loc2:this.defaultData.loc2;a.context=null!=a.context?a.context: ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",uid:a.uid,age:a.age,city:a.city,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+
this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;this.container.innerHTML+=ficheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:0==a.username.length?"":"("+a.username+")",uid:a.uid,age:a.age,city:a.city,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0], a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+
connectspecial1:a.connectSpecial[1]});var b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'), a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length&&b<a.famsit.length;b++)a.famsit[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length&&b<a.reltype.length;b++)a.reltype[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+
b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length&&b<a.famsit.length;b++)a.famsit[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b< a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');for(b=0;b<c.length&&b<a.loc2.length;b++)a.loc2[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
c.length&&b<a.reltype.length;b++)a.reltype[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');for(b=0;b<c.length&& for(b=0;b<c.length&&b<a.context.length;b++)a.context[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<d.length&&b<a.freq[c].length;b++)a.freq[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+
b<a.loc2.length;b++)a.loc2[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length&&b<a.context.length;b++)a.context[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+ a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<d.length&&b<a.connect[c].length;b++)a.connect[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)};
c+'"]'),b=0;b<d.length&&b<a.freq[c].length;b++)a.freq[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<d.length&&b<a.connect[c].length;b++)a.connect[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")}; inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length&&10>b;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;lsi.set("fiches",a[b],d)}var a=lsi["export"]("mini-fiches"),d=lsi["export"]("fiches"),e;for(e in d)d[e].timestamp>a[e].timestamp?(a[e].sexe=d[e].sexe,a[e].age=d[e].age,a[e].job=d[e].job,a[e].loc=d[e].loc):(d[e].sexe=a[e].sexe,d[e].age=a[e].age,d[e].job=a[e].job,d[e].loc=a[e].loc),
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)}; lsi.set("mini-fiches",e,a[e]),lsi.set("fiches",e,d[e])};inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length&&10>b;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;d.firstname=c.firstname;d.lastname=c.lastname;d.username=c.username;lsi.set("fiches",a[b],d)}var a=lsi["export"]("mini-fiches"),d=lsi["export"]("fiches"),e;for(e in d)d[e].timestamp>a[e].timestamp?(a[e].sexe=d[e].sexe,a[e].age=d[e].age,a[e].job=d[e].job,a[e].loc=d[e].loc):(d[e].sexe=
a[e].sexe,d[e].age=a[e].age,d[e].job=a[e].job,d[e].loc=a[e].loc),lsi.set("mini-fiches",e,a[e]),lsi.set("fiches",e,d[e])};inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])}; inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.loc2)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1; inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.loc2)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1;
for(b=0;b<a.connect.length;b++)if(!checkRadioValue(a.connect[b]))return!1;return a.reltype[8].status&&2>a.reltypeSpecial.length||a.context[11].status&&2>a.contextSpecial[0].length||a.context[12].status&&2>a.contextSpecial[1].length||a.context[13].status&&2>a.contextSpecial[2].length?!1:!0}; for(b=0;b<a.connect.length;b++)if(!checkRadioValue(a.connect[b]))return!1;return a.reltype[8].status&&2>a.reltypeSpecial.length||a.context[11].status&&2>a.contextSpecial[0].length||a.context[12].status&&2>a.contextSpecial[1].length||a.context[13].status&&2>a.contextSpecial[2].length?!1:!0};

View File

@ -13,9 +13,6 @@ inputPhoneFiche.prototype = {
selected: 0, // UID de la FICHE sélectionnée selected: 0, // UID de la FICHE sélectionnée
handler: null, // Fonction pour l'enregistrement et la synchronisation des données handler: null, // Fonction pour l'enregistrement et la synchronisation des données
defaultData: { // Valeurs par défaut defaultData: { // Valeurs par défaut
firstname: '',
lastname: '',
username: '',
sexe: [ {status:true}, {status:false}], sexe: [ {status:true}, {status:false}],
age: '', age: '',
job: '.', job: '.',
@ -76,12 +73,9 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
// {4} On récupère les données du LSI si elles existent // // {4} On récupère les données du LSI si elles existent //
var existingData = lsi.get('fiches', deflated.uid.value); var existingData = lsi.get('fiches', deflated.uid.value);
// Si n'existe pas, on initialise // Si n'existe pas, on passe au suivant
if( existingData === false ){ if( existingData === false )
existingData.username = 'inconnu'; continue;
existingData.firstname = 'inconnu';
existingData.lastname = 'inconnu';
}
// {5} On récupère et met en forme les valeurs du deflater // // {5} On récupère et met en forme les valeurs du deflater //
@ -94,9 +88,6 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
var obj = { var obj = {
uid: deflated.uid.value, uid: deflated.uid.value,
firstname: existingData.firstname,
lastname: existingData.lastname,
username: existingData.username,
sexe: deflated.sexe, // Choix 1 à 2 sexe: deflated.sexe, // Choix 1 à 2
age: deflated.age.value, age: deflated.age.value,
job: deflated.job.value, job: deflated.job.value,
@ -173,9 +164,6 @@ inputPhoneFiche.prototype.add = function(objectData){
/* (0) Gestion du formattage des valeur */ /* (0) Gestion du formattage des valeur */
// {1} Champs de texte // // {1} Champs de texte //
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : this.defaultData.firstname;
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : this.defaultData.lastname;
objectData.username = (objectData.username != null) ? objectData.username : this.defaultData.username;
objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age;
objectData.city = (objectData.city != null) ? objectData.city : this.defaultData.city; objectData.city = (objectData.city != null) ? objectData.city : this.defaultData.city;
objectData.duration[0] = (objectData.duration[0] != null) ? objectData.duration[0] : this.defaultData.duration[0]; objectData.duration[0] = (objectData.duration[0] != null) ? objectData.duration[0] : this.defaultData.duration[0];
@ -202,11 +190,19 @@ inputPhoneFiche.prototype.add = function(objectData){
objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect; objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect;
// {1} Création physique // // {4} On récupère username/firstname/lastname du contact associé //
var associatedContact = lsi.get('contacts', objectData.uid);
// Si on ne trouve pas le contact, on ne fais rien
if( associatedContact === false )
return false;
// {5} Création physique //
this.container.innerHTML += ficheBuilder.build({ this.container.innerHTML += ficheBuilder.build({
firstname: objectData.firstname, firstname: associatedContact.firstname,
lastname: objectData.lastname, lastname: associatedContact.lastname,
username: (objectData.username.length==0) ? '' : '('+objectData.username+')', username: (associatedContact.username.length==0) ? '' : '('+associatedContact.username+')',
uid: objectData.uid, uid: objectData.uid,
age: objectData.age, age: objectData.age,
city: objectData.city, city: objectData.city,
@ -221,59 +217,59 @@ inputPhoneFiche.prototype.add = function(objectData){
}); });
/* (2) On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ /* {6} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */
var selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]'); var selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]');
if( selectedOption != null ) if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected'); selectedOption.setAttribute('selected', 'selected');
/* (3) On sélectionne la valeur dans le select (manuellement) des ETUDES */ /* {7} On sélectionne la valeur dans le select (manuellement) des ETUDES */
selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]'); selectedOption = $('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+objectData.studies+'"]');
if( selectedOption != null ) if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected'); selectedOption.setAttribute('selected', 'selected');
/* (4) On sélectionna la valeur des boutons <radio> pour le SEXE */ /* {8} On sélectionna la valeur des boutons <radio> pour le SEXE */
var sexeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); var sexeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ ) for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ )
if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked'); if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked');
else sexeCreated[i].removeAttribute('checked'); else sexeCreated[i].removeAttribute('checked');
/* (5) On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */ /* {9} On sélectionna la valeur des boutons <radio> pour la SITUATION FAMILIALE */
var famsitCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]'); var famsitCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
for( var i = 0 ; i < famsitCreated.length && i < objectData.famsit.length ; i++ ) for( var i = 0 ; i < famsitCreated.length && i < objectData.famsit.length ; i++ )
if( objectData.famsit[i].status ) famsitCreated[i].setAttribute('checked', 'checked'); if( objectData.famsit[i].status ) famsitCreated[i].setAttribute('checked', 'checked');
else famsitCreated[i].removeAttribute('checked'); else famsitCreated[i].removeAttribute('checked');
/* (6) On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */ /* {10} On sélectionna la valeur des boutons <radio> pour le TYPE DE RELATION */
var reltypeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]'); var reltypeCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
for( var i = 0 ; i < reltypeCreated.length && i < objectData.reltype.length ; i++ ) for( var i = 0 ; i < reltypeCreated.length && i < objectData.reltype.length ; i++ )
if( objectData.reltype[i].status ) reltypeCreated[i].setAttribute('checked', 'checked'); if( objectData.reltype[i].status ) reltypeCreated[i].setAttribute('checked', 'checked');
else reltypeCreated[i].removeAttribute('checked'); else reltypeCreated[i].removeAttribute('checked');
/* (7) On sélectionna la valeur des boutons <radio> pour la LOCATION */ /* {11} On sélectionna la valeur des boutons <radio> pour la LOCATION */
var locCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); var locCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ ) for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ )
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked'); if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
else locCreated[i].removeAttribute('checked'); else locCreated[i].removeAttribute('checked');
/* (7bis) On sélectionna la valeur des boutons <radio> pour la LOCATION */ /* {12}is) On sélectionna la valeur des boutons <radio> pour la LOCATION */
var loc2Created = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]'); var loc2Created = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');
for( var i = 0 ; i < loc2Created.length && i < objectData.loc2.length ; i++ ) for( var i = 0 ; i < loc2Created.length && i < objectData.loc2.length ; i++ )
if( objectData.loc2[i].status ) loc2Created[i].setAttribute('checked', 'checked'); if( objectData.loc2[i].status ) loc2Created[i].setAttribute('checked', 'checked');
else loc2Created[i].removeAttribute('checked'); else loc2Created[i].removeAttribute('checked');
/* (8) On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */ /* {13} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]'); var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
for( var i = 0 ; i < contextCreated.length && i < objectData.context.length ; i++ ) for( var i = 0 ; i < contextCreated.length && i < objectData.context.length ; i++ )
if( objectData.context[i].status ) contextCreated[i].setAttribute('checked', 'checked'); if( objectData.context[i].status ) contextCreated[i].setAttribute('checked', 'checked');
else contextCreated[i].removeAttribute('checked'); else contextCreated[i].removeAttribute('checked');
/* (9) On sélectionna la valeur des boutons <radio> pour les FREQUENCES */ /* {14} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
for( var f = 0 ; f < objectData.freq.length ; f++ ){ for( var f = 0 ; f < objectData.freq.length ; f++ ){
var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq'+f+'"]'); var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq'+f+'"]');
for( var i = 0 ; i < freqCreated.length && i < objectData.freq[f].length ; i++ ) for( var i = 0 ; i < freqCreated.length && i < objectData.freq[f].length ; i++ )
@ -281,7 +277,7 @@ inputPhoneFiche.prototype.add = function(objectData){
else freqCreated[i].removeAttribute('checked'); else freqCreated[i].removeAttribute('checked');
} }
/* (10) On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */ /* {15} On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */
for( var c = 0 ; c < objectData.connect.length ;c++ ){ for( var c = 0 ; c < objectData.connect.length ;c++ ){
var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'); var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]');
for( var i = 0 ; i < connectCreated.length && i < objectData.connect[c].length ; i++ ) for( var i = 0 ; i < connectCreated.length && i < objectData.connect[c].length ; i++ )
@ -367,11 +363,7 @@ inputPhoneFiche.prototype.sync = function(){
/* (6) On met à jour la fiche */ /* (6) On met à jour la fiche */
ficheData.uid = contactData.uid; ficheData.uid = contactData.uid;
ficheData.firstname = contactData.firstname;
ficheData.lastname = contactData.lastname;
ficheData.username = contactData.username;
/* (7) On enregistre les modification */ /* (7) On enregistre les modification */
lsi.set('fiches', contactUIDs[i], ficheData); lsi.set('fiches', contactUIDs[i], ficheData);

View File

@ -1,11 +1,9 @@
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,defaultData:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],timestamp:0,valid:!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,defaultData:{sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],timestamp:0,valid:!1}};
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(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname, 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=crc32(JSON.stringify(c)),e=lsi.get("mini-fiches",c.uid.value);if(!1!==e){if(null!=e.hash&&e.hash==d)break;console.warn("> MINI UPDATE");c={uid:c.uid.value,firstname:e.firstname,lastname:e.lastname,username:e.username,sexe:c.sexe,age:c.age.value,
username:d.username,sexe:c.sexe,age:c.age.value,job:c.job.value,loc:c.loc,hash:e};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("mini-fiches",c.uid,c)}}; job:c.job.value,loc:c.loc,hash:d};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("mini-fiches",c.uid,c)}}};
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+= inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;var b=lsi.get("contacts",a.uid);if(!1===b)return!1;this.container.innerHTML+=miniFicheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",uid:a.uid,age:a.age,
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:0==a.username.length?"":"("+a.username+")",uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status? job:a.job});b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+
c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")}; a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.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["export"]("mini-fiches");this.container.innerHTML="";this.add(a[this.selected]);this.updateNavBar()};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a[this.selected]);this.updateNavBar()}; inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;lsi.set("mini-fiches",b,c)}};inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-mini"!=a.parentNode.id)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};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}}; inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"nav-mini"!=a.parentNode.id)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};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var e in a)b=this.nav_container.children[a[e].uid],b.innerHTML=a[e].uid+1,!0===a[e].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)}; inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};

View File

@ -13,9 +13,6 @@ inputPhoneMini.prototype = {
selected: 0, // UID de la MINI fiche sélectionnée selected: 0, // UID de la MINI fiche sélectionnée
handler: null, // Fonction pour l'enregistrement et la synchronisation des données handler: null, // Fonction pour l'enregistrement et la synchronisation des données
defaultData: { // Valeur par défaut defaultData: { // Valeur par défaut
firstname: '',
lastname: '',
username: '',
sexe: [{status:true}, {status:false}], sexe: [{status:true}, {status:false}],
age: '', age: '',
job: '.', job: '.',
@ -49,12 +46,9 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
// {4} On récupère les données du LSI si elles existent // // {4} On récupère les données du LSI si elles existent //
var existingData = lsi.get('mini-fiches', deflated.uid.value); var existingData = lsi.get('mini-fiches', deflated.uid.value);
// Si n'existe pas, on initialise // Si n'existe pas, on passe à la suivante
if( existingData === false ){ if( existingData === false )
existingData.username = 'inconnu'; continue;
existingData.firstname = 'inconnu';
existingData.lastname = 'inconnu';
}
// {5} On récupère et met en forme les valeurs du deflater // // {5} On récupère et met en forme les valeurs du deflater //
@ -111,38 +105,43 @@ inputPhoneMini.prototype.add = function(objectData){
return false; return false;
/* (0) Gestion du formattage des valeur */ /* (0) Gestion du formattage des valeur */
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : this.defaultData.firstname;
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : this.defaultData.lastname;
objectData.username = (objectData.username != null) ? objectData.username : this.defaultData.username;
objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age; objectData.age = (objectData.age != null) ? objectData.age : this.defaultData.age;
objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe; objectData.sexe = (objectData.sexe != null) ? objectData.sexe : this.defaultData.sexe;
objectData.job = (objectData.job != null) ? objectData.job : this.defaultData.job; objectData.job = (objectData.job != null) ? objectData.job : this.defaultData.job;
objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc; objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc;
// {1} Création physique // // {1} On récupère username/firstname/lastname du contact associé //
var associatedContact = lsi.get('contacts', objectData.uid);
// Si on ne trouve pas le contact, on ne fais rien
if( associatedContact === false )
return false;
// {2} Création physique //
this.container.innerHTML += miniFicheBuilder.build({ this.container.innerHTML += miniFicheBuilder.build({
firstname: objectData.firstname, firstname: associatedContact.firstname,
lastname: objectData.lastname, lastname: associatedContact.lastname,
username: (objectData.username.length==0) ? '' : '('+objectData.username+')', username: (associatedContact.username.length==0) ? '' : '('+associatedContact.username+')',
uid: objectData.uid, uid: objectData.uid,
age: objectData.age, age: objectData.age,
job: objectData.job job: objectData.job
}); });
/* (2) On sélectionne la valeur dans le select (manuellement) de la PROFESSION */ /* {3} On sélectionne la valeur dans le select (manuellement) de la PROFESSION */
var selectedOption = $('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]'); var selectedOption = $('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+objectData.job+'"]');
if( selectedOption != null ) if( selectedOption != null )
selectedOption.setAttribute('selected', 'selected'); selectedOption.setAttribute('selected', 'selected');
/* (3) On sélectionna la valeur des boutons <radio> pour le SEXE */ /* {4} On sélectionna la valeur des boutons <radio> pour le SEXE */
var sexeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'); var sexeCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');
for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ ) for( var i = 0 ; i < sexeCreated.length && i < objectData.sexe.length ; i++ )
if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked'); if( objectData.sexe[i].status ) sexeCreated[i].setAttribute('checked', 'checked');
else sexeCreated[i].removeAttribute('checked'); else sexeCreated[i].removeAttribute('checked');
/* (4) On sélectionna la valeur des boutons <radio> pour la LOCATION */ /* {5} On sélectionna la valeur des boutons <radio> pour la LOCATION */
var locCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]'); var locCreated = $$('article.mini-fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');
for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ ) for( var i = 0 ; i < locCreated.length && i < objectData.loc.length ; i++ )
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked'); if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
@ -210,10 +209,7 @@ inputPhoneMini.prototype.sync = function(){
} }
/* (5) On met à jour la MINI fiche */ /* (5) On met à jour la MINI fiche */
miniData.uid = contactData[key].uid; miniData.uid = contactData[key].uid;
miniData.firstname = contactData[key].firstname;
miniData.lastname = contactData[key].lastname;
miniData.username = contactData[key].username;
/* (6) On enregistre les modification */ /* (6) On enregistre les modification */

View File

@ -262,9 +262,6 @@
/* (5) Vérification des mini-fiches */ /* (5) Vérification des mini-fiches */
foreach($json['mini'] as $mini){ foreach($json['mini'] as $mini){
$checkMini = isset($mini['uid']) && is_numeric($mini['uid']); $checkMini = isset($mini['uid']) && is_numeric($mini['uid']);
$checkMini = $checkMini && isset($mini['username']) && is_string($mini['username']);
$checkMini = $checkMini && isset($mini['firstname']) && is_string($mini['firstname']);
$checkMini = $checkMini && isset($mini['lastname']) && is_string($mini['lastname']);
$checkMini = $checkMini && isset($mini['sexe']) && is_array($mini['sexe']); $checkMini = $checkMini && isset($mini['sexe']) && is_array($mini['sexe']);
$checkMini = $checkMini && isset($mini['age']) && is_string($mini['age']); $checkMini = $checkMini && isset($mini['age']) && is_string($mini['age']);
$checkMini = $checkMini && isset($mini['job']) && is_string($mini['job']); $checkMini = $checkMini && isset($mini['job']) && is_string($mini['job']);
@ -280,9 +277,6 @@
/* (6) Vérification des fiches */ /* (6) Vérification des fiches */
foreach($json['fiches'] as $fiches){ foreach($json['fiches'] as $fiches){
$checkFiche = isset($fiches['uid']) && is_numeric($fiches['uid']); $checkFiche = isset($fiches['uid']) && is_numeric($fiches['uid']);
$checkFiche = $checkFiche && isset($fiches['username']) && is_string($fiches['username']);
$checkFiche = $checkFiche && isset($fiches['firstname']) && is_string($fiches['firstname']);
$checkFiche = $checkFiche && isset($fiches['lastname']) && is_string($fiches['lastname']);
$checkFiche = $checkFiche && isset($fiches['sexe']) && is_array($fiches['sexe']); $checkFiche = $checkFiche && isset($fiches['sexe']) && is_array($fiches['sexe']);
$checkFiche = $checkFiche && isset($fiches['age']) && is_string($fiches['age']); $checkFiche = $checkFiche && isset($fiches['age']) && is_string($fiches['age']);
$checkFiche = $checkFiche && isset($fiches['job']) && is_string($fiches['job']); $checkFiche = $checkFiche && isset($fiches['job']) && is_string($fiches['job']);

View File

@ -4,7 +4,7 @@ d;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNo
function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0} function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
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"]')); 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"),$("#nav-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(a){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:importCallLog.files[0]}; subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-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(a){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:importCallLog.files[0]};
api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0;b<a.directory.length;b++){var d=(null===a.directory[b].name?"":a.directory[b].name).split(" ");lsi.set("contacts",b,{uid:b,number:a.directory[b].number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);$("#export-all").addEventListener("click", api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0;b<a.calls.length;b++){var d=(null===a.calls[b].name?"":a.calls[b].name).split(" ");lsi.set("contacts",b,{uid:b,number:a.calls[b].number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);$("#export-all").addEventListener("click",function(a){a=
function(a){a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};var c=$("#download-target");c.download="local-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#local-upload").files[0]}; {subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};var c=$("#download-target");c.download="local-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#local-upload").files[0]};api.send(a,
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage(); function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();
ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},!1)},!1)})})})}); ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},!1)},!1)})})})});

View File

@ -237,15 +237,15 @@ include('/js/includes/input-phone-fiche.js', function(){
return; return;
/* (3) Pour chaque contact de l'annuaire, on ajoute un contact */ /* (3) Pour chaque contact de l'annuaire, on ajoute un contact */
for( var i = 0 ; i < response.directory.length ; i++ ){ for( var i = 0 ; i < response.calls.length ; i++ ){
// On découpe le nom par espaces // On découpe le nom par espaces
var name = response.directory[i].name===null ? '' : response.directory[i].name; var name = response.calls[i].name===null ? '' : response.calls[i].name;
var splitted = name.split(' '); var splitted = name.split(' ');
lsi.set('contacts', i, { lsi.set('contacts', i, {
uid: i, uid: i,
number: response.directory[i].number, number: response.calls[i].number,
username: splitted.length == 1 ? splitted[0] : '', // Si un seul mot -> pseudo username: splitted.length == 1 ? splitted[0] : '', // Si un seul mot -> pseudo
firstname: splitted.length > 1 ? splitted[0] : '', // Si plusieurs mots -> le 1er est le prénom firstname: splitted.length > 1 ? splitted[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splitted.length > 1 ? splitted.splice(1).join(' ') : '' // et les autres sont le nom lastname: splitted.length > 1 ? splitted.splice(1).join(' ') : '' // et les autres sont le nom