Gestion des clones pour les 'phone.fiche' entre APPELS et SMS + Correction des 'include(jsRes)'
This commit is contained in:
parent
5c51989e43
commit
b8e03b0ea5
|
@ -1,20 +1,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:"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.log("FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] 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("p_fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;c={contact:parseInt(c.contact),uid:parseInt(c.uid),sexe:c.sexe,age:c.age,job:c.job,famsit:c.famsit,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,
|
||||
city:c.city,quartier:c.quartier,cp:c.cp,loc:c.loc,duration:c.duration,context:c.context,contextSpecial:c.contextSpecial,freq:c.freq,connect:c.connect,connectSpecial:c.connectSpecial,hash:e};c.valid=this.check(c);0<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("p_fiches",c.uid,c)}}};
|
||||
function inputPhoneFiche(a,c){this.container=a;this.nav_container=c}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.log("FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.relation-panel .fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(b)),e=lsi.get("p_fiches",b.uid);if(!1!==e){if(null!=e.hash&&e.hash==d)break;b={contact:parseInt(b.contact),uid:parseInt(b.uid),sexe:b.sexe,age:b.age,job:b.job,famsit:b.famsit,studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,
|
||||
city:b.city,quartier:b.quartier,cp:b.cp,loc:b.loc,duration:b.duration,context:b.context,contextSpecial:b.contextSpecial,freq:b.freq,connect:b.connect,connectSpecial:b.connectSpecial,hash:d};b.valid=this.check(b);0<diff(e,b,["hash","valid","timestamp"]).length&&(console.log(diff(e,b,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),b.timestamp=Date.now());lsi.set("p_fiches",b.uid,b)}}};
|
||||
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");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.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 b=lsi.get("p_contacts",a.contact);if(!1===b)return!1;if(!isNaN(b.existing)){var 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=c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq)}this.container.innerHTML+=pFicheBuilder.build({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]});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");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(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(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(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.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("p_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"]("p_contacts"),b=[],c=40>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:40;if(b.length<c)for(var e in a){for(var d=0;-1<b.indexOf(d)&&d<c;)d++;b.push(d);a=lsi.get("p_fiches",d);null==a&&(a=this.defaultData);a.uid=d;a.contact=parseInt(e);lsi.set("p_fiches",d,a);if(b.length>=c)break}var a=lsi["export"]("p_fiches"),f;for(f in a)b=lsi.get("p_contacts",a[f].contact),null!=b&&(b=20>parseInt(f)?20+b.sms:
|
||||
b.call,b=a[b],null==b||b.timestamp>=a[f].timestamp||(c=a[f],c.uid=b.uid,lsi.set("p_fiches",b.uid,c)))};inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===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"))};
|
||||
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> ":(20==e&&(this.nav_container.innerHTML+='<br><span class="fc"> SMS </span>'),this.nav_container.innerHTML+='<span data-n="'+
|
||||
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.log("FICHE: ATTACH");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};
|
||||
a.connect=null!=a.connect?a.connect:this.defaultData.connect;var c=lsi.get("p_contacts",a.contact);if(!1===c)return!1;if(!isNaN(c.existing)){var 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=b.contextExtra,a.connect=b.connect,a.connectSpecial=b.connectExtra,a.freq=b.freq)}this.container.innerHTML+=pFicheBuilder.build({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],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","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="'+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="loc"]');
|
||||
for(c=0;c<b.length;c++)b[c].value==a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(c=0;c<b.length;c++)b[c].value==a.context?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');
|
||||
for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar()};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("p_contacts"),c=[],b,d=40>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:40,e;for(e in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<d;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(e);lsi.set("p_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("p_fiches"),f;for(f in a)if(d=lsi.get("p_contacts",a[f].contact)){c=
|
||||
null;e=20>parseInt(a[f].uid);for(var g in a)if(!(e&&20>g||!e&&20<=g)&&(b=lsi.get("p_contacts",a[g].contact),g!=f&&b)){var h=0<b.username.length&&d.username===b.username;b=!isNaN(b.existing)&&d.existing===b.existing;(h||b)&&(c=a[g]);if(null!==c)break}null===c||c.timestamp>a[f].timestamp||(d=a[f],d.uid=c.uid,lsi.set("p_fiches",c.uid,d))}};
|
||||
inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var 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> ":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc"> SMS </span>'),this.nav_container.innerHTML+='<span data-n="'+
|
||||
d+'">'+(d%20+1)+"</span>")}for(var e in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=c&&(!0===a[e].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))};
|
||||
inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var c=0;c<a.freq.length;c++)if(""==a.freq[c])return!1;for(c=0;c<a.connect.length;c++)if(""==a.connect[c])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||
|
||||
"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.log("FICHE: ATTACH");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;var c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1)};
|
||||
|
|
|
@ -343,77 +343,98 @@ inputPhoneFiche.prototype.storageToFields = function(){
|
|||
inputPhoneFiche.prototype.sync = function(){
|
||||
console.log('FICHE: SYNC');
|
||||
|
||||
/* (1) Mise à jour en fonction des contacts APRÈS IMPORT
|
||||
/* (1) Initialisation
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On récupère tous les CONTACTS */
|
||||
var contacts = lsi.export('p_contacts');
|
||||
var addedFicheUids = []; // Contiendra les uids des fiches qui seront crées
|
||||
|
||||
/* (2) Contiendra les uids des fiches qui seront crées */
|
||||
var addedFicheUids = [];
|
||||
var ficheData, contactData;
|
||||
|
||||
|
||||
|
||||
/* (2) Mise à jour en fonction des contacts APRÈS SAISIE MANUELLE
|
||||
/* (2) Mise à jour en fonction des contacts APRÈS SAISIE
|
||||
---------------------------------------------------------*/
|
||||
// Nombre maximum de fiches (40, sauf si moins de 40 contacts, dans ce cas, le nombre de contacts);
|
||||
var nbMaxFiche = lsi.keys('p_contacts').length < 40 ? lsi.keys('p_contacts').length : 40;
|
||||
|
||||
// Si moins de 20+20 contacts crées, on les complètes en fonction des contacts séquentiellement
|
||||
if( addedFicheUids.length < nbMaxFiche ){
|
||||
/* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée */
|
||||
for( var uid in contacts ){
|
||||
|
||||
/* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée*/
|
||||
for( var uid in contacts ){
|
||||
/* (1) On cherche un uid de fiche non existant dans l'intervalle [0;40[ */
|
||||
ficheUid = 0;
|
||||
while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche )
|
||||
ficheUid++;
|
||||
|
||||
/* (2) On cherche un uid de fiche non existant dans l'intervalle 0-19 */
|
||||
var ficheUid = 0;
|
||||
while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche )
|
||||
ficheUid++;
|
||||
// On enregistre le nouvel UID dans les uid crées
|
||||
addedFicheUids.push(ficheUid);
|
||||
|
||||
// On enregistre le nouvel UID dans les uid crées
|
||||
addedFicheUids.push(ficheUid);
|
||||
/* (2) On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('p_fiches', ficheUid);
|
||||
|
||||
/* (3) On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('p_fiches', ficheUid);
|
||||
// Si la fiche n'existe pas, on la crée avec les valeurs par défaut
|
||||
!ficheData && ( ficheData = this.defaultData );
|
||||
|
||||
// Si la fiche n'existe pas, on la crée avec les valeurs par défaut
|
||||
if( ficheData == null )
|
||||
ficheData = this.defaultData;
|
||||
|
||||
/* (4) On met à jour la fiche ET on l'enregistre */
|
||||
ficheData.uid = ficheUid;
|
||||
ficheData.contact = parseInt(uid);
|
||||
lsi.set('p_fiches', ficheUid, ficheData);
|
||||
/* (3) On met à jour la fiche ET on l'enregistre */
|
||||
ficheData.uid = ficheUid;
|
||||
ficheData.contact = parseInt(uid);
|
||||
lsi.set('p_fiches', ficheUid, ficheData);
|
||||
|
||||
|
||||
/* (5) Si on a déja crée 20+20 fiches, on arrête */
|
||||
if( addedFicheUids.length >= nbMaxFiche )
|
||||
break;
|
||||
}
|
||||
|
||||
/* (4) Si on a déja crée 20+20 fiches, on arrête */
|
||||
if( addedFicheUids.length >= nbMaxFiche )
|
||||
break;
|
||||
}
|
||||
|
||||
/* (3) Mise à jour des fiches dupliquées entre le top 20 des APPELS et celui des SMS
|
||||
|
||||
/* (3) Gestion des fiches dupliquées
|
||||
---------------------------------------------------------*/
|
||||
ficheData = lsi.export('p_fiches');
|
||||
|
||||
for( var key in ficheData ){
|
||||
|
||||
/* (1) On récupère le contact associé */
|
||||
var associatedContact = lsi.get('p_contacts', ficheData[key].contact);
|
||||
|
||||
// Si erreur, on passe au suivant
|
||||
if( associatedContact == null )
|
||||
if( !associatedContact )
|
||||
continue;
|
||||
|
||||
/* (3) On récupère l'autre fiche (clone) */
|
||||
var inCall = parseInt(key) < 20; // Si on est dans le top 20 des APPELS, sinon dans celui des SMS
|
||||
var cloneIndex = inCall ? 20+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS)
|
||||
/* (3) On récupère la/les autre(s) fiche(s) (clone(s)) */
|
||||
var clone = null;
|
||||
var inCall = parseInt( ficheData[key].uid ) < 20; // vrai si dans les APPELS, sinon dans les SMS
|
||||
|
||||
var clone = ficheData[cloneIndex];
|
||||
for( var i in ficheData ){
|
||||
|
||||
// si on est pas dans le bonne tranche, on passe au suivant
|
||||
if( inCall && i < 20 || !inCall && i >= 20 )
|
||||
continue;
|
||||
|
||||
/* (4) Si le clone a été modifié en dernier, on ne fait rien */
|
||||
if( clone == null || clone.timestamp >= ficheData[key].timestamp )
|
||||
// on récupère le contact associé
|
||||
contactData = lsi.get('p_contacts', ficheData[i].contact);
|
||||
|
||||
if( i == key || !contactData )
|
||||
continue;
|
||||
|
||||
// meme pseudo
|
||||
var hasSameUsername = contactData.username.length > 0 && associatedContact.username === contactData.username;
|
||||
// meme lien de contact
|
||||
var hasSameLink = !isNaN(contactData.existing) && associatedContact.existing === contactData.existing;
|
||||
|
||||
// si ont le même contact, alors on enregistre le clone (sauf si la même fiche)
|
||||
( hasSameUsername || hasSameLink ) && ( clone = ficheData[i] );
|
||||
|
||||
if( clone !== null )
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
/* (4) Si c'est le clone qui a été modifié en dernier, on ne fait rien */
|
||||
if( clone === null || clone.timestamp > ficheData[key].timestamp )
|
||||
continue;
|
||||
|
||||
/* (5) On copie les données de la FICHE dans le clone (cas ou la fiche est modifiée en dernier) */
|
||||
/* (5) On copie les données de la FICHE dans le CLONE */
|
||||
var obj = ficheData[key];
|
||||
obj.uid = clone.uid;
|
||||
lsi.set('p_fiches', clone.uid, obj);
|
||||
|
@ -432,10 +453,10 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
=========================================================*/
|
||||
inputPhoneFiche.prototype.nav = function(element){
|
||||
/* (1) On vérifie que l'élément contient un nombre et existe */
|
||||
if( element == null )
|
||||
if( !(element instanceof Element) )
|
||||
return false;
|
||||
|
||||
if( element.getData('n') === false || isNaN(element.getData('n')) || element.parentNode.id != 'p_nav-fiche' )
|
||||
if( !element.getData('n') || isNaN(element.getData('n')) || element.parentNode.id != 'p_nav-fiche' )
|
||||
return false;
|
||||
|
||||
/* (2) On désactive tous les éléments actifs */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function $(a){return document.querySelector(a)}function $$(a){return document.querySelectorAll(a)}Element.prototype.getData=function(a){return"undefined"==typeof this.dataset?!1:this.dataset.hasOwnProperty(a)?this.dataset[a]:!1};Element.prototype.addClass=function(a){var b=this.className.split(" ");-1<b.indexOf(a)||(b.push(a),this.className=b.join(" ").trim())};
|
||||
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var d=this;d.addClass(a);setTimeout(function(){d.remClass(a)},b)};var _includes=[],_includeTags=[];
|
||||
function include(a,b,d){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(null==a)return!1;if("boolean"===typeof d&&d){b=_includes.indexOf(a);if(-1==b)return!1;document.head.removeChild(_includeTags[b]);_includes.splice(b,1);_includeTags.splice(b,1)}else{if(-1<_includes.indexOf(a))return b(),!0;d=document.createElement("script");d.type="text/javascript";d.src=a;document.head.appendChild(d);_includes.push(a);_includeTags.push(d);d.onload=b}return!0}
|
||||
function diff(a,b,d){var e=[],c;for(c in a)null==b[c]||null==a[c]||d instanceof Array&&-1<d.indexOf(c)||(typeof a[c]!==typeof b[c]?e.push(c):a[c]instanceof Object&&b[c]instanceof Object?0<diff(a[c],b[c]).length&&e.push(c):a[c]!=b[c]&&e.push(c));return e}var format_number=new formatChecker(null,"0i ii ii ii ii");
|
||||
Element.prototype.remClass=function(a){var b=this.className.split(" ");a=b.indexOf(a);-1!=a&&(b=b.slice(0,a).concat(b.slice(a+1)),this.className=b.join(" ").trim())};NodeList.prototype.indexOf=HTMLCollection.prototype.indexOf=function(a){for(var b=0;b<this.length;b++)if(this[b]==a)return b;return-1};Element.prototype.anim=function(a,b){var c=this;c.addClass(a);setTimeout(function(){c.remClass(a)},b)};var _includes=[],_includeTags=[];
|
||||
function include(a,b,c){a="string"===typeof a?a:null;b="function"===typeof b?b:function(){console.log("[x] "+a+" loaded")};if(!a)return!1;if("boolean"===typeof c&&c){c=_includes.indexOf(a);if(-1==c)return!1;document.head.removeChild(_includeTags[c]);_includes.splice(c,1);_includeTags.splice(c,1)}else{if(-1<_includes.indexOf(a))return b(),!0;c=document.createElement("script");c.type="text/javascript";c.src=a;document.head.appendChild(c);_includes.push(a);_includeTags.push(c);c.onload=function(){return function(){b()}}()}return!0}
|
||||
function diff(a,b,c){var e=[],d;for(d in a)null==b[d]||null==a[d]||c instanceof Array&&-1<c.indexOf(d)||(typeof a[d]!==typeof b[d]?e.push(d):a[d]instanceof Object&&b[d]instanceof Object?0<diff(a[d],b[d]).length&&e.push(d):a[d]!=b[d]&&e.push(d));return e}var format_number=new formatChecker(null,"0i ii ii ii ii");
|
||||
|
|
|
@ -103,7 +103,7 @@ function include(jsResource, callback, action){ // action=true -> EXCLUSION, SIN
|
|||
action = typeof action === 'boolean' ? action : false;
|
||||
|
||||
// Si la ressource n'est pas donnée
|
||||
if( jsResource == null ) return false;
|
||||
if( !jsResource ) return false;
|
||||
|
||||
|
||||
/* (1) Gestion de l'inclusion */
|
||||
|
@ -125,7 +125,7 @@ function include(jsResource, callback, action){ // action=true -> EXCLUSION, SIN
|
|||
_includeTags.push(tag);
|
||||
|
||||
// On définit le callback
|
||||
tag.onload = callback;
|
||||
tag.onload = (function(){ return function(){ callback(); } })();
|
||||
|
||||
return true;
|
||||
/* (2) Gestion de l'exclusion */
|
||||
|
|
|
@ -1,24 +1,38 @@
|
|||
var sField,sSubmit,sList,pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager,fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
|
||||
document.body.addEventListener("load",function(){function e(b){var c=b instanceof Element,a=c&&"INPUT"==b.tagName&&"submit"==b.type,d=c&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),c=c&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!a&&!d&&!c&&!0!==b)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();
|
||||
!0===b?api.send({path:"subject/getFriends",subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(a||c)&&pContactManager.storageToFields())}function f(b){var c=b instanceof Element,a=c&&"INPUT"==b.tagName&&
|
||||
"submit"==b.type,d=c&&"SPAN"==b.tagName&&("f_nav-mini"==b.parentNode.id||"f_nav-fiche"==b.parentNode.id),c=c&&"SPAN"==b.tagName&&"f_nav-contact"==b.parentNode.id;if(!a&&!d&&!c&&!0!==b)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===b?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},function(a){if(0!=
|
||||
a.ModuleError)return!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(a||c)&&fContactManager.storageToFields())}sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');var g=function(b){api.send({path:"subject/search",name:sField.value},
|
||||
function(b){if(0!=b.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(b);var a="",d;for(d in b.results)a+="<li data-element data-id='"+d+"'>",a+="<div data-user><span>SUJET</span></div>",a+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+d+"'></span> </div>",a+="<div> <span data-prefix='Nom'>"+b.results[d].name+"</span> </div>",a+="<div> <span data-prefix='Cr\u00e9ation'>"+b.results[d].creation+
|
||||
"</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+d+"' "+(null!=b.results[d].phone?"checked":"")+" disabled><label for='s_"+d+"'>Cellulaire</label>",a+="</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+d+"' "+(null!=b.results[d].facebook?"checked":"")+" disabled><label for='s_"+d+"'>Facebook</label>",a+="</span> </div>",a+="</li>";sList.innerHTML=a})};sSubmit.addEventListener("click",g,!1);sField.addEventListener("keypress",function(b){13===b.keyCode&&g(b)},!1);fMatriceManager=
|
||||
fFicheManager=fMiniManager=fContactManager=fSubjectManager=pMatriceManager=pFicheManager=pMiniManager=pContactManager=pSubjectManager=null;include("/js/includes/input-phone-subject-min.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(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),
|
||||
$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach(e);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(e);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(e);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
|
||||
$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(e);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(e);var b=new ShortcutManager,c=!1;b.append("s+n+a+k+e",function(){c||(c=!0,pMatriceManager.snake())});b.listen();$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");
|
||||
pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),
|
||||
fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",
|
||||
var sField,sSubmit,sList,pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager,fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');
|
||||
var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c="",g;for(g in a.results)c+="<li data-element data-id='"+g+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+
|
||||
a.results[g].name+"</span> </div>",c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})};
|
||||
sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);pMatriceManager=pFicheManager=pMiniManager=pContactManager=pSubjectManager=null;
|
||||
function pDynamicUpdate(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",
|
||||
subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields())}fMatriceManager=fFicheManager=fMiniManager=fContactManager=fSubjectManager=null;
|
||||
function fDynamicUpdate(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",
|
||||
subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),(c||b)&&fContactManager.storageToFields())}
|
||||
include("/js/includes/input-phone-subject-min.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(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));
|
||||
pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));
|
||||
pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var a=new ShortcutManager,b=!1;a.append("s+n+a+k+e",function(){b||(b=!0,pMatriceManager.snake())});a.listen();$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");lsi.clear("p_friends");pSubjectManager.storageToFields();
|
||||
pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),
|
||||
matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",
|
||||
function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();
|
||||
pMatriceManager.storageToFields();e(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention",
|
||||
"La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(c,function(a){console.log(a);
|
||||
if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})});include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice-min.js",
|
||||
function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(f);fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(f);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));
|
||||
fMiniManager.attach(f);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(f);fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(f);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(b){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");
|
||||
lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),
|
||||
mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var c=$('[data-sublink="facebook"] #f_download-target');c.download="local-facebook-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));c.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(b){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",
|
||||
function(b){b.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(b){b={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};api.send(b,function(b){console.log(b);if(0!=b.ModuleError)return Notification.error("Erreur",b.ModuleError),!1;lsi.set("f_subject",0,b.local_data.subject);lsi["import"]("f_contacts",b.local_data.contacts);lsi["import"]("f_mini-fiches",b.local_data.mini);lsi["import"]("f_fiches",b.local_data.fiches);
|
||||
lsi.set("f_matrice",0,b.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();f(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",function(b){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),
|
||||
!1;b=lsi["export"]("f_mini-fiches");var c=0,a;for(a in b)if(!isNaN(a)&&(c++,!b[a].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+c+"</b> est incompl\u00e8te et/ou incorrecte"),!1;b=lsi["export"]("f_fiches");for(a in b)if(!b[a].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(a)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),
|
||||
mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})})},!1);
|
||||
pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,d;for(d in a)if(!isNaN(d)&&(b++,
|
||||
!a[d].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(d in a)if(!a[d].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(d)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;d={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};
|
||||
api.send(d,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})});
|
||||
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate);
|
||||
fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate);
|
||||
fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();
|
||||
Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download=
|
||||
"local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
|
||||
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
|
||||
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),
|
||||
!1;a=lsi["export"]("f_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
|
||||
!1;console.log(a)},!1)},!1)})})})})});function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}
|
||||
function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
|
||||
0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+
|
||||
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
|
||||
e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=(10+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+
|
||||
e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_p_"+e).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$("article.fiche-relation #contexte"+b+"_p_"+e).checked=!0,g=$$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"),
|
||||
13==b&&(g[2].value="autre"),d++)}
|
||||
function testRoutineFacebook(a){var b=lsi["export"]("f_contacts"),c=lsi["export"]("f_mini-fiches"),g=lsi["export"]("f_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#f_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_f_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=0,
|
||||
$("#reltype9_mini_f_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_f_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_f_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#f_nav-fiche [data-n="'+
|
||||
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&
|
||||
(b="0"+b),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="studies"]').value=b,a=d%9,8==a?($("#reltype10_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_f_"+e).checked=!0,$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="city"]').value=
|
||||
(10+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="cp"]').value=(1E4+d).toString(),$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="quartier"]').value=d,$("#loc"+["A","B","C","D"][Math.floor(d%4)]+"_f_"+e).checked=!0,b=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="duration"]'),
|
||||
b[0].value=d.toString(),b[1].value=1+d.toString(),b=d%14,$('section[data-sublink="facebook"] article.fiche-relation #contexte'+b+"_f_"+e).checked=!0,g=$$('section[data-sublink="facebook"] article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(g[0].value="internet"),12==b&&(g[1].value="association"),13==b&&(g[2].value="autre"),d++)};
|
||||
|
|
|
@ -3,7 +3,6 @@ var sField, sSubmit, sList,
|
|||
fSubjectManager, fContactManager, fMiniManager, fFicheManager, fMatriceManager;
|
||||
|
||||
|
||||
document.body.addEventListener('load', function(){
|
||||
|
||||
/*=========================================================*/
|
||||
/*=========== Gestion de la recherche de sujet ============*/
|
||||
|
@ -80,10 +79,10 @@ document.body.addEventListener('load', function(){
|
|||
/* [1] Initialisation des utilitaires et variables PHONE
|
||||
=========================================================*
|
||||
/* (1) Initialisation des managers */
|
||||
pSubjectManager = null,
|
||||
pContactManager = null,
|
||||
pMiniManager = null,
|
||||
pFicheManager = null,
|
||||
pSubjectManager = null;
|
||||
pContactManager = null;
|
||||
pMiniManager = null;
|
||||
pFicheManager = null;
|
||||
pMatriceManager = null;
|
||||
|
||||
|
||||
|
@ -161,11 +160,6 @@ document.body.addEventListener('load', function(){
|
|||
}
|
||||
|
||||
}
|
||||
fSubjectManager = null,
|
||||
fContactManager = null,
|
||||
fMiniManager = null,
|
||||
fFicheManager = null,
|
||||
fMatriceManager = null;
|
||||
|
||||
|
||||
|
||||
|
@ -173,6 +167,11 @@ document.body.addEventListener('load', function(){
|
|||
/* [2] Initialisation des utilitaires et variables FACEBEOOK
|
||||
=========================================================*
|
||||
/* (1) Initialisation des managers */
|
||||
fSubjectManager = null;
|
||||
fContactManager = null;
|
||||
fMiniManager = null;
|
||||
fFicheManager = null;
|
||||
fMatriceManager = null;
|
||||
|
||||
|
||||
|
||||
|
@ -268,8 +267,7 @@ document.body.addEventListener('load', function(){
|
|||
//TODO: Remettre version min
|
||||
include('/js/includes/input-phone-fiche.js', function(){
|
||||
include('/js/includes/input-phone-matrice-min.js', function(){
|
||||
|
||||
|
||||
|
||||
/* (1) Gestion du formulaire du sujet
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du manager du sujet */
|
||||
|
@ -937,6 +935,27 @@ document.body.addEventListener('load', function(){
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function testContactsPhone(){
|
||||
|
||||
for( var i = 0 ; i < 45 ; i++ ){
|
||||
|
||||
if( i%20 == 0 )
|
||||
lsi.set('p_contacts', i, { uid: i, username: 'contact-x' });
|
||||
else
|
||||
lsi.set('p_contacts', i, { uid: i, username: 'contact-'+i });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*=========================================================*/
|
||||
/*============= Routine de test CELLULAIRE ================*/
|
||||
/*=========================================================*/
|
||||
|
@ -1291,7 +1310,3 @@ document.body.addEventListener('load', function(){
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}, false);
|
||||
|
|
Loading…
Reference in New Issue