Gestion des `mini` vers les `fiches` de même contact (clones) + reste le `timestamp` à gérer entre le clonage mini/fiche et le clonage fiche/fiche

This commit is contained in:
xdrm-brackets 2016-10-17 10:14:50 +02:00
parent d253a7fb3c
commit 8ab7bde4b8
18 changed files with 249 additions and 126 deletions

View File

@ -1,6 +1,6 @@
{
"host" : "localhost",
"dbname" : "socioview",
"dbname" : "nxtic",
"user" : "php",
"password" : "Qt358nUdyeTxLDM8"
}

View File

@ -1,6 +1,6 @@
{
"host" : "xdrm.io",
"dbname" : "socioview",
"dbname" : "nxtic",
"user" : "php",
"password" : "QbzjZACndQM6NmuD"
}

View File

@ -171,6 +171,8 @@ inputFacebookFiche.prototype.add = function(objectData){
return false;
// {2} Si lié à un contact d'une autre étude, on utilise ses informations //
var importedFiche = '';
if( !isNaN(associatedContact.existing) ){
var existingData = lsi.get('f_friends', associatedContact.existing);
@ -206,6 +208,9 @@ inputFacebookFiche.prototype.add = function(objectData){
objectData.connect = existingData.connect;
objectData.connectSpecial = existingData.connectExtra;
objectData.freq = existingData.freq;
importedFiche = 'Contact importé: non modifiable!';
}else{
importedFiche = 'Contact importé (incomplet): modifiable partiellement!';
}
}
@ -213,6 +218,7 @@ inputFacebookFiche.prototype.add = function(objectData){
// {5} Création physique //
this.container.innerHTML += fFicheBuilder.build({
importedfiche: importedFiche,
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,

View File

@ -180,6 +180,10 @@ fFicheBuilder.setLayout(
"\t<h4 data-icon='a' class='color2'>@name</h4>\n"+
"\t<h5 class='nobold color0'>"+
"\t\t@importedfiche"+
"\t</h5>"+
"\t<h5 class='nobold color0'>\n"+
"\t\t<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeH_f_@uid' value='0'><label for='sexeH_f_@uid'>Homme</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeF_f_@uid' value='1'><label for='sexeF_f_@uid'>Femme</label>\n"+

View File

@ -332,19 +332,22 @@ inputPhoneFiche.prototype.storageToFields = function(){
inputPhoneFiche.prototype.sync = function(){
console.group('[phone.fiche] synchronisation');
/* (1) Initialisation
{ /* (1) Initialisation
---------------------------------------------------------*/
/* (1) On récupère tous les CONTACTS */
var contacts = lsi.export('p_contacts');
/* (2) Contiendra les uids des fiches qui seront crées */
var addedFicheUids = [];
var ficheData, contactData;
var ficheData, contactData, miniData;
}
/* (2) Mise à jour en fonction des contacts APRÈS SAISIE
{ /* (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 < 2*this.top_size ? lsi.keys('p_contacts').length : 2*this.top_size;
@ -376,8 +379,102 @@ inputPhoneFiche.prototype.sync = function(){
break;
}
}
/* (3) Gestion des fiches dupliquées
{ /* (3) Gestion des liens entre mini-fiches et fiches
---------------------------------------------------------*/
var hasSameUsername, hasSameLink;
ficheData = lsi.export('p_fiches');
miniData = lsi.export('p_mini-fiches');
// Pour chaque fiche
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 )
continue;
/* (3) On récupère la mini-fiche clone si existe */
var clone = null;
// Pour chaque mini-fiche
for( var i in miniData ){
// on récupère le contact associé (si on est dans `call`, celui dans la tranche avec `sms` / et inversement)
contactData = lsi.get('p_contacts', miniData[i].contact);
if( !contactData )
continue;
// meme pseudo
hasSameUsername = contactData.username.length > 0 && associatedContact.username === contactData.username;
// meme lien de contact
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 = miniData[i] );
if( clone !== null )
break;
}
/* (4) Si c'est le clone qui a été modifié en dernier, on ne fait rien */
var fiche_ts = ( ficheData[key].hasOwnProperty('timestamp') ) ? ficheData[key].timestamp : 0;
var mini_ts = ( clone instanceof Object && clone.hasOwnProperty('timestamp') ) ? clone.timestamp : 0;
if( clone === null )
continue;
/* (5.1) Si clone modifiée en dernier > On copie les données de la mini (CLONE) dans la FICHE */
var copied;
if( mini_ts > fiche_ts ){
console.warn('copying mini#'+clone.uid+' to fiche#'+ficheData[key].uid);
copied = ficheData[key];
copied.age = clone.age;
copied.sexe = clone.sexe;
copied.loc = clone.loc;
copied.reltype = clone.reltype;
copied.reltypeSpecial = clone.reltypeSpecial;
copied.timestamp = Date.now();
lsi.set('p_fiches', copied.uid, copied);
clone.timestamp = copied.timestamp;
lsi.set('p_mini-fiches', clone.uid, clone);
/* (5.2) Si fiche modifiée en dernier > On copie les données de la FICHE dans la mini (CLONE) */
}else if( fiche_ts > mini_ts ){
console.warn('copying fiche#'+ficheData[key].uid+' to mini#'+clone.uid);
copied = clone;
copied.age = ficheData[key].age;
copied.sexe = ficheData[key].sexe;
copied.loc = ficheData[key].loc;
copied.reltype = ficheData[key].reltype;
copied.reltypeSpecial = ficheData[key].reltypeSpecial;
copied.timestamp = Date.now();
lsi.set('p_mini-fiches', copied.uid, copied);
ficheData[key].timestamp = copied.timestamp;
lsi.set('p_fiches', ficheData[key].uid, ficheData[key]);
}
}
}
{ /* (4) Gestion des fiches dupliquées
---------------------------------------------------------*/
ficheData = lsi.export('p_fiches');
@ -407,9 +504,9 @@ inputPhoneFiche.prototype.sync = function(){
continue;
// meme pseudo
var hasSameUsername = contactData.username.length > 0 && associatedContact.username === contactData.username;
hasSameUsername = contactData.username.length > 0 && associatedContact.username === contactData.username;
// meme lien de contact
var hasSameLink = !isNaN(contactData.existing) && associatedContact.existing === contactData.existing;
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] );
@ -426,14 +523,24 @@ inputPhoneFiche.prototype.sync = function(){
if( clone === null || clone_ts > fiche_ts )
continue;
console.warn('copying fiche#'+ficheData[key].uid+' to fiche#'+clone.uid);
/* (5) On copie les données de la FICHE dans le CLONE */
var obj = ficheData[key];
obj.uid = clone.uid;
obj.timestamp = Date.now();
lsi.set('p_fiches', clone.uid, obj);
var copied = ficheData[key];
copied.uid = clone.uid;
copied.timestamp = Date.now();
lsi.set('p_fiches', copied.uid, copied);
ficheData[key].timestamp = copied.timestamp;
lsi.set('p_fiches', ficheData[key].uid, ficheData[key]);
}
}
console.groupEnd();
};

View File

@ -65,6 +65,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
var obj = {
uid: parseInt(deflated.uid),
contact: parseInt(deflated.uid),
sexe: deflated.sexe, // [0] Homme, [1] Femme, [2] Indéterminé
age: deflated.age,
studies: deflated.studies,
@ -292,7 +293,6 @@ inputPhoneMini.prototype.sync = function(){
var contactData = lsi.export('p_contacts');
var ficheData, miniData;
/* (2) On enregistre les contacts qui ne sont pas déja dans les FICHES */
ficheIndexes = lsi.keys('p_fiches');
@ -343,6 +343,8 @@ inputPhoneMini.prototype.sync = function(){
}
console.groupEnd();
};

View File

@ -4,13 +4,13 @@ reltypeSpecial:b.reltypeSpecial,city:b.city,quartier:b.quartier,cp:b.cp,loc:b.lo
inputFacebookFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;
a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];
a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:
this.defaultData.connect;var c=lsi.get("f_contacts",a.contact);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("f_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+=fFicheBuilder.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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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")};
this.defaultData.connect;var c=lsi.get("f_contacts",a.contact);if(!1===c)return!1;var b="";isNaN(c.existing)||(b=lsi.get("f_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,b="Contact import\u00e9: non modifiable!"):b="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=fFicheBuilder.build({importedfiche:b,name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],
contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});c=$('[data-sublink="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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")};
inputFacebookFiche.prototype.storageToFields=function(){console.group("[facebook.fiche] storage to fields");var a=lsi["export"]("f_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar();console.groupEnd()};
inputFacebookFiche.prototype.sync=function(){console.group("[facebook.fiche] synchronisation");var a=lsi["export"]("f_contacts"),c=[],b,d=lsi.keys("f_contacts").length<2*this.top_size?lsi.keys("f_contacts").length:2*this.top_size,e;for(e in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<d;)ficheUid++;c.push(ficheUid);a=lsi.get("f_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(e);lsi.set("f_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("f_fiches"),f;
for(f in a)if(d=lsi.get("f_contacts",a[f].contact)){c=null;e=parseInt(a[f].uid)<this.top_size;for(var g in a)if(!(e&&g<this.top_size||!e&&g>=this.top_size)&&(b=lsi.get("f_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}d=a[f].hasOwnProperty("timestamp")?a[f].timestamp:0;e=c instanceof Object&&c.hasOwnProperty("timestamp")?c.timestamp:0;null===c||e>d||(d=a[f],d.uid=c.uid,d.timestamp=

File diff suppressed because one or more lines are too long

View File

@ -1,21 +1,23 @@
function inputPhoneFiche(a,c){this.container=a;this.nav_container=c;this.top_size=10}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.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)return;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)}}console.groupEnd()};
function inputPhoneFiche(a,b){this.container=a;this.nav_container=b;this.top_size=10}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.group("[phone.fiche] fields to storage");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(),f=crc32(JSON.stringify(c)),d=lsi.get("p_fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==f)return;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:f};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)}}console.groupEnd()};
inputPhoneFiche.prototype.add=function(a){if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;
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 c=lsi.get("p_contacts",a.contact);if(!1===c)return!1;var b="";isNaN(c.existing)||(b=lsi.get("p_friends",c.existing),c.username=b.name,a.age=b.age,a.sexe=b.sexe,a.loc=b.dist,isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial=""),null!=b.studies2?(a.studies=b.studies2,a.job=b.job,a.famsit=b.famsit,a.city=b.city,a.cp=b.cp,a.quartier=b.quartier,a.duration[0]=b.duration[0],a.duration[1]=b.duration[1],a.context=b.context,a.contextSpecial=
b.contextExtra,a.connect=b.connect,a.connectSpecial=b.connectExtra,a.freq=b.freq,b="Contact import\u00e9: non modifiable!"):b="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:b,name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],
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.group("[phone.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();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,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=parseInt(a[f].uid)<this.top_size;for(var g in a)if(!(e&&g<this.top_size||!e&&g>=this.top_size)&&(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}d=a[f].hasOwnProperty("timestamp")?a[f].timestamp:0;e=c instanceof Object&&c.hasOwnProperty("timestamp")?c.timestamp:0;null===c||e>d||(d=a[f],d.uid=c.uid,d.timestamp=Date.now(),lsi.set("p_fiches",
c.uid,d))}console.groupEnd()};inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var d=parseInt(c[b]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
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||
this.defaultData.connect;var b=lsi.get("p_contacts",a.contact);if(!1===b)return!1;var c="";isNaN(b.existing)||(c=lsi.get("p_friends",b.existing),b.username=c.name,a.age=c.age,a.sexe=c.sexe,a.loc=c.dist,isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):(a.reltype=c.reltype,a.reltypeSpecial=""),null!=c.studies2?(a.studies=c.studies2,a.job=c.job,a.famsit=c.famsit,a.city=c.city,a.cp=c.cp,a.quartier=c.quartier,a.duration[0]=c.duration[0],a.duration[1]=c.duration[1],a.context=c.context,a.contextSpecial=
c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq,c="Contact import\u00e9: non modifiable!"):c="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:c,name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],
contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});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.group("[phone.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();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),b=[],c,f;f=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size;for(var d in a){for(ficheUid=0;-1<b.indexOf(ficheUid)&&ficheUid<f;)ficheUid++;b.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(d);lsi.set("p_fiches",ficheUid,a);if(b.length>=f)break}a=lsi["export"]("p_fiches");f=lsi["export"]("p_mini-fiches");
for(var e in a){var g=lsi.get("p_contacts",a[e].contact);if(g){var b=null,h;for(h in f)if(c=lsi.get("p_contacts",f[h].contact))if(d=0<c.username.length&&g.username===c.username,c=!isNaN(c.existing)&&g.existing===c.existing,(d||c)&&(b=f[h]),null!==b)break;d=a[e].hasOwnProperty("timestamp")?a[e].timestamp:0;g=b instanceof Object&&b.hasOwnProperty("timestamp")?b.timestamp:0;null!==b&&(g>d?(console.warn("copying mini#"+b.uid+" to fiche#"+a[e].uid),d=a[e],d.age=b.age,d.sexe=b.sexe,d.loc=b.loc,d.reltype=
b.reltype,d.reltypeSpecial=b.reltypeSpecial,d.timestamp=Date.now(),lsi.set("p_fiches",d.uid,d),b.timestamp=d.timestamp,lsi.set("p_mini-fiches",b.uid,b)):d>g&&(console.warn("copying fiche#"+a[e].uid+" to mini#"+b.uid),d=b,d.age=a[e].age,d.sexe=a[e].sexe,d.loc=a[e].loc,d.reltype=a[e].reltype,d.reltypeSpecial=a[e].reltypeSpecial,d.timestamp=Date.now(),lsi.set("p_mini-fiches",d.uid,d),a[e].timestamp=d.timestamp,lsi.set("p_fiches",a[e].uid,a[e])))}}a=lsi["export"]("p_fiches");for(e in a)if(g=lsi.get("p_contacts",
a[e].contact)){b=null;f=parseInt(a[e].uid)<this.top_size;for(h in a)if(!(f&&h<this.top_size||!f&&h>=this.top_size)&&(c=lsi.get("p_contacts",a[h].contact),h!=e&&c&&(d=0<c.username.length&&g.username===c.username,c=!isNaN(c.existing)&&g.existing===c.existing,(d||c)&&(b=a[h]),null!==b)))break;d=a[e].hasOwnProperty("timestamp")?a[e].timestamp:0;f=b instanceof Object&&b.hasOwnProperty("timestamp")?b.timestamp:0;null===b||f>d||(console.warn("copying fiche#"+a[e].uid+" to fiche#"+b.uid),d=a[e],d.uid=b.uid,
d.timestamp=Date.now(),lsi.set("p_fiches",d.uid,d),a[e].timestamp=d.timestamp,lsi.set("p_fiches",a[e].uid,a[e]))}console.groupEnd()};inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var 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 f=parseInt(b[c]);0==f&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>f&&c<b.length-1&&20<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+f+'" class="lc">'+(f%20+1)+"</span>&nbsp;&nbsp;":(20==f&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
f+'">'+(f%20+1)+"</span>")}for(var d in a)b=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))};
inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||
"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.group("[phone.fiche] attaching events");lsi.createDataset("p_fiches");this.storageToFields();this.handler=a;this.nav_container.addEventListener("click",function(a){this.nav(a.target);this.handler(a.target)}.bind(this),!1);console.groupEnd()};

View File

@ -1,6 +1,6 @@
function inputPhoneMini(a,c){this.container=a;this.nav_container=c}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:null,handler:null,defaultData:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,timestamp:0,valid:!1}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.group("[phone.mini] fields to storage");for(var a=$$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("p_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");b={uid:parseInt(b.uid),sexe:b.sexe,age:b.age,studies:b.studies,reltype:b.reltype,
reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length&&(console.log(diff(d,b,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),b.timestamp=Date.now());lsi.set("p_mini-fiches",b.uid,b)}}console.groupEnd()};
inputPhoneMini.prototype.fieldsToStorage=function(){console.group("[phone.mini] fields to storage");for(var a=$$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(b)),d=lsi.get("p_mini-fiches",b.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");b={uid:parseInt(b.uid),contact:parseInt(b.uid),sexe:b.sexe,age:b.age,studies:b.studies,
reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,loc:b.loc,unknown:null!=b.unknown,hash:e};b.valid=this.check(b);0<diff(d,b,["hash","valid","timestamp"]).length&&(console.log(diff(d,b,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),b.timestamp=Date.now());lsi.set("p_mini-fiches",b.uid,b)}}console.groupEnd()};
inputPhoneMini.prototype.add=function(a){if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown;var c=lsi.get("p_contacts",
a.uid);if(!1===c)return!1;if(!isNaN(c.existing)){var b=lsi.get("p_friends",c.existing);c.username=b.name;a.contact=c.uid;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.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=pMiniFicheBuilder.build({name:c.username,countcall:c.countcall,countsms:c.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="phone"] article.mini-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.mini-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.mini-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==

View File

@ -6,10 +6,12 @@
class DataBase{
/* ATTRIBUTS STATIQUES */
public static $config_path = [
public static function config_path(){
return [
'local' => __ROOT__.'/config/database-local.json',
'remote' => __ROOT__.'/config/database.json'
];
}
private static $pdo;
private static $instance;
@ -49,9 +51,9 @@
// chargement de la configuration du server SQL
if( !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
$conf = json_decode( file_get_contents(self::$config_path['local']), true );
$conf = json_decode( file_get_contents(self::config_path()['local']), true );
else
$conf = json_decode( file_get_contents(self::$config_path['remote']), true );
$conf = json_decode( file_get_contents(self::config_path()['remote']), true );
// creation de l'instance en fonction des parametres
self::$instance = new DataBase($conf['host'], $conf['dbname'], $conf['user'], $conf['password']);

View File

@ -7,7 +7,7 @@
class MenuManager{
// Constantes
public static $config_path = __ROOT__.'/config/menu.json';
public static function config_path(){ return __ROOT__.'/config/menu.json'; }
// Attributs prives utiles (initialisation)
@ -27,7 +27,7 @@
/* [0] On met a jour la configuration
=========================================================*/
// Categories specifiees
$this->categories = json_decode( file_get_contents(self::$config_path), true );
$this->categories = json_decode( file_get_contents(self::config_path()), true );
// Gestion de l'erreur de parsage
if( $this->categories == null ){

View File

@ -8,7 +8,7 @@
class ModuleRequest{
// Constantes
public static $config_path = __ROOT__.'/config/modules.json';
public static function config_path(){ return __ROOT__.'/config/modules.json'; }
public static $default_options = [
'download' => false
];
@ -48,7 +48,7 @@
/* [0] On met a jour la configuration
=========================================================*/
// Modules specifies
$this->modules = json_decode( file_get_contents(self::$config_path), true );
$this->modules = json_decode( file_get_contents(self::config_path()), true );
// Gestion de l'erreur de parsage
if( $this->modules == null ){

View File

@ -11,7 +11,7 @@
// CLASSE MAITRE
class Table{
private static $database = 'stefproject';
private static $database = 'logauth';
/* RENVOIE LES DONNEES D'UNE TABLE
@ -44,7 +44,7 @@
/* (3) Si n'existe pas, on renvoie une erreur */
if( !in_array($table_name, $tables) )
return null;
throw new \Exception('[*] Unknown table.');
/* (4) On enregistre les données */
$schema['table'] = $table_name;
@ -75,7 +75,7 @@
/* (3) Si on trouve rien, on envoie une erreur */
if( !is_array($columns) || count($columns) == 0 )
return null;
throw new \Exception('[*] Cannot fetch columns');
/* (4) On enregistre les colonnes */
$schema['columns'] = $columns;
@ -86,6 +86,8 @@
=========================================================*/
/* (1) On récupère le texte du 'CREATE TABLE' */
$getCreateTable = Database::getPDO()->query("show create table ".$table_name);
if( is_bool($getCreateTable) )
throw new \Exception('[*] Cannot fetch constrains');
$create_table = $getCreateTable->fetch()['Create Table'];
/* (2) On découpte en lignes */

0
automate.php → test/automate.php Executable file → Normal file
View File

View File

@ -227,8 +227,6 @@ if( $getAllR->error == ManagerError::Success )
<!-- GESTION DE L'AJOUT DES CONTACTS -->
<span data-space></span>
<h5 data-text="Renseigner au moins un des nominatifs pour chaque amis. (pseudo, prénom et/ou nom)"></h5>
<span data-space></span>
<div class='arrow-container line' id='f_nav-contact'></div>
<article class='contact-panel'>