Gestion de la création des fiches avec le top 10 des `appels`, puis le top 10 des `sms`
This commit is contained in:
parent
b029ac9062
commit
0b70913b26
File diff suppressed because one or more lines are too long
|
@ -169,6 +169,7 @@ var ficheBuilder = new HTMLBuilder();
|
|||
ficheBuilder.setLayout(
|
||||
"<article class='fiche-relation'>\n"+
|
||||
|
||||
"\t<input type='hidden' data-name='contact' value='@contact'>\n"+
|
||||
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
|
||||
"\t<input type='hidden' data-name='firstname' value='@firstname'>\n"+
|
||||
"\t<input type='hidden' data-name='lastname' value='@lastname'>\n"+
|
||||
|
|
|
@ -2,19 +2,21 @@ 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={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();lsi.set("fiches",c.uid,c)}}};
|
||||
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid)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.uid);if(!1===b)return!1;this.container.innerHTML+=
|
||||
ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",uid:a.uid,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 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")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");for(var a=lsi.keys("contacts"),b=0;b<a.length&&10>b;b++){var c=lsi.get("contacts",a[b]),d=lsi.get("fiches",a[b]);null==d&&(d=this.defaultData);d.uid=c.uid;lsi.set("fiches",a[b],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])};inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"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.innerHTML)-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();
|
||||
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+")",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 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")};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)};
|
||||
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])};inputPhoneFiche.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML)||"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.innerHTML)-1};
|
||||
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="";for(var c=0;c<b;c++)this.nav_container.innerHTML+="<span></span>"}for(var d in a)b=this.nav_container.children[a[d].uid],b.innerHTML=a[d].uid+1,!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[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};
|
||||
|
|
|
@ -87,6 +87,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
|||
|
||||
|
||||
var obj = {
|
||||
contact: deflated.contact.value,
|
||||
uid: deflated.uid.value,
|
||||
sexe: deflated.sexe, // Choix 1 à 2
|
||||
age: deflated.age.value,
|
||||
|
@ -158,8 +159,8 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
|
|||
inputPhoneFiche.prototype.add = function(objectData){
|
||||
console.log('FICHE: ADD');
|
||||
|
||||
// Si pas d'UID, on retourne une erreur
|
||||
if( objectData.uid == null )
|
||||
// Si pas d'UID ou d'UID de contact, on retourne une erreur
|
||||
if( objectData.uid == null || objectData.contact == null )
|
||||
return false;
|
||||
|
||||
/* (0) Gestion du formattage des valeur */
|
||||
|
@ -191,7 +192,7 @@ inputPhoneFiche.prototype.add = function(objectData){
|
|||
|
||||
|
||||
// {4} On récupère username/firstname/lastname du contact associé //
|
||||
var associatedContact = lsi.get('contacts', objectData.uid);
|
||||
var associatedContact = lsi.get('contacts', objectData.contact);
|
||||
|
||||
// Si on ne trouve pas le contact, on ne fais rien
|
||||
if( associatedContact === false )
|
||||
|
@ -204,6 +205,7 @@ inputPhoneFiche.prototype.add = function(objectData){
|
|||
lastname: associatedContact.lastname,
|
||||
username: (associatedContact.username.length==0) ? '' : '('+associatedContact.username+')',
|
||||
uid: objectData.uid,
|
||||
contact: objectData.contact, // uid du contact associé
|
||||
age: objectData.age,
|
||||
city: objectData.city,
|
||||
duration0: objectData.duration[0],
|
||||
|
@ -344,31 +346,55 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
|
||||
/* (1) Mise à jour en fonction des contacts
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On récupère les clés de tous les CONTACTS */
|
||||
var contactUIDs = lsi.keys('contacts');
|
||||
/* (1) On récupère tous les CONTACTS */
|
||||
var contacts = lsi.export('contacts');
|
||||
|
||||
/* (2) Pour chaque CONTACT, on met à jour/crée la MINI fiche associée */
|
||||
for( var i = 0 ; i < contactUIDs.length && i < 10; i++ ){
|
||||
/* (2) Pour chaque CONTACT, on met à jour/crée la FICHE associée, si dans le TOP 10 des APPELS ou des SMS */
|
||||
for( var uid in contacts ){
|
||||
|
||||
/* (3) On récupère les informations du CONTACT */
|
||||
var contactData = lsi.get('contacts', contactUIDs[i]);
|
||||
/* (3) Indice de 0 à 9 si dans le TOP 10 des APPELS */
|
||||
if( contacts[uid].call > -1 ){
|
||||
// On calcule le rang de la fiche en fonction du classement
|
||||
var ficheIndex = contacts[uid].call;
|
||||
|
||||
/* (4) On récupère les informations de la MINI (si elle existe) */
|
||||
var ficheData = lsi.get('fiches', contactUIDs[i]);
|
||||
// On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('fiches', ficheIndex);
|
||||
|
||||
// Si la fiche n'existe pas, on la crée avec les valeurs par défaut
|
||||
if( ficheData == null )
|
||||
ficheData = this.defaultData;
|
||||
|
||||
// On met à jour la fiche ET on l'enregistre
|
||||
ficheData.uid = ficheIndex;
|
||||
ficheData.contact = uid;
|
||||
lsi.set('fiches', ficheIndex, ficheData);
|
||||
}
|
||||
|
||||
|
||||
/* (5) Si la FICHE n'exise pas, on la crée avec les valeurs par défaut */
|
||||
if( ficheData == null )
|
||||
ficheData = this.defaultData;
|
||||
/* (4) Indice de 10 à 19 si dans le TOP 10 des SMS */
|
||||
if( contacts[uid].sms > -1 ){
|
||||
// On calcule le rang de la fiche en fonction du classement
|
||||
var ficheIndex = 10+contacts[uid].sms;
|
||||
|
||||
// On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('fiches', ficheIndex);
|
||||
|
||||
// Si la fiche n'existe pas, on la crée avec les valeurs par défaut
|
||||
if( ficheData == null )
|
||||
ficheData = this.defaultData;
|
||||
|
||||
// On met à jour la fiche ET on l'enregistre
|
||||
ficheData.uid = ficheIndex;
|
||||
ficheData.contact = uid;
|
||||
lsi.set('fiches', ficheIndex, ficheData);
|
||||
|
||||
|
||||
/* (6) On met à jour la fiche */
|
||||
ficheData.uid = contactData.uid;
|
||||
}
|
||||
|
||||
|
||||
/* (7) On enregistre les modification */
|
||||
lsi.set('fiches', contactUIDs[i], ficheData);
|
||||
}
|
||||
|
||||
|
||||
/* (2) Mise à jour en fonction des MINI fiches
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On récupère les valeurs des MINI fiches et des FICHES */
|
||||
|
|
|
@ -4,9 +4,8 @@ f;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNo
|
|||
function checkRadioValue(a){for(var e=0,b=0;b<a.length;b++)!0===a[b].status&&e++;return 1!=e?!1:!0}
|
||||
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
|
||||
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:importCallLog.files[0]};
|
||||
api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0,f=[],c=0;c<a.calls.length&&10>c;c++)f.push(a.calls[c].number);for(c=0;c<f.length;c++){var d=a.directory[f[c]].name.split(" ");lsi.set("contacts",b,{uid:b,number:f[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",call:c});b++}console.log(lsi["export"]("contacts"));for(var g=[],c=0;c<a.sms.length&&10>c;c++)g.push(a.sms[c].number);for(c=0;c<g.length;c++)if(d=f.indexOf(g[c]),
|
||||
-1<d){var k=lsi.get("contacts",d);k.sms=c;lsi.set("contacts",d,k)}else d=a.directory[g[c]].name.split(" "),lsi.set("contacts",b,{uid:b,number:g[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",sms:c}),b++;console.log(lsi["export"]("contacts"));for(var h in a.directory)-1<f.indexOf(h)||-1<g.indexOf(h)||(d=(null===a.directory[h].name?"":a.directory[h].name).split(" "),lsi.set("contacts",b,{uid:b,number:h,username:1==d.length?d[0]:"",firstname:1<
|
||||
d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",call:-1,sms:-1}),b++);console.log(lsi["export"]("contacts"));contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);$("#export-all").addEventListener("click",function(a){a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};var e=$("#download-target");e.download=
|
||||
"local-data.json";e.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));e.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#local-upload").files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",
|
||||
a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};
|
||||
api.send(a,function(a){console.log(a)},!1)},!1)})})})});
|
||||
api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var b=0,f=[],c=0;c<a.calls.length&&10>c;c++)f.push(a.calls[c].number);for(c=0;c<f.length;c++){var d=a.directory[f[c]].name.split(" ");lsi.set("contacts",b,{uid:b,number:f[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",call:c});b++}for(var g=[],c=0;c<a.sms.length&&10>c;c++)g.push(a.sms[c].number);for(c=0;c<g.length;c++)if(d=f.indexOf(g[c]),-1<d){var k=lsi.get("contacts",d);k.sms=
|
||||
c;lsi.set("contacts",d,k)}else d=a.directory[g[c]].name.split(" "),lsi.set("contacts",b,{uid:b,number:g[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",sms:c}),b++;for(var h in a.directory)-1<f.indexOf(h)||-1<g.indexOf(h)||(d=(null===a.directory[h].name?"":a.directory[h].name).split(" "),lsi.set("contacts",b,{uid:b,number:h,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",call:-1,sms:-1}),
|
||||
b++);contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);$("#export-all").addEventListener("click",function(a){a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};var e=$("#download-target");e.download="local-data.json";e.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));e.click()},!1);$("#import-all").addEventListener("click",
|
||||
function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#local-upload").files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);
|
||||
submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},!1)},!1)})})})});
|
||||
|
|
|
@ -260,7 +260,7 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
|
||||
uid++;
|
||||
}
|
||||
console.log( lsi.export('contacts') );
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -293,7 +293,7 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
|
||||
uid++;
|
||||
}
|
||||
console.log( lsi.export('contacts') );
|
||||
|
||||
|
||||
/* (6) Pour chaque contact qui n'est pas dans le top 10, on l'ajoute */
|
||||
for( var number in response.directory ){
|
||||
|
@ -324,7 +324,7 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
|
||||
uid++;
|
||||
}
|
||||
console.log( lsi.export('contacts') );
|
||||
|
||||
|
||||
/* (6) On met à jour l'affichage */
|
||||
contactManager.storageToFields();
|
||||
|
|
Loading…
Reference in New Issue