Correction de la synchronisation croisée entre les `mini` et les `fiches` associées, lors du premier `dynamicUpdate()`, le `timestamp` était mis à jour pour les `mini` puis les `fiches` même s'il n'y avait pas eu de modification à cause du `hash` qui n'était pas encore défini, ajout de la méthode `diff(objectA, objectB)` qui vérifie (en profondeur) et renvoie les clés des valeurs qui sont différentes pour ​*vraiment*​ vérifier si on a modifié les valeurs.

This commit is contained in:
xdrm-brackets 2016-05-08 15:25:20 +02:00
parent 5b1d01ecbf
commit 11a1af7eb8
8 changed files with 113 additions and 58 deletions

View File

@ -1,24 +1,23 @@
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:{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}],duration:["",""],context:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1}, inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:[defTrue,defFalse],age:".",job:".",famsit:[defTrue,defFalse,defFalse],studies:".",reltype:[defTrue,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse],reltypeSpecial:"",city:"",loc:[defTrue,defFalse,defFalse,defFalse],duration:["",""],context:[defTrue,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,
{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:!1},{status:!0}],[{status:!1},{status:!0}], defFalse],contextSpecial:["","",""],freq:[[defTrue,defFalse,defFalse,defFalse],[defTrue,defFalse,defFalse,defFalse],[defTrue,defFalse,defFalse,defFalse],[defTrue,defFalse,defFalse,defFalse],[defTrue,defFalse,defFalse,defFalse]],connect:[[defFalse,defTrue],[defFalse,defTrue],[defFalse,defTrue],[defFalse,defTrue],[defFalse,defTrue],[defFalse,defTrue]],connectSpecial:["",""],timestamp:0,valid:!1}};
[{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(),e=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid.value);if(!1!==d){if(null!=d.hash&&d.hash==e)break;c={contact:parseInt(c.contact.value),uid:parseInt(c.uid.value),sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value,reltype:c.reltype,
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(),e=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid.value);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> FICHE UPDATE");c={contact:c.contact.value,uid:c.uid.value,sexe:c.sexe,age:c.age.value,job:c.job.value,famsit:c.famsit,studies:c.studies.value, reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,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:e};c.valid=this.check(c);0<diff(d,c).length&&(console.warn("> FICHE UPDATE"),
reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,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:e};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("fiches", c.timestamp=Date.now());lsi.set("fiches",c.uid,c)}}};
c.uid,c)}}}; inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||null==a.contact)return!1;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||null==a.contact)return!1;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];a.contextSpecial[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;
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;a.age=null!= a.age=null!=a.age?a.age:this.defaultData.age;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.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.contact);if(!1===b)return!1;this.container.innerHTML+=
a.age?a.age:this.defaultData.age;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.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.contact);if(!1===b)return!1;this.container.innerHTML+=ficheBuilder.build({firstname:b.firstname, ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,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="'+
lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,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="'+ 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");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][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");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');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="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="'+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"]');
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< 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="'+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="context"]');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="'+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="context"]');for(b=0;b<c.length&& 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 e=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<e.length&&b<a.freq[c].length;b++)a.freq[c][b].status?e[b].setAttribute("checked","checked"):e[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(e=$$('article.fiche-relation input[data-name="uid"][value="'+
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 e=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<e.length&&b<a.freq[c].length;b++)a.freq[c][b].status?e[b].setAttribute("checked","checked"):e[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(e=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+ a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<e.length&&b<a.connect[c].length;b++)a.connect[c][b].status?e[b].setAttribute("checked","checked"):e[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<e.length&&b<a.connect[c].length;b++)a.connect[c][b].status?e[b].setAttribute("checked","checked"):e[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()}; inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=parseInt(c);lsi.set("fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("fiches",e,d))}if(20>b.length)for(c in a){for(a=0;-1<b.indexOf(a)&&20>a;)a++;b.push(a);d=lsi.get("fiches",
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=c;lsi.set("fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=c,lsi.set("fiches",e,d))}if(20>b.length)for(c in a){for(a=0;-1<b.indexOf(a)&&20>a;)a++;b.push(a);d=lsi.get("fiches",a);null==d&&(d=this.defaultData); a);null==d&&(d=this.defaultData);d.uid=a;d.contact=c;lsi.set("fiches",a,d);if(20<=b.length)break}var d=lsi["export"]("fiches"),f;for(f in d)miniData=lsi.get("mini-fiches",d[f].contact),d[f].timestamp>=miniData.timestamp?(miniData.sexe=d[f].sexe,miniData.age=d[f].age,miniData.studies=d[f].studies,miniData.loc=d[f].loc,miniData.reltype=d[f].reltype,miniData.reltypeSpecial=d[f].reltypeSpecial):(d[f].sexe=miniData.sexe,d[f].age=miniData.age,d[f].studies=miniData.studies,d[f].loc=miniData.loc,d[f].reltype=
d.uid=a;d.contact=c;lsi.set("fiches",a,d);if(20<=b.length)break}var d=lsi["export"]("fiches"),f;for(f in d)miniData=lsi.get("mini-fiches",d[f].contact),d[f].timestamp>=miniData.timestamp?(miniData.sexe=d[f].sexe,miniData.age=d[f].age,miniData.studies=d[f].studies,miniData.loc=d[f].loc,miniData.reltype=d[f].reltype,miniData.reltypeSpecial=d[f].reltypeSpecial):(d[f].sexe=miniData.sexe,d[f].age=miniData.age,d[f].studies=miniData.studies,d[f].loc=miniData.loc,d[f].reltype=miniData.reltype,d[f].reltypeSpecial= miniData.reltype,d[f].reltypeSpecial=miniData.reltypeSpecial),lsi.set("mini-fiches",d[f].contact,miniData),lsi.set("fiches",f,d[f]);for(f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))};
miniData.reltypeSpecial),lsi.set("mini-fiches",d[f].contact,miniData),lsi.set("fiches",f,d[f]);for(f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))};
inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"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.getData("n"))}; inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"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.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=lsi.keys("fiches").length;if($$("#nav-fiche [data-n]").length!=b){this.nav_container.innerHTML="<span>APPELS</span>";for(var c=0;c<b;c++)9==c?this.nav_container.innerHTML+='<span data-n="'+c+'" class="lc">'+(c%10+1)+"</span>&nbsp;&nbsp;":(10==c&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c%10+1)+"</span>")}for(var e in a)b=$('#nav-fiche [data-n="'+ inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=lsi.keys("fiches").length;if($$("#nav-fiche [data-n]").length!=b){this.nav_container.innerHTML="<span>APPELS</span>";for(var c=0;c<b;c++)9==c?this.nav_container.innerHTML+='<span data-n="'+c+'" class="lc">'+(c%10+1)+"</span>&nbsp;&nbsp;":(10==c&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c%10+1)+"</span>")}for(var e in a)b=$('#nav-fiche [data-n="'+
a[e].uid+'"]'),!0===a[e].valid?b.addClass("done"):b.remClass("done");this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))}; a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))};
inputPhoneFiche.prototype.check=function(a){if(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||"."==a.age||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!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; inputPhoneFiche.prototype.check=function(a){if(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||"."==a.age||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!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};inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!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};inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};

View File

@ -13,34 +13,34 @@ 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
sexe: [ {status:true}, {status:false}], sexe: [ defTrue, defFalse],
age: '.', age: '.',
job: '.', job: '.',
famsit: [ {status:true}, {status:false}, {status:false} ], // Choix 1 à 3 famsit: [ defTrue, defFalse, defFalse ], // Choix 1 à 3
studies: '.', studies: '.',
reltype: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false}, reltype: [ defTrue, defFalse, defFalse, defFalse, defFalse,
{status:false}, {status:false}, {status:false}, {status:false}], // Choix 1 à 9 defFalse, defFalse, defFalse, defFalse], // Choix 1 à 9
reltypeSpecial: '', reltypeSpecial: '',
city: '', city: '',
loc: [ {status:true}, {status:false}, {status:false}, {status:false} ], loc: [ defTrue, defFalse, defFalse, defFalse ],
duration: ['', ''], duration: ['', ''],
context: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false}, context: [ defTrue, defFalse, defFalse, defFalse, defFalse,
{status:false}, {status:false}, {status:false}, {status:false}, {status:false}, defFalse, defFalse, defFalse, defFalse, defFalse,
{status:false}, {status:false}, {status:false}, {status:false}], // Choix 1 à 14 defFalse, defFalse, defFalse, defFalse], // Choix 1 à 14
contextSpecial: ['', '', ''], contextSpecial: ['', '', ''],
freq: [ freq: [
[ {status:true}, {status:false}, {status:false}, {status:false} ], [ defTrue, defFalse, defFalse, defFalse ],
[ {status:true}, {status:false}, {status:false}, {status:false} ], [ defTrue, defFalse, defFalse, defFalse ],
[ {status:true}, {status:false}, {status:false}, {status:false} ], [ defTrue, defFalse, defFalse, defFalse ],
[ {status:true}, {status:false}, {status:false}, {status:false} ], [ defTrue, defFalse, defFalse, defFalse ],
[ {status:true}, {status:false}, {status:false}, {status:false} ]], [ defTrue, defFalse, defFalse, defFalse ]],
connect: [ connect: [
[ {status:false}, {status:true} ], [ defFalse, defTrue ],
[ {status:false}, {status:true} ], [ defFalse, defTrue ],
[ {status:false}, {status:true} ], [ defFalse, defTrue ],
[ {status:false}, {status:true} ], [ defFalse, defTrue ],
[ {status:false}, {status:true} ], [ defFalse, defTrue ],
[ {status:false}, {status:true} ]], [ defFalse, defTrue ]],
connectSpecial: ['', ''], connectSpecial: ['', ''],
timestamp: 0, timestamp: 0,
valid: false valid: false
@ -82,12 +82,10 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
if( existingData.hash != null && existingData.hash == deflatedHash ) if( existingData.hash != null && existingData.hash == deflatedHash )
return; return;
console.warn('> FICHE UPDATE');
var obj = { var obj = {
contact: deflated.contact.value, contact: parseInt(deflated.contact.value),
uid: deflated.uid.value, uid: parseInt(deflated.uid.value),
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,
@ -131,8 +129,13 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
/* (6) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ /* (6) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */
obj.valid = this.check(obj); obj.valid = this.check(obj);
obj.timestamp = Date.now();
// On met à jour la date de modification, si on a pas qu'@uid de différent
if( diff(existingData, obj).length > 0 ){
console.warn('> FICHE UPDATE');
obj.timestamp = Date.now();
}
/* (7) On enregistre les données dans le 'localStorage' */ /* (7) On enregistre les données dans le 'localStorage' */
lsi.set('fiches', obj.uid, obj); lsi.set('fiches', obj.uid, obj);
@ -360,7 +363,7 @@ inputPhoneFiche.prototype.sync = function(){
// On met à jour la fiche ET on l'enregistre // On met à jour la fiche ET on l'enregistre
ficheData.uid = ficheIndex; ficheData.uid = ficheIndex;
ficheData.contact = uid; ficheData.contact = parseInt(uid);
lsi.set('fiches', ficheIndex, ficheData); lsi.set('fiches', ficheIndex, ficheData);
} }
@ -380,7 +383,7 @@ inputPhoneFiche.prototype.sync = function(){
// On met à jour la fiche ET on l'enregistre // On met à jour la fiche ET on l'enregistre
ficheData.uid = ficheIndex; ficheData.uid = ficheIndex;
ficheData.contact = uid; ficheData.contact = parseInt(uid);
lsi.set('fiches', ficheIndex, ficheData); lsi.set('fiches', ficheIndex, ficheData);
@ -568,6 +571,8 @@ inputPhoneFiche.prototype.updateNavBar = function(){
var currentElement = $('#nav-fiche [data-n="'+ficheData[key].uid+'"]'); var currentElement = $('#nav-fiche [data-n="'+ficheData[key].uid+'"]');
if( currentElement == null )
continue;
// Si on ne trouve pas le bouton // Si on ne trouve pas le bouton

View File

@ -1,10 +1,10 @@
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:".",studies:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}],reltype:[{status:!0},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],reltypeSpecial:"",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:[defTrue,defFalse],age:".",studies:".",loc:[defTrue,defFalse,defFalse,defFalse],reltype:[defTrue,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse,defFalse],reltypeSpecial:"",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);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value, 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);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:parseInt(c.uid.value),firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,
studies:c.studies.value,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,loc:c.loc,hash:e};c.valid=this.check(c);c.timestamp=Date.now();lsi.set("mini-fiches",c.uid,c)}}}; studies:c.studies.value,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,loc:c.loc,hash:e};c.valid=this.check(c);0<diff(d,c).length&&(console.warn("> FICHE UPDATE"),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.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;var b=lsi.get("contacts",a.uid);if(!1===b)return!1; 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.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;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+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('article.mini-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");b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+ this.container.innerHTML+=miniFicheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('article.mini-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");b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+
a.age+'"]');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="'+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", a.age+'"]');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="'+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.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")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);this.container.innerHTML="";this.add(a);this.updateNavBar()}; "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")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);this.container.innerHTML="";this.add(a);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(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"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.getData("n"))}; 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(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"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.getData("n"))};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if($$("#nav-mini [data-n]").length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c+1)+"</span>"}for(var e in a)b=$('#nav-mini [data-n="'+a[e].uid+'"]'),!0===a[e].valid?b.addClass("done"):b.remClass("done");this.nav($('#nav-mini [data-n="'+this.selected+'"]'))}; inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if($$("#nav-mini [data-n]").length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c+1)+"</span>"}for(var e in a)b=$('#nav-mini [data-n="'+a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))};
inputPhoneMini.prototype.check=function(a){return!checkRadioValue(a.sexe)||"."==a.studies||"."==a.age||!checkRadioValue(a.loc)||!checkRadioValue(a.reltype)||a.reltype[8].status&&2>a.reltypeSpecial.length?!1:!0};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!checkRadioValue(a.sexe)||"."==a.studies||"."==a.age||!checkRadioValue(a.loc)||!checkRadioValue(a.reltype)||a.reltype[8].status&&2>a.reltypeSpecial.length?!1:!0};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,12 +13,12 @@ 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
sexe: [{status:true}, {status:false}], sexe: [defTrue, defFalse],
age: '.', age: '.',
studies: '.', studies: '.',
loc: [{status:true}, {status:false}, {status:false}, {status:false}], loc: [defTrue, defFalse, defFalse, defFalse],
reltype: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false}, reltype: [ defTrue, defFalse, defFalse, defFalse, defFalse,
{status:false}, {status:false}, {status:false}, {status:false}], // Choix 1 à 9 defFalse, defFalse, defFalse, defFalse], // Choix 1 à 9
reltypeSpecial: '', reltypeSpecial: '',
timestamp: 0, timestamp: 0,
valid: false valid: false
@ -63,7 +63,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
var obj = { var obj = {
uid: deflated.uid.value, uid: parseInt(deflated.uid.value),
firstname: existingData.firstname, firstname: existingData.firstname,
lastname: existingData.lastname, lastname: existingData.lastname,
username: existingData.username, username: existingData.username,
@ -78,7 +78,12 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
/* (8) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */ /* (8) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */
obj.valid = this.check(obj); obj.valid = this.check(obj);
obj.timestamp = Date.now();
// On met à jour la date de modification, si on a pas qu'@uid de différent
if( diff(existingData, obj).length > 0 ){
console.warn('> FICHE UPDATE');
obj.timestamp = Date.now();
}
/* (9) On enregistre les données dans le 'localStorage' */ /* (9) On enregistre les données dans le 'localStorage' */
@ -294,6 +299,9 @@ inputPhoneMini.prototype.updateNavBar = function(){
var currentElement = $('#nav-mini [data-n="'+miniData[key].uid+'"]'); var currentElement = $('#nav-mini [data-n="'+miniData[key].uid+'"]');
if( currentElement == null )
continue;
// On remplit avec le numéro de la MINI fiche // On remplit avec le numéro de la MINI fiche
// currentElement.setAttribute('data-n', miniData[key].uid); // currentElement.setAttribute('data-n', miniData[key].uid);
// currentElement.innerHTML = miniData[key].uid + 1; // currentElement.innerHTML = miniData[key].uid + 1;

2
js/lib/reset-min.js vendored
View File

@ -1,4 +1,4 @@
function $(a){return document.querySelector(a)}function $$(a){return document.querySelectorAll(a)}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())}; function $(a){return document.querySelector(a)}function $$(a){return document.querySelectorAll(a)}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())};
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var _includes=[],_includeTags=[]; Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var _includes=[],_includeTags=[];
function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(null==a)return!1;if("boolean"===typeof c&&c){b=_includes.indexOf(a);if(-1==b)return!1;document.head.removeChild(_includeTags[b]);_includes.splice(b,1);_includeTags.splice(b,1)}else{if(-1<_includes.indexOf(a))return b(),!0;c=document.createElement("script");c.type="text/javascript";c.src=a;document.head.appendChild(c);_includes.push(a);_includeTags.push(c);c.onload=b}return!0} function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(null==a)return!1;if("boolean"===typeof c&&c){b=_includes.indexOf(a);if(-1==b)return!1;document.head.removeChild(_includeTags[b]);_includes.splice(b,1);_includeTags.splice(b,1)}else{if(-1<_includes.indexOf(a))return b(),!0;c=document.createElement("script");c.type="text/javascript";c.src=a;document.head.appendChild(c);_includes.push(a);_includeTags.push(c);c.onload=b}return!0}
var format_number=new formatChecker(null,"0i ii ii ii ii"); function diff(a,b){var c=[],d;for(d in a)null!=b[d]&&null!=a[d]&&(typeof a[d]!==typeof b[d]?c.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&c.push(d):a[d]!=b[d]&&c.push(d));return c}var format_number=new formatChecker(null,"0i ii ii ii ii");

View File

@ -148,6 +148,44 @@ function include(jsResource, callback, action){ // action=true -> EXCLUSION, SIN
/* RETOURNE LES CLÉS N'AYANT PAS UNE VALEUR EGALE POUR 2 OBJETS
*
* @A<Object> Premier Objet
* @B<Object> Second Objet
*
* @return diff<Array> Tableau contenant les clés des valeurs différentes (uniquement les clés communes et non NULLes)
*
*/
function diff(A, B){
var dKeys = [];
for( var key in A ){
// Si A[key] ou B[key] est NULL, on ne compare pas
if( B[key] == null || A[key] == null )
continue;
/* (1) On vérifie le type */
if( typeof A[key] !== typeof B[key] )
dKeys.push(key);
/* (2) Vérification récursive si 2 objets */
else if( A[key] instanceof Object && B[key] instanceof Object ){
// Si au moins 1 différence profonde (récursive), on ajoute la clé
if( diff(A[key], B[key]).length > 0 )
dKeys.push(key);
/* (3) Vérification superficielle (types non composés) */
}else if( A[key] != B[key] )
dKeys.push(key);
}
return dKeys;
}
/* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER /* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER
* *

View File

@ -1,4 +1,4 @@
var clearAllButton=$("#clear-all"),submitAllButton=$("#submit-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager; var clearAllButton=$("#clear-all"),submitAllButton=$("#submit-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager,defTrue={status:!0,value:"on"},defFalse={status:!1,value:"on"};
function dynamicUpdate(a){var b=a instanceof Element,e=b&&"SPAN"==a.tagName&&"switch-left"==a.className,f=b&&"SPAN"==a.tagName&&"switch-both"==a.className,c=b&&"INPUT"==a.tagName&&"submit"==a.type,d=b&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(f||e||c||d||b)&&!0!==a)return!1;if(f)console.log("> switch firstname <-> lastname"),e=a.parentNode,a=e.children[8],e=e.children[10],f=a.value,a.value=e.value,e.value= function dynamicUpdate(a){var b=a instanceof Element,e=b&&"SPAN"==a.tagName&&"switch-left"==a.className,f=b&&"SPAN"==a.tagName&&"switch-both"==a.className,c=b&&"INPUT"==a.tagName&&"submit"==a.type,d=b&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(f||e||c||d||b)&&!0!==a)return!1;if(f)console.log("> switch firstname <-> lastname"),e=a.parentNode,a=e.children[8],e=e.children[10],f=a.value,a.value=e.value,e.value=
f;else if(e){console.log("> switch firstname+lastname -> username");e=a.parentNode;f=e.children[6];a=e.children[8];e=e.children[10];if(0<f.value.length||0==a.value.length&&0==e.value.length)return!1;f.value=a.value+" "+e.value;a.value="";e.value=""}else console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),(c||b)&&contactManager.storageToFields()} f;else if(e){console.log("> switch firstname+lastname -> username");e=a.parentNode;f=e.children[6];a=e.children[8];e=e.children[10];if(0<f.value.length||0==a.value.length&&0==e.value.length)return!1;f.value=a.value+" "+e.value;a.value="";e.value=""}else console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),(c||b)&&contactManager.storageToFields()}
function checkRadioValue(a){for(var b=0,e=0;e<a.length;e++)!0===a[e].status&&b++;return 1!=b?!1:!0} function checkRadioValue(a){for(var b=0,e=0;e<a.length;e++)!0===a[e].status&&b++;return 1!=b?!1:!0}

View File

@ -23,6 +23,11 @@ var contactManager;
var miniManager; var miniManager;
var ficheManager; var ficheManager;
// CONSTANTES
var defTrue = {status: true, value: 'on'};
var defFalse = {status: false, value: 'on'};
/* (4) Fonctions utiles */ /* (4) Fonctions utiles */
function dynamicUpdate(target){ function dynamicUpdate(target){