Gestion du debug pour régler le pb de timestamp pas bien mis à jour

This commit is contained in:
xdrm-brackets 2016-10-20 14:21:46 +02:00
parent 8e40423228
commit 0d38d1c684
6 changed files with 68 additions and 42 deletions

View File

@ -61,6 +61,7 @@ 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('p_fiches', deflated.uid); var existingData = lsi.get('p_fiches', deflated.uid);
// Si n'existe pas, on passe au suivant // Si n'existe pas, on passe au suivant
if( existingData === false ) if( existingData === false )
continue; continue;
@ -68,7 +69,10 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
// {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 //
// Si le hash est le même, on ne fait rien // Si le hash est le même, on ne fait rien
if( existingData.hash != null && existingData.hash == deflatedHash || existingData.hash === 0 ) if( existingData != null && existingData.hash != null )
if( existingData.hash === 0 )
console.log('FICHE#'+existingData.uid+' UPDATED BUT NO TIMESTAMP UPDATE');
else if( existingData.hash == deflatedHash )
return; return;
@ -100,18 +104,29 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
obj.valid = this.check(obj); obj.valid = this.check(obj);
// On met à jour la date de modification, si on a pas qu'@uid de différent // On met à jour la date de modification, si on a pas qu'@uid de différent
// {6.1} Si on doit mettre à jour //
if( existingData.hash !== 0 ){
// Si on a des modifications, on met à jour le `timestamp` //
if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){
console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) );
obj.timestamp = Date.now(); obj.timestamp = Date.now();
console.warn('> FICHE UPDATE ('+(obj.timestamp-input_ts)+')'); console.warn('> FICHE UPDATE ('+(obj.timestamp-input_ts)+')');
}else if( existingData['timestamp'] == undefined ){
console.warn('fiche#'+obj.uid);
obj.timestamp = Date.now();
} }
if( existingData['timestamp'] == undefined || !isNaN(existingData.timestamp) )
obj.timestamp = Date.now();
// {6.2} Initialisation du `timestamp` si pas encore fait //
}else if( existingData['timestamp'] == undefined || !isNaN(existingData.timestamp) )
obj.timestamp = 0;
/* (7) On enregistre les données dans le 'localStorage' */ /* (7) On enregistre les données dans le 'localStorage' */
console.warn('saving fiche#'+obj.uid+' with timestamp of '+obj.timestam+' and hash of '+existingData.hash+' and now '+obj.hash);
lsi.set('p_fiches', obj.uid, obj); lsi.set('p_fiches', obj.uid, obj);
} }
@ -482,9 +497,8 @@ inputPhoneFiche.prototype.sync = function(){
if( clone[i][0] == clone[last_index][0] ){ if( clone[i][0] == clone[last_index][0] ){
console.warn('copying fiche#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); console.warn('copying fiche#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts);
copied = clone[last_index][1]; copied = cloneObject( clone[last_index][1] );
copied.uid = clone[i][1].uid; copied.uid = clone[i][1].uid;
// copied.timestamp = Date.now();
copied.hash = 0 copied.hash = 0
lsi.set('p_fiches', copied.uid, copied); lsi.set('p_fiches', copied.uid, copied);
@ -492,26 +506,25 @@ inputPhoneFiche.prototype.sync = function(){
}else if( clone[last_index][0] == 'fiche' ){ }else if( clone[last_index][0] == 'fiche' ){
console.warn('copying fiche#'+clone[last_index][1].uid+' to mini#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); console.warn('copying fiche#'+clone[last_index][1].uid+' to mini#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts);
copied = clone[i][1]; copied = cloneObject( clone[i][1] );
copied.age = clone[last_index][1].age; copied.age = clone[last_index][1].age;
copied.sexe = clone[last_index][1].sexe; copied.sexe = clone[last_index][1].sexe;
copied.loc = clone[last_index][1].loc; copied.loc = clone[last_index][1].loc;
copied.reltype = clone[last_index][1].reltype; copied.reltype = clone[last_index][1].reltype;
copied.reltypeSpecial = clone[last_index][1].reltypeSpecial; copied.reltypeSpecial = clone[last_index][1].reltypeSpecial;
copied.timestamp = Date.now(); copied.hash = 0;
lsi.set('p_mini-fiches', copied.uid, copied); lsi.set('p_mini-fiches', copied.uid, copied);
/* (5.3) mini vers fiche */ /* (5.3) mini vers fiche */
}else{ }else{
console.warn('copying mini#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); console.warn('copying mini#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts);
copied = clone[i][1]; copied = cloneObject( clone[i][1] );
copied.age = clone[last_index][1].age; copied.age = clone[last_index][1].age;
copied.sexe = clone[last_index][1].sexe; copied.sexe = clone[last_index][1].sexe;
copied.loc = clone[last_index][1].loc; copied.loc = clone[last_index][1].loc;
copied.reltype = clone[last_index][1].reltype; copied.reltype = clone[last_index][1].reltype;
copied.reltypeSpecial = clone[last_index][1].reltypeSpecial; copied.reltypeSpecial = clone[last_index][1].reltypeSpecial;
// copied.timestamp = Date.now();
copied.hash = 0; copied.hash = 0;
lsi.set('p_fiches', copied.uid, copied); lsi.set('p_fiches', copied.uid, copied);

View File

@ -44,7 +44,6 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
var deflatedHash = crc32(JSON.stringify(deflated)); var deflatedHash = crc32(JSON.stringify(deflated));
// console.log(deflated);
// {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 //
@ -54,10 +53,12 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
if( existingData === false ) if( existingData === false )
continue; continue;
// {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 //
// Si le hash est le même, on ne fait rien // Si le hash est le même, on ne fait rien
if( existingData != null && existingData.hash != null && existingData.hash == deflatedHash ) if( existingData != null && existingData.hash != null )
if( existingData.hash === 0 )
console.log('MINI#'+existingData.uid+' UPDATED BUT NO TIMESTAMP UPDATE');
else if( existingData.hash == deflatedHash )
return; return;
@ -78,17 +79,28 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
obj.valid = this.check(obj); obj.valid = this.check(obj);
// On met à jour la date de modification, si on a pas qu'@uid de différent // On met à jour la date de modification, si on a pas qu'@uid de différent
// {8.1} Si on doit mettre à jour //
if( existingData.hash !== 0 ){
// Si on a des modifications, on met à jour le `timestamp` //
if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){
console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) );
obj.timestamp = Date.now(); obj.timestamp = Date.now();
console.warn('> MINI UPDATE ('+(obj.timestamp-input_ts)+')'); console.warn('> MINI UPDATE ('+(obj.timestamp-input_ts)+')');
}else if( existingData['timestamp'] == undefined ) }
if( existingData['timestamp'] == undefined || !isNaN(existingData.timestamp) )
obj.timestamp = Date.now(); obj.timestamp = Date.now();
// {6.2} Initialisation du `timestamp` si pas encore fait //
}else if( existingData['timestamp'] == undefined || !isNaN(existingData.timestamp) )
obj.timestamp = 0;
/* (9) On enregistre les données dans le 'localStorage' */ /* (9) On enregistre les données dans le 'localStorage' */
console.warn('saving mini#'+obj.uid+' with timestamp of '+obj.timestam+' and hash of '+existingData.hash+' and now '+obj.hash);
lsi.set('p_mini-fiches', obj.uid, obj); lsi.set('p_mini-fiches', obj.uid, obj);
} }

View File

@ -1,7 +1,7 @@
function inputPhoneFiche(a,c){this.container=a;this.nav_container=c;this.top_size=10}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}}; function inputPhoneFiche(a,c){this.container=a;this.nav_container=c;this.top_size=10}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");for(var a=$$('[data-sublink="phone"] article.relation-panel .fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),g=crc32(JSON.stringify(b)),h=lsi.get("p_fiches",b.uid);if(!1!==h){if(null!=h.hash&&h.hash==g||0===h.hash)return;b={contact:parseInt(b.contact),uid:parseInt(b.uid),sexe:b.sexe,age:b.age,job:b.job,famsit:b.famsit,studies:b.studies, inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");for(var a=$$('[data-sublink="phone"] article.relation-panel .fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),h=crc32(JSON.stringify(b)),g=lsi.get("p_fiches",b.uid);if(!1!==g){if(null!=g&&null!=g.hash)if(0===g.hash)console.log("FICHE#"+g.uid+" UPDATED BUT NO TIMESTAMP UPDATE");else if(g.hash==h)return;b={contact:parseInt(b.contact),uid:parseInt(b.uid),
reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,city:b.city,quartier:b.quartier,cp:b.cp,loc:b.loc,duration:b.duration,context:b.context,contextSpecial:b.contextSpecial,freq:b.freq,connect:b.connect,connectSpecial:b.connectSpecial,hash:g};b.valid=this.check(b);0<diff(h,b,["hash","valid","timestamp"]).length?(console.log(diff(h,b,["hash","valid","timestamp"])),b.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(b.timestamp-input_ts)+")")):void 0==h.timestamp&&(console.warn("fiche#"+b.uid),b.timestamp= sexe:b.sexe,age:b.age,job:b.job,famsit:b.famsit,studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,city:b.city,quartier:b.quartier,cp:b.cp,loc:b.loc,duration:b.duration,context:b.context,contextSpecial:b.contextSpecial,freq:b.freq,connect:b.connect,connectSpecial:b.connectSpecial,hash:h};b.valid=this.check(b);0!==g.hash?(0<diff(g,b,["hash","valid","timestamp"]).length&&(console.log(diff(g,b,["hash","valid","timestamp"])),b.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(b.timestamp-
Date.now());lsi.set("p_fiches",b.uid,b)}}console.groupEnd()}; input_ts)+")")),void 0!=g.timestamp&&isNaN(g.timestamp)||(b.timestamp=Date.now())):void 0!=g.timestamp&&isNaN(g.timestamp)||(b.timestamp=0);console.warn("saving fiche#"+b.uid+" with timestamp of "+b.timestam+" and hash of "+g.hash+" and now "+b.hash);lsi.set("p_fiches",b.uid,b)}}console.groupEnd()};
inputPhoneFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;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; inputPhoneFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;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]=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.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.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?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: 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?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:
@ -13,12 +13,12 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(c=0;c<b.length;c++)
a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c].value==a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(c=0;c<b.length;c++)b[c].value==a.context?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+ a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c].value==a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(c=0;c<b.length;c++)b[c].value==a.context?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")}; a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar();console.groupEnd()}; inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,g=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,h;for(h in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<g;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(h);lsi.set("p_fiches",ficheUid,a);if(c.length>=g)break}var d,e,k,g={};h={};var a=lsi["export"]("p_fiches"), inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,h=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,g;for(g in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<h;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(g);lsi.set("p_fiches",ficheUid,a);if(c.length>=h)break}var d,e,k,h={};g={};var a=lsi["export"]("p_fiches"),
c=lsi["export"]("p_mini-fiches"),l;for(l in a)if(d=lsi.get("p_contacts",a[l].contact),!(0<d.username.length&&void 0!=g[d.username]||0==d.username.length&&void 0!=h[d.existing])&&(0<d.username.length?g[d.username]=0:h[d.existing]=0,d)){var f=[["fiche",a[l]]];for(b in a)e=lsi.get("p_contacts",a[b].contact),b!=l&&e&&(k=0<e.username.length&&d.username===e.username,e=!isNaN(e.existing)&&d.existing===e.existing,(k||e)&&f.push(["fiche",a[b]]));for(b in c)e=lsi.get("p_contacts",c[b].contact),k=0<e.username.length&& c=lsi["export"]("p_mini-fiches"),l;for(l in a)if(d=lsi.get("p_contacts",a[l].contact),!(0<d.username.length&&void 0!=h[d.username]||0==d.username.length&&void 0!=g[d.existing])&&(0<d.username.length?h[d.username]=0:g[d.existing]=0,d)){var f=[["fiche",a[l]]];for(b in a)e=lsi.get("p_contacts",a[b].contact),b!=l&&e&&(k=0<e.username.length&&d.username===e.username,e=!isNaN(e.existing)&&d.existing===e.existing,(k||e)&&f.push(["fiche",a[b]]));for(b in c)e=lsi.get("p_contacts",c[b].contact),k=0<e.username.length&&
d.username===e.username,e=!isNaN(e.existing)&&d.existing===e.existing,(k||e)&&f.push(["mini",c[b]]);if(1!==f.length){k=[];for(b in f)k[b]=f[b][1].hasOwnProperty("timestamp")?f[b][1].timestamp:0;e=k.indexOf(Math.max.apply(Math,k));for(b in f)b!=e&&(f[b][0]==f[e][0]?(console.warn("copying fiche#"+f[e][1].uid+" to fiche#"+f[b][1].uid,k[e]-input_ts,k[b]-input_ts),d=f[e][1],d.uid=f[b][1].uid,d.hash=0,lsi.set("p_fiches",d.uid,d)):"fiche"==f[e][0]?(console.warn("copying fiche#"+f[e][1].uid+" to mini#"+f[b][1].uid, d.username===e.username,e=!isNaN(e.existing)&&d.existing===e.existing,(k||e)&&f.push(["mini",c[b]]);if(1!==f.length){k=[];for(b in f)k[b]=f[b][1].hasOwnProperty("timestamp")?f[b][1].timestamp:0;e=k.indexOf(Math.max.apply(Math,k));for(b in f)b!=e&&(f[b][0]==f[e][0]?(console.warn("copying fiche#"+f[e][1].uid+" to fiche#"+f[b][1].uid,k[e]-input_ts,k[b]-input_ts),d=cloneObject(f[e][1]),d.uid=f[b][1].uid,d.hash=0,lsi.set("p_fiches",d.uid,d)):"fiche"==f[e][0]?(console.warn("copying fiche#"+f[e][1].uid+
k[e]-input_ts,k[b]-input_ts),d=f[b][1],d.age=f[e][1].age,d.sexe=f[e][1].sexe,d.loc=f[e][1].loc,d.reltype=f[e][1].reltype,d.reltypeSpecial=f[e][1].reltypeSpecial,d.timestamp=Date.now(),lsi.set("p_mini-fiches",d.uid,d)):(console.warn("copying mini#"+f[e][1].uid+" to fiche#"+f[b][1].uid,k[e]-input_ts,k[b]-input_ts),d=f[b][1],d.age=f[e][1].age,d.sexe=f[e][1].sexe,d.loc=f[e][1].loc,d.reltype=f[e][1].reltype,d.reltypeSpecial=f[e][1].reltypeSpecial,d.hash=0,lsi.set("p_fiches",d.uid,d)))}}console.groupEnd()}; " to mini#"+f[b][1].uid,k[e]-input_ts,k[b]-input_ts),d=cloneObject(f[b][1]),d.age=f[e][1].age,d.sexe=f[e][1].sexe,d.loc=f[e][1].loc,d.reltype=f[e][1].reltype,d.reltypeSpecial=f[e][1].reltypeSpecial,d.hash=0,lsi.set("p_mini-fiches",d.uid,d)):(console.warn("copying mini#"+f[e][1].uid+" to fiche#"+f[b][1].uid,k[e]-input_ts,k[b]-input_ts),d=cloneObject(f[b][1]),d.age=f[e][1].age,d.sexe=f[e][1].sexe,d.loc=f[e][1].loc,d.reltype=f[e][1].reltype,d.reltypeSpecial=f[e][1].reltypeSpecial,d.hash=0,lsi.set("p_fiches",
inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))}; d.uid,d)))}}console.groupEnd()};inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var g=parseInt(c[b]);0==g&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>g&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+g+'" class="lc">'+(g%20+1)+"</span>&nbsp;&nbsp;":(20==g&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+ inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var h=parseInt(c[b]);0==h&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>h&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+h+'" class="lc">'+(h%20+1)+"</span>&nbsp;&nbsp;":(20==h&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
g+'">'+(g%20+1)+"</span>")}for(var h in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[h].uid+'"]'),null!=c&&(!0===a[h].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; h+'">'+(h%20+1)+"</span>")}for(var g in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[g].uid+'"]'),null!=c&&(!0===a[g].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_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||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var c=0;c<a.freq.length;c++)if(""==a.freq[c])return!1;for(c=0;c<a.connect.length;c++)if(""==a.connect[c])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length|| 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||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var c=0;c<a.freq.length;c++)if(""==a.freq[c])return!1;for(c=0;c<a.connect.length;c++)if(""==a.connect[c])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||
"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.group("[phone.fiche] attaching events");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()}; "11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.group("[phone.fiche] attaching events");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()};

View File

@ -1,6 +1,7 @@
function inputPhoneMini(a,c){this.container=a;this.nav_container=c}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,timestamp:0,valid:!1}}; function inputPhoneMini(a,c){this.container=a;this.nav_container=c}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,timestamp:0,valid:!1}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.group("[phone.mini] fields to storage");for(var a=$$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("p_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;b={uid:parseInt(b.uid),contact:parseInt(b.uid),sexe:b.sexe,age:b.age,studies:b.studies,reltype:b.reltype, inputPhoneMini.prototype.fieldsToStorage=function(){console.group("[phone.mini] fields to storage");for(var a=$$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("p_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash)if(0===d.hash)console.log("MINI#"+d.uid+" UPDATED BUT NO TIMESTAMP UPDATE");else if(d.hash==e)return;b={uid:parseInt(b.uid),
reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length?(console.log(diff(d,b,["hash","valid","timestamp"])),b.timestamp=Date.now(),console.warn("> MINI UPDATE ("+(b.timestamp-input_ts)+")")):void 0==d.timestamp&&(b.timestamp=Date.now());lsi.set("p_mini-fiches",b.uid,b)}}console.groupEnd()}; contact:parseInt(b.uid),sexe:b.sexe,age:b.age,studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0!==d.hash?(0<diff(d,b,["hash","valid","timestamp"]).length&&(console.log(diff(d,b,["hash","valid","timestamp"])),b.timestamp=Date.now(),console.warn("> MINI UPDATE ("+(b.timestamp-input_ts)+")")),void 0!=d.timestamp&&isNaN(d.timestamp)||(b.timestamp=Date.now())):void 0!=d.timestamp&&isNaN(d.timestamp)||(b.timestamp=0);console.warn("saving mini#"+
b.uid+" with timestamp of "+b.timestam+" and hash of "+d.hash+" and now "+b.hash);lsi.set("p_mini-fiches",b.uid,b)}}console.groupEnd()};
inputPhoneMini.prototype.add=function(a){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;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown;var c=lsi.get("p_contacts", inputPhoneMini.prototype.add=function(a){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;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown;var c=lsi.get("p_contacts",
a.uid);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("p_friends",c.existing);c.username=b.name;a.contact=c.uid;a.age=b.age;a.sexe=b.sexe;a.loc=b.dist;isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial="");null!=b.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=pMiniFicheBuilder.build({name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+ a.uid);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("p_friends",c.existing);c.username=b.name;a.contact=c.uid;a.age=b.age;a.sexe=b.sexe;a.loc=b.dist;isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial="");null!=b.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=pMiniFicheBuilder.build({name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=c&&c.setAttribute("selected","selected");b=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(c=0;c<b.length;c++)b[c].value== a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=c&&c.setAttribute("selected","selected");b=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(c=0;c<b.length;c++)b[c].value==

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=[],_includeLoad=[]; 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=[],_includeLoad=[];
function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(!a)return!1;if("boolean"===typeof c&&c){c=_includes.indexOf(a);if(-1==c)return!1;document.head.removeChild(_includeTags[c]);_includes.splice(c,1);_includeTags.splice(c,1)}else{c=_includes.indexOf(a);if(-1<c)return b(),!0;var e=document.createElement("script");c=_includes.length;_includes[c]=a;_includeLoad[c]=!1;_includeTags[c]=e;e.onload=function(a){return function(){_includeLoad[a]= function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(!a)return!1;if("boolean"===typeof c&&c){c=_includes.indexOf(a);if(-1==c)return!1;document.head.removeChild(_includeTags[c]);_includes.splice(c,1);_includeTags.splice(c,1)}else{c=_includes.indexOf(a);if(-1<c)return b(),!0;var e=document.createElement("script");c=_includes.length;_includes[c]=a;_includeLoad[c]=!1;_includeTags[c]=e;e.onload=function(a){return function(){_includeLoad[a]=
!0;b()}}(c);e.setAttribute("src",a);e.setAttribute("type","text/javascript");document.head.appendChild(e)}return!0}function diff(a,b,c){var e=[],d;for(d in a)null==b[d]||null==a[d]||c instanceof Array&&-1<c.indexOf(d)||(typeof a[d]!==typeof b[d]?e.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&e.push(d):a[d]!=b[d]&&e.push(d));return e}var format_number=new formatChecker(null,"0i ii ii ii ii"); !0;b()}}(c);e.setAttribute("src",a);e.setAttribute("type","text/javascript");document.head.appendChild(e)}return!0}function diff(a,b,c){var e=[],d;for(d in a)null==b[d]||null==a[d]||c instanceof Array&&-1<c.indexOf(d)||(typeof a[d]!==typeof b[d]?e.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&e.push(d):a[d]!=b[d]&&e.push(d));return e}cloneObject=function(a){return JSON.parse(JSON.stringify(a))};var format_number=new formatChecker(null,"0i ii ii ii ii");

View File

@ -221,9 +221,9 @@ function diff(A, B, ignore){
* Note: prise en compte des primitifs && tableaux uniquement * Note: prise en compte des primitifs && tableaux uniquement
* *
*/ */
// Object.prototype.clone = function(){ cloneObject = function(input){
// return this; return JSON.parse( JSON.stringify(input) );
// }; };
/* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER /* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER