|
|
|
@ -2,8 +2,8 @@ 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.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(c)),e=lsi.get("fiches",c.uid.value);if(!1!==e){if(null!=e.hash&&e.hash==d)break;console.warn("> FICHE UPDATE");c={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:d};c.valid=this.check(c);c.timestamp=Date.now();
|
|
|
|
|
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(),f=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid.value);if(!1!==d){if(null!=d.hash&&d.hash==f)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:f};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?
|
|
|
|
@ -12,14 +12,14 @@ if(!1===b)return!1;this.container.innerHTML+=ficheBuilder.build({firstname:b.fir
|
|
|
|
|
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 d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<d.length&&b<a.freq[c].length;b++)a.freq[c][b].status?
|
|
|
|
|
d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<d.length&&b<a.connect[c].length;b++)a.connect[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};
|
|
|
|
|
"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 f=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<f.length&&b<a.freq[c].length;b++)a.freq[c][b].status?
|
|
|
|
|
f[b].setAttribute("checked","checked"):f[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(f=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<f.length&&b<a.connect[c].length;b++)a.connect[c][b].status?f[b].setAttribute("checked","checked"):f[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;for(b in a){if(-1<a[b].call){var c=a[b].call,d=lsi.get("fiches",c);null==d&&(d=this.defaultData);d.uid=c;d.contact=b;lsi.set("fiches",c,d)}-1<a[b].sms&&(c=10+a[b].sms,d=lsi.get("fiches",c),null==d&&(d=this.defaultData),d.uid=c,d.contact=b,lsi.set("fiches",c,d))}var a=lsi["export"]("mini-fiches"),d=lsi["export"]("fiches"),e;for(e in d)d[e].timestamp>a[e].timestamp?(a[e].sexe=d[e].sexe,a[e].age=d[e].age,
|
|
|
|
|
a[e].job=d[e].job,a[e].loc=d[e].loc):(d[e].sexe=a[e].sexe,d[e].age=a[e].age,d[e].job=a[e].job,d[e].loc=a[e].loc),lsi.set("mini-fiches",e,a[e]),lsi.set("fiches",e,d[e]);for(e in d)a=lsi.get("contacts",d[e].contact),null!=a&&-1!=a.sms&&-1!=a.call&&(a=10>parseInt(e)?10+a.sms:a.call,a=d[a],a.timestamp>=d[e].timestamp||(b=d[e],b.uid=a.uid,lsi.set("fiches",a.uid,b)))};
|
|
|
|
|
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=Object.keys(a).length;if(this.nav_container.children.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> ":(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 d in a)b=$('#nav-fiche [data-n="'+
|
|
|
|
|
a[d].uid+'"]'),!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))};
|
|
|
|
|
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 f=a[c].call;b.push(f);var d=lsi.get("fiches",f);null==d&&(d=this.defaultData);d.uid=f;d.contact=c;lsi.set("fiches",f,d)}-1<a[c].sms&&(f=10+a[c].sms,b.push(f),d=lsi.get("fiches",f),null==d&&(d=this.defaultData),d.uid=f,d.contact=c,lsi.set("fiches",f,d))}console.log(b);if(20>b.length)for(c in console.log("need to add contacts sequentially to top 10s"),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"),e;for(e in d)d[e].timestamp>b[e].timestamp?(b[e].sexe=d[e].sexe,b[e].age=d[e].age,b[e].job=d[e].job,b[e].loc=d[e].loc):(d[e].sexe=b[e].sexe,d[e].age=b[e].age,d[e].job=b[e].job,d[e].loc=b[e].loc),lsi.set("mini-fiches",e,b[e]),lsi.set("fiches",e,d[e]);for(e in d)b=lsi.get("contacts",d[e].contact),
|
|
|
|
|
null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(e)?10+b.sms:b.call,b=d[b],b.timestamp>=d[e].timestamp||(c=d[e],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;console.log($$("#nav-fiche [data-n]").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> ":(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 f in a)b=
|
|
|
|
|
$('#nav-fiche [data-n="'+a[f].uid+'"]'),!0===a[f].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.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)};
|
|
|
|
|