Remplacement de `loc` par `loc2` dans les `mini` et les `fiches`

This commit is contained in:
xdrm-brackets 2016-05-06 12:19:25 +02:00
parent fa3043997c
commit da91926146
4 changed files with 51 additions and 73 deletions

File diff suppressed because one or more lines are too long

View File

@ -104,10 +104,10 @@ miniFicheBuilder.setLayout(
"\t<h5 class='nobold color0'>\n"+
"\t\tOù habite t-elle/il ?<br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_min_@uid' data-name='loc' id='locA_min_@uid'><label for='locA_min_@uid'>- de 10km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_min_@uid' data-name='loc' id='locB_min_@uid'><label for='locB_min_@uid'>de 10km à 30km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_min_@uid' data-name='loc' id='locC_min_@uid'><label for='locC_min_@uid'>de 30km à 100km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_min_@uid' data-name='loc' id='locD_min_@uid'><label for='locD_min_@uid'>+ de 100km</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_min_@uid' data-name='loc' id='locA_min_@uid'><label for='locA_min_@uid'>- de 5 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_min_@uid' data-name='loc' id='locB_min_@uid'><label for='locB_min_@uid'>de 5 à 15 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_min_@uid' data-name='loc' id='locC_min_@uid'><label for='locC_min_@uid'>de 15 à 60 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_min_@uid' data-name='loc' id='locD_min_@uid'><label for='locD_min_@uid'>+ d'une heure</label><br>\n"+
"\t</h5>\n"+
"</article>");
@ -289,18 +289,10 @@ ficheBuilder.setLayout(
"\t<h5 class='nobold color0'>\n"+
"\t\tOù habite t-elle/il ?<br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_@uid' data-name='loc' id='locA_@uid'><label for='locA_@uid'>- de 10km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_@uid' data-name='loc' id='locB_@uid'><label for='locB_@uid'>de 10km à 30km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_@uid' data-name='loc' id='locC_@uid'><label for='locC_@uid'>de 30km à 100km</label><br>\n"+
"\t\t&nbsp&nbsp&nbsp<input type='radio' name='loc_@uid' data-name='loc' id='locD_@uid'><label for='locD_@uid'>+ de 100km</label>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc2_@uid' data-name='loc2' id='loc2A_@uid'><label for='loc2A_@uid'>- de 5 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc2_@uid' data-name='loc2' id='loc2B_@uid'><label for='loc2B_@uid'>de 5 à 15 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc2_@uid' data-name='loc2' id='loc2C_@uid'><label for='loc2C_@uid'>de 15 à 60 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc2_@uid' data-name='loc2' id='loc2D_@uid'><label for='loc2D_@uid'>+ d'une heure</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_@uid' data-name='loc' id='locA_@uid'><label for='locA_@uid'>- de 5 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_@uid' data-name='loc' id='locB_@uid'><label for='locB_@uid'>de 5 à 15 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_@uid' data-name='loc' id='locC_@uid'><label for='locC_@uid'>de 15 à 60 minutes</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='loc_@uid' data-name='loc' id='locD_@uid'><label for='locD_@uid'>+ d'une heure</label><br>\n"+
"\t</h5>\n"+
"\t<h5 class='nobold color0'>\n"+

View File

@ -1,25 +1,24 @@
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}],loc2:[{status:!0},{status:!1},{status:!1},{status:!1}],duration:["",""],context:[{status:!0},
{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1},{status:!1}],contextSpecial:["","",""],freq:[[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}],[{status:!0},{status:!1},{status:!1},{status:!1}]],connect:[[{status:!1},{status:!0}],[{status:!1},{status:!0}],
[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}],[{status:!1},{status:!0}]],connectSpecial:["",""],timestamp:0,valid:!1}};
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},
{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}],
[{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;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,
reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,city:c.city.value,loc:c.loc,loc2:c.loc2,duration:[c.duration[0].value,c.duration[1].value],context:c.context,contextSpecial:[c.contextSpecial[0].value,c.contextSpecial[1].value,c.contextSpecial[2].value],freq:[c.freq0,c.freq1,c.freq2,c.freq3,c.freq4],connect:[c.connect0,c.connect1,c.connect2,c.connect3,c.connect4,c.connect5],connectSpecial:[c.connectSpecial[0].value,c.connectSpecial[1].value],hash:e};c.valid=this.check(c);c.timestamp=Date.now();
lsi.set("fiches",c.uid,c)}}};
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.uid,c)}}};
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||null==a.contact)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.city=null!=a.city?a.city:this.defaultData.city;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:
this.defaultData.contextSpecial[0];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.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.loc2=null!=a.loc2?a.loc2:this.defaultData.loc2;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("contacts",a.contact);
if(!1===b)return!1;this.container.innerHTML+=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,age:a.age,city:a.city,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});
b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&
b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length&&b<a.famsit.length;b++)a.famsit[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length&&b<a.reltype.length;b++)a.reltype[b].status?
c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length&&b<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');for(b=0;b<c.length&&b<a.loc2.length;b++)a.loc2[b].status?c[b].setAttribute("checked",
"checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length&&b<a.context.length;b++)a.context[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var 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+'"] ~ 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")};
a.studies:this.defaultData.studies;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.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,
lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,age:a.age,city:a.city,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+
a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length&&b<a.famsit.length;b++)a.famsit[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length&&b<a.reltype.length;b++)a.reltype[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+
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.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+'"] ~ 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=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);
d.uid=a;d.contact=c;lsi.set("fiches",a,d);if(20<=b.length)break}var b=lsi["export"]("mini-fiches"),d=lsi["export"]("fiches"),f;for(f in d)c=d[f].contact,d[f].timestamp>b[c].timestamp?(b[c].sexe=d[f].sexe,b[c].age=d[f].age,b[c].studies=d[f].studies,b[c].loc=d[f].loc):(d[f].sexe=b[c].sexe,d[f].age=b[c].age,d[f].studies=b[c].studies,d[f].loc=b[c].loc),lsi.set("mini-fiches",f,b[f]),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"))};
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):(d[f].sexe=miniData.sexe,d[f].age=miniData.age,d[f].studies=miniData.studies,d[f].loc=miniData.loc),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.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+'"]'))};
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.loc2)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1;
for(b=0;b<a.connect.length;b++)if(!checkRadioValue(a.connect[b]))return!1;return a.reltype[8].status&&2>a.reltypeSpecial.length||a.context[11].status&&2>a.contextSpecial[0].length||a.context[12].status&&2>a.contextSpecial[1].length||a.context[13].status&&2>a.contextSpecial[2].length?!1:!0};
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.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)};

View File

@ -23,7 +23,6 @@ inputPhoneFiche.prototype = {
reltypeSpecial: '',
city: '',
loc: [ {status:true}, {status:false}, {status:false}, {status:false} ],
loc2: [ {status:true}, {status:false}, {status:false}, {status:false} ],
duration: ['', ''],
context: [ {status:true}, {status:false}, {status:false}, {status:false}, {status:false},
{status:false}, {status:false}, {status:false}, {status:false}, {status:false},
@ -87,18 +86,17 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
var obj = {
contact: deflated.contact.value,
uid: deflated.uid.value,
sexe: deflated.sexe, // Choix 1 à 2
age: deflated.age.value,
job: deflated.job.value,
famsit: deflated.famsit, // Choix 1 à 3
studies: deflated.studies.value,
reltype: deflated.reltype, // Choix 1 à 9
contact: deflated.contact.value,
uid: deflated.uid.value,
sexe: deflated.sexe, // Choix 1 à 2
age: deflated.age.value,
job: deflated.job.value,
famsit: deflated.famsit, // Choix 1 à 3
studies: deflated.studies.value,
reltype: deflated.reltype, // Choix 1 à 9
reltypeSpecial: deflated.reltypeSpecial.value,
city: deflated.city.value,
loc: deflated.loc, // Choix 1 à 3
loc2: deflated.loc2, // Choix 1 à 3
city: deflated.city.value,
loc: deflated.loc, // Choix 1 à 3
duration: [
deflated.duration[0].value, // Durée de la relation en mois
deflated.duration[1].value // Durée de la relation en années
@ -185,7 +183,6 @@ inputPhoneFiche.prototype.add = function(objectData){
objectData.famsit = (objectData.famsit != null) ? objectData.famsit : this.defaultData.famsit;
objectData.reltype = (objectData.reltype != null) ? objectData.reltype : this.defaultData.reltype;
objectData.loc = (objectData.loc != null) ? objectData.loc : this.defaultData.loc;
objectData.loc2 = (objectData.loc2 != null) ? objectData.loc2 : this.defaultData.loc2;
objectData.context = (objectData.context != null) ? objectData.context : this.defaultData.context;
objectData.freq = (objectData.freq != null) ? objectData.freq : this.defaultData.freq;
objectData.connect = (objectData.connect != null) ? objectData.connect : this.defaultData.connect;
@ -259,21 +256,15 @@ inputPhoneFiche.prototype.add = function(objectData){
if( objectData.loc[i].status ) locCreated[i].setAttribute('checked', 'checked');
else locCreated[i].removeAttribute('checked');
/* {12}is) On sélectionna la valeur des boutons <radio> pour la LOCATION */
var loc2Created = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');
for( var i = 0 ; i < loc2Created.length && i < objectData.loc2.length ; i++ )
if( objectData.loc2[i].status ) loc2Created[i].setAttribute('checked', 'checked');
else loc2Created[i].removeAttribute('checked');
/* {13} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
/* {12} On sélectionna la valeur des boutons <radio> pour le CONTEXTE DE RENCONTRE */
var contextCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="context"]');
for( var i = 0 ; i < contextCreated.length && i < objectData.context.length ; i++ )
if( objectData.context[i].status ) contextCreated[i].setAttribute('checked', 'checked');
else contextCreated[i].removeAttribute('checked');
else contextCreated[i].removeAttribute('checked');
/* {14} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
/* {13} On sélectionna la valeur des boutons <radio> pour les FREQUENCES */
for( var f = 0 ; f < objectData.freq.length ; f++ ){
var freqCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="freq'+f+'"]');
for( var i = 0 ; i < freqCreated.length && i < objectData.freq[f].length ; i++ )
@ -281,7 +272,7 @@ inputPhoneFiche.prototype.add = function(objectData){
else freqCreated[i].removeAttribute('checked');
}
/* {15} On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */
/* {14} On sélectionna la valeur des boutons <radio> pour les CONNECTIONS */
for( var c = 0 ; c < objectData.connect.length ;c++ ){
var connectCreated = $$('article.fiche-relation input[data-name="uid"][value="'+objectData.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]');
for( var i = 0 ; i < connectCreated.length && i < objectData.connect[c].length ; i++ )
@ -435,33 +426,32 @@ inputPhoneFiche.prototype.sync = function(){
/* (3) Mise à jour en fonction des MINI fiches
---------------------------------------------------------*/
/* (1) On récupère les valeurs des MINI fiches et des FICHES */
var miniData = lsi.export('mini-fiches');
var ficheData = lsi.export('fiches');
var ficheData = lsi.export('fiches');
/* (2) Pour chaque champ, on synchronise les MINI fiches avec les FICHES associées */
for( var key in ficheData ){
var contactUid = ficheData[key].contact;
miniData = lsi.get('mini-fiches', ficheData[key].contact);
var ficheModifiedLast = ficheData[key].timestamp > miniData[contactUid].timestamp;
var ficheModifiedLast = ficheData[key].timestamp >= miniData.timestamp;
/* (3) Si la FICHE a été modifiée en dernier, on utilise ses données */
if( ficheModifiedLast ){
miniData[contactUid].sexe = ficheData[key].sexe;
miniData[contactUid].age = ficheData[key].age;
miniData[contactUid].studies = ficheData[key].studies;
miniData[contactUid].loc = ficheData[key].loc;
miniData.sexe = ficheData[key].sexe;
miniData.age = ficheData[key].age;
miniData.studies = ficheData[key].studies;
miniData.loc = ficheData[key].loc;
/* (4) Sinon, on utilise les données de la MINI */
}else{
ficheData[key].sexe = miniData[contactUid].sexe;
ficheData[key].age = miniData[contactUid].age;
ficheData[key].studies = miniData[contactUid].studies;
ficheData[key].loc = miniData[contactUid].loc;
ficheData[key].sexe = miniData.sexe;
ficheData[key].age = miniData.age;
ficheData[key].studies = miniData.studies;
ficheData[key].loc = miniData.loc;
}
/* (5) On enregistre les modifications */
lsi.set('mini-fiches', key, miniData[key]);
lsi.set('mini-fiches', ficheData[key].contact, miniData);
lsi.set('fiches', key, ficheData[key]);
}
@ -628,9 +618,6 @@ inputPhoneFiche.prototype.check = function(ficheData){
// 11. La DISTANCE DE DOMICILE (location) a un et un seul choix
if( !checkRadioValue(ficheData.loc) )
return false;
// 11bis. La DISTANCE DE DOMICILE (location 2) a un et un seul choix
if( !checkRadioValue(ficheData.loc2) )
return false;
// 12. Le CONTEXTE DE RENCONTRE a un et un seul choix
if( !checkRadioValue(ficheData.context) )
return false;