Gestion du clonage fonctionnel pour `input/phone` [FUNC]

This commit is contained in:
xdrm-brackets 2016-10-21 16:09:34 +02:00
parent f7457f3f38
commit b41f50e23e
4 changed files with 48 additions and 24 deletions

View File

@ -326,6 +326,7 @@ pFicheBuilder.setLayout(
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype5_p_@uid' value='5'><label for='reltype5_p_@uid'>Voisin</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype5_p_@uid' value='5'><label for='reltype5_p_@uid'>Voisin</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype6_p_@uid' value='6'><label for='reltype6_p_@uid'>Ami proche</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype6_p_@uid' value='6'><label for='reltype6_p_@uid'>Ami proche</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype7_p_@uid' value='7'><label for='reltype7_p_@uid'>Ami</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype7_p_@uid' value='7'><label for='reltype7_p_@uid'>Ami</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype8_p_@uid' value='8'><label for='reltype8_p_@uid'>Relation de service (médecin, ...)</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype10_p_@uid' value='10'><label for='reltype10_p_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_p_@uid' data-name='reltype' id='reltype10_p_@uid' value='10'><label for='reltype10_p_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+
"\t</h5>\n"+ "\t</h5>\n"+

View File

@ -104,7 +104,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
/* (7) On met à jour le `timestamp` (car à ce point, on a une modification) */ /* (7) On met à jour le `timestamp` (car à ce point, on a une modification) */
obj.timestamp = Date.now(); obj.timestamp = Date.now();
console.warn('> FICHE UPDATE ('+(obj.timestamp-input_ts)+')', existingData, obj); console.warn('> FICHE UPDATE ('+(obj.timestamp-input_ts)+')');
/* (8) On enregistre les données dans le 'localStorage' */ /* (8) On enregistre les données dans le 'localStorage' */
lsi.set('p_fiches', obj.uid, obj); lsi.set('p_fiches', obj.uid, obj);
@ -481,7 +481,7 @@ inputPhoneFiche.prototype.sync = function(){
/* (5.1) fiche vers fiche */ /* (5.1) fiche vers fiche */
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); /*CLONING_DEBUG*///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 = cloneObject( clone[last_index][1] ); copied = cloneObject( clone[last_index][1] );
copied.uid = clone[i][1].uid; copied.uid = clone[i][1].uid;
lsi.set('p_fiches', copied.uid, copied); lsi.set('p_fiches', copied.uid, copied);
@ -489,19 +489,41 @@ inputPhoneFiche.prototype.sync = function(){
/* (5.2) fiche vers mini OU mini vers fiche*/ /* (5.2) fiche vers mini OU mini vers fiche*/
}else if( clone[last_index][0] == 'fiche' ){ }else if( clone[last_index][0] == 'fiche' ){
console.warn('copying '+clone[last_index][0]+'#'+clone[last_index][1].uid+' to '+clone[i][0]+'#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); /*CLONING_DEBUG*///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 = cloneObject( 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;
lsi.set( (clone[i][0]=='mini') ? 'p_mini-fiches' : 'p_fiches', copied.uid, copied); lsi.set('p_mini-fiches', copied.uid, copied);
/* (5.3) mini vers fiche */
}else{
/*CLONING_DEBUG*///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 = cloneObject( clone[i][1] );
copied.age = clone[last_index][1].age;
copied.sexe = clone[last_index][1].sexe;
copied.loc = clone[last_index][1].loc;
copied.reltype = clone[last_index][1].reltype;
copied.reltypeSpecial = clone[last_index][1].reltypeSpecial;
// Particularité 1, `mini` peut prendre la valeur '.' en plus de celles de `fiche`
if( clone[last_index][1].loc == '.' ) copied.loc = '0';
// Particularité 2, `mini` peut prendre la valeur '9' (inconnu) en plus de celles de `fiche`
if( clone[last_index][1].reltype == '9' ){
copied.reltype = '10';
copied.reltypeSpecial = 'inconnu';
}
lsi.set('p_fiches', copied.uid, copied);
} }
} }
console.warn('cloning done'); /*CLONING_DEBUG*///console.warn('cloning done');
} }

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,23 @@
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,b){this.container=a;this.nav_container=b;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");var a,c,b,d,f,e=$$('[data-sublink="phone"] article.relation-panel .fiche-relation');a=0;for(c=e.length;a<c;a++)if(b=new FormDeflater(e[a],["input","select"],["data-name"]),d=b.deflate(),b=lsi.get("p_fiches",d.uid),!1!==b&&(d={sexe:d.sexe,age:d.age,job:d.job,famsit:d.famsit,studies:d.studies,reltype:d.reltype,reltypeSpecial:d.reltypeSpecial,city:d.city,quartier:d.quartier,cp:d.cp,loc:d.loc,duration:d.duration, inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");var a,b,c,e,d,h=$$('[data-sublink="phone"] article.relation-panel .fiche-relation');a=0;for(b=h.length;a<b;a++)if(c=new FormDeflater(h[a],["input","select"],["data-name"]),e=c.deflate(),c=lsi.get("p_fiches",e.uid),!1!==c&&(e={sexe:e.sexe,age:e.age,job:e.job,famsit:e.famsit,studies:e.studies,reltype:e.reltype,reltypeSpecial:e.reltypeSpecial,city:e.city,quartier:e.quartier,cp:e.cp,loc:e.loc,duration:e.duration,
context:d.context,contextSpecial:d.contextSpecial,freq:d.freq,connect:d.connect,connectSpecial:d.connectSpecial,uid:parseInt(d.uid),contact:parseInt(d.contact)},f=crc32(JSON.stringify(d)),void 0==b.hash||f!=b.hash))d.hash=f,d.valid=this.check(d),d.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(d.timestamp-input_ts)+")",b,d),lsi.set("p_fiches",d.uid,d);console.groupEnd()}; context:e.context,contextSpecial:e.contextSpecial,freq:e.freq,connect:e.connect,connectSpecial:e.connectSpecial,uid:parseInt(e.uid),contact:parseInt(e.contact)},d=crc32(JSON.stringify(e)),void 0==c.hash||d!=c.hash))e.hash=d,e.valid=this.check(e),e.timestamp=Date.now(),console.warn("> FICHE UPDATE ("+(e.timestamp-input_ts)+")"),lsi.set("p_fiches",e.uid,e);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:
this.defaultData.connect;var c=lsi.get("p_contacts",a.contact);if(!1===c)return!1;var b="";isNaN(c.existing)||(b=lsi.get("p_friends",c.existing),c.username=b.name,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.studies2?(a.studies=b.studies2,a.job=b.job,a.famsit=b.famsit,a.city=b.city,a.cp=b.cp,a.quartier=b.quartier,a.duration[0]=b.duration[0],a.duration[1]=b.duration[1],a.context=b.context,a.contextSpecial= this.defaultData.connect;var b=lsi.get("p_contacts",a.contact);if(!1===b)return!1;var c="";isNaN(b.existing)||(c=lsi.get("p_friends",b.existing),b.username=c.name,a.age=c.age,a.sexe=c.sexe,a.loc=c.dist,isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):(a.reltype=c.reltype,a.reltypeSpecial=""),null!=c.studies2?(a.studies=c.studies2,a.job=c.job,a.famsit=c.famsit,a.city=c.city,a.cp=c.cp,a.quartier=c.quartier,a.duration[0]=c.duration[0],a.duration[1]=c.duration[1],a.context=c.context,a.contextSpecial=
b.contextExtra,a.connect=b.connect,a.connectSpecial=b.connectExtra,a.freq=b.freq,b="Contact import\u00e9: non modifiable!"):b="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:b,name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1], c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq,c="Contact import\u00e9: non modifiable!"):c="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:c,name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,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]});c=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=c&&c.setAttribute("selected", contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('[data-sublink="phone"] 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=$('[data-sublink="phone"] 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");c=$('[data-sublink="phone"] article.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.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.sexe?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+ "selected");b=$('[data-sublink="phone"] 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");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(c=0;c<b.length;c++)b[c].value==a.famsit?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="reltype"]');for(c=0;c<b.length;c++)b[c].value==a.reltype?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="famsit"]');for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[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="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[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(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a,c=lsi["export"]("p_fiches");this.container.innerHTML="";for(var b in c)a=cloneObject(c[b]),delete a.hash,delete a.timestamp,delete a.valid,c[b].hash=crc32(JSON.stringify(a)),lsi.set("p_fiches",c[b].uid,c[b]),c[b].uid==this.selected&&this.add(c[b]);this.updateNavBar();console.groupEnd()}; inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.fiche] storage to fields");var a,b=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in b)a=cloneObject(b[c]),delete a.hash,delete a.timestamp,delete a.valid,b[c].hash=crc32(JSON.stringify(a)),lsi.set("p_fiches",b[c].uid,b[c]),b[c].uid==this.selected&&this.add(b[c]);this.updateNavBar();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");lsi["export"]("p_contacts");var a,c,b,d;d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size;for(c=0;c<d;c++)a=lsi.get("p_fiches",c),!a&&(a=this.defaultData),a.uid=c,a.contact=c,lsi.set("p_fiches",c,a);var f,e,h;d={};var l={};a=lsi["export"]("p_fiches");c=lsi["export"]("p_mini-fiches");for(var k in a)if(f=lsi.get("p_contacts",a[k].contact),!(0<f.username.length&&void 0!= inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");lsi["export"]("p_contacts");var a,b,c,e;e=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size;for(b=0;b<e;b++)a=lsi.get("p_fiches",b),!a&&(a=this.defaultData),a.uid=b,a.contact=b,lsi.set("p_fiches",b,a);var d,h,g;e={};var l={};a=lsi["export"]("p_fiches");b=lsi["export"]("p_mini-fiches");for(var k in a)if(d=lsi.get("p_contacts",a[k].contact),!(0<d.username.length&&void 0!=
d[f.username]||0==f.username.length&&void 0!=l[f.existing])&&(0<f.username.length?d[f.username]=0:l[f.existing]=0,f)){var g=[["fiche",a[k]]];for(b in a)e=lsi.get("p_contacts",a[b].contact),b!=k&&e&&(h=0<e.username.length&&f.username===e.username,e=!isNaN(e.existing)&&f.existing===e.existing,(h||e)&&g.push(["fiche",a[b]]));for(b in c)e=lsi.get("p_contacts",c[b].contact),h=0<e.username.length&&f.username===e.username,e=!isNaN(e.existing)&&f.existing===e.existing,(h||e)&&g.push(["mini",c[b]]);if(1!== e[d.username]||0==d.username.length&&void 0!=l[d.existing])&&(0<d.username.length?e[d.username]=0:l[d.existing]=0,d)){var f=[["fiche",a[k]]];for(c in a)h=lsi.get("p_contacts",a[c].contact),c!=k&&h&&(g=0<h.username.length&&d.username===h.username,h=!isNaN(h.existing)&&d.existing===h.existing,(g||h)&&f.push(["fiche",a[c]]));for(c in b)h=lsi.get("p_contacts",b[c].contact),g=0<h.username.length&&d.username===h.username,h=!isNaN(h.existing)&&d.existing===h.existing,(g||h)&&f.push(["mini",b[c]]);if(1!==
g.length){h=[];for(b in g)h[b]=g[b][1].hasOwnProperty("timestamp")?g[b][1].timestamp:0;e=h.indexOf(Math.max.apply(Math,h));for(b in g)b!=e&&(g[b][0]==g[e][0]?(console.warn("copying fiche#"+g[e][1].uid+" to fiche#"+g[b][1].uid,h[e]-input_ts,h[b]-input_ts),f=cloneObject(g[e][1]),f.uid=g[b][1].uid,lsi.set("p_fiches",f.uid,f)):"fiche"==g[e][0]&&(console.warn("copying "+g[e][0]+"#"+g[e][1].uid+" to "+g[b][0]+"#"+g[b][1].uid,h[e]-input_ts,h[b]-input_ts),f=cloneObject(g[b][1]),f.age=g[e][1].age,f.sexe=g[e][1].sexe, f.length){d=[];for(c in f)d[c]=f[c][1].hasOwnProperty("timestamp")?f[c][1].timestamp:0;g=d.indexOf(Math.max.apply(Math,d));for(c in f)c!=g&&(f[c][0]==f[g][0]?(d=cloneObject(f[g][1]),d.uid=f[c][1].uid,lsi.set("p_fiches",d.uid,d)):"fiche"==f[g][0]?(d=cloneObject(f[c][1]),d.age=f[g][1].age,d.sexe=f[g][1].sexe,d.loc=f[g][1].loc,d.reltype=f[g][1].reltype,d.reltypeSpecial=f[g][1].reltypeSpecial,lsi.set("p_mini-fiches",d.uid,d)):(d=cloneObject(f[c][1]),d.age=f[g][1].age,d.sexe=f[g][1].sexe,d.loc=f[g][1].loc,
f.loc=g[e][1].loc,f.reltype=g[e][1].reltype,f.reltypeSpecial=g[e][1].reltypeSpecial,lsi.set("mini"==g[b][0]?"p_mini-fiches":"p_fiches",f.uid,f)));console.warn("cloning done")}}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"))}; d.reltype=f[g][1].reltype,d.reltypeSpecial=f[g][1].reltypeSpecial,"."==f[g][1].loc&&(d.loc="0"),"9"==f[g][1].reltype&&(d.reltype="10",d.reltypeSpecial="inconnu"),lsi.set("p_fiches",d.uid,d)))}}console.groupEnd()};
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 d=parseInt(c[b]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+ 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 b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
d+'">'+(d%20+1)+"</span>")}for(var f in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[f].uid+'"]'),null!=c&&(!0===a[f].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var e=parseInt(b[c]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>e&&c<b.length-1&&20<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%20+1)+"</span>&nbsp;&nbsp;":(20==e&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
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|| e+'">'+(e%20+1)+"</span>")}for(var d in a)b=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.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 b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])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()};