diff --git a/public_html/js/action-script.js b/public_html/js/action-script.js index 7c978ac..ea8082d 100644 --- a/public_html/js/action-script.js +++ b/public_html/js/action-script.js @@ -1,6 +1,4 @@ -var DOM, pageManager, api, Notification, global_start_timestamp; - -global_start_timestamp = Date.now(); +var DOM, pageManager, api, Notification; /* [1] Toggle du sub-menu-side <-> navigation diff --git a/public_html/js/includes/input-phone-contact.js b/public_html/js/includes/input-phone-contact.js index be92bd3..d5e107b 100644 --- a/public_html/js/includes/input-phone-contact.js +++ b/public_html/js/includes/input-phone-contact.js @@ -8,10 +8,10 @@ function inputPhoneContact(container, navContainer){ /* [1] Attributs =========================================================*/ inputPhoneContact.prototype = { - container: this.container, // Conteneur des formulaires de contact + container: this.container, // Conteneur des formulaires de contact nav_container: this.nav_container, // Conteneur de la navigation entre les formulaires - selected: 0, // UID du permier des contacts sélectionnés (10 par 10) - handler: null // Fonction pour l'enregistrement et la synchronisation des données + selected: 0, // UID du permier des contacts sélectionnés (10 par 10) + handler: null // Fonction pour l'enregistrement et la synchronisation des données }; @@ -74,6 +74,9 @@ inputPhoneContact.prototype.check = function(deflated){ return false; } + // On trim l'username + deflated.username = deflated.username.trim(); + /* (2) On vérifie la validité du formulaire ---------------------------------------------------------*/ var isValid = !isNaN(deflated.existing) || deflated.username.length > 0; diff --git a/public_html/js/includes/input-phone-fiche.js b/public_html/js/includes/input-phone-fiche.js index e3d2fe2..b151268 100644 --- a/public_html/js/includes/input-phone-fiche.js +++ b/public_html/js/includes/input-phone-fiche.js @@ -68,7 +68,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){ // {5} On récupère et met en forme les valeurs du deflater // // Si le hash est le même, on ne fait rien - if( existingData.hash != null && existingData.hash == deflatedHash ) + if( existingData.hash != null && existingData.hash == deflatedHash || existingData.hash === 0 ) return; @@ -103,12 +103,12 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){ if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); - console.warn('> FICHE UPDATE'); - // console.warn('fiche-ts', existingData.timestamp, obj.timestamp); obj.timestamp = Date.now(); + console.warn('> FICHE UPDATE ('+(obj.timestamp-input_ts)+')'); + }else if( existingData['timestamp'] == undefined ){ - // console.warn('fiche-refresh'); - obj.timestamp = this.defaultData.timestamp; + console.warn('fiche#'+obj.uid); + obj.timestamp = Date.now(); } /* (7) On enregistre les données dans le 'localStorage' */ @@ -388,188 +388,143 @@ inputPhoneFiche.prototype.sync = function(){ { /* (3) Gestion des liens entre mini-fiches et fiches ---------------------------------------------------------*/ - var hasSameUsername, hasSameLink; + var originalContact, cloneContact, + hasSameUsername, hasSameLink, + copied; + + var alreadyDoneUsername = {}, + alreadyDoneExisting = {}; ficheData = lsi.export('p_fiches'); miniData = lsi.export('p_mini-fiches'); // Pour chaque mini-fiche - for( var key in miniData ){ + for( var key in ficheData ){ /* (1) On récupère le contact associé */ - var associatedContact = lsi.get('p_contacts', miniData[key].contact); + originalContact = lsi.get('p_contacts', ficheData[key].contact); - // Si erreur, on passe au suivant - if( !associatedContact ) + // {1.1} On vérifie que le contact n'a pas déja été traité // + if( originalContact.username.length > 0 && alreadyDoneUsername[originalContact.username] != undefined + || originalContact.username.length == 0 && alreadyDoneExisting[originalContact.existing] != undefined ) continue; - /* (3) On récupère les/la fiche(s) clone(s) si existe */ - var clone = []; + // {1.2} On enregistre username || existing // + if( originalContact.username.length > 0 ) alreadyDoneUsername[originalContact.username] = 0; + else alreadyDoneExisting[originalContact.existing] = 0; - // Pour chaque fiche + // Si erreur, on passe au suivant + if( !originalContact ) + continue; + + /* (3) On récupère la liste des fiches/mini-fiches de même contact*/ + var clone = [ + [ 'fiche', ficheData[key] ] + ]; + + // {3.1} On récupère les fiches de même contact // for( i in ficheData ){ // 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', ficheData[i].contact); + cloneContact = lsi.get('p_contacts', ficheData[i].contact); - if( i == key || !contactData ) + if( i == key || !cloneContact ) continue; // meme pseudo - hasSameUsername = contactData.username.length > 0 && associatedContact.username === contactData.username; + hasSameUsername = cloneContact.username.length > 0 && originalContact.username === cloneContact.username; // meme lien de contact - hasSameLink = !isNaN(contactData.existing) && associatedContact.existing === contactData.existing; + hasSameLink = !isNaN(cloneContact.existing) && originalContact.existing === cloneContact.existing; // si ont le même contact, alors on enregistre le clone (sauf si la même fiche) - ( hasSameUsername || hasSameLink ) && clone.push( ficheData[i] ); + ( hasSameUsername || hasSameLink ) && clone.push( ['fiche', ficheData[i]] ); } - // si aucun clone, on quitte - if( clone.length === 0 ) + // {3.2} On récupère les mini-fiches de même contact // + for( i in miniData ){ + + // on récupère le contact associé (si on est dans `call`, celui dans la tranche avec `sms` / et inversement) + cloneContact = lsi.get('p_contacts', miniData[i].contact); + + // meme pseudo + hasSameUsername = cloneContact.username.length > 0 && originalContact.username === cloneContact.username; + // meme lien de contact + hasSameLink = !isNaN(cloneContact.existing) && originalContact.existing === cloneContact.existing; + + // si ont le même contact, alors on enregistre le clone (sauf si la même fiche) + ( hasSameUsername || hasSameLink ) && clone.push( ['mini', miniData[i]] ); + + } + + // {3.3} si aucun clone, on quitte // + if( clone.length === 1 ) continue; /* (4) On récupère le modèle (dernier modifié) */ - var mini_ts = ( miniData[key].hasOwnProperty('timestamp') ) ? miniData[key].timestamp : 0; + var clones_ts = []; // contiendra les temps des clones - var clones_ts = []; // contiendra les temps des clones - var mini_update = true; // true si dernier modifié - - for( i in clone ){ - clones_ts[i] = clone[i].hasOwnProperty('timestamp') ? clone[i].timestamp : 0; - mini_update = mini_update && mini_ts > clones_ts[i]; - } + for( i in clone ) + clones_ts[i] = clone[i][1].hasOwnProperty('timestamp') ? clone[i][1].timestamp : 0; var last_index = clones_ts.indexOf( Math.max.apply(Math, clones_ts) ); + /* (5) On copie le dernier modifié dans les clones */ + for( i in clone ){ + + // excepté le dernier modifié + if( i == last_index ) + continue; + /* (5.1) fiche vers fiche */ + if( clone[i][0] == clone[last_index][0] ){ - - - /* (5.1) Si mini est le modèle -> On copie les données de MINI dans les CLONES */ - var copied; - if( mini_update ){ - - for( i in clone ){ - - console.warn('copying mini#'+miniData[key].uid+' to fiche#'+clone[i].uid, mini_ts-global_start_timestamp, clones_ts[i]-global_start_timestamp); - copied = clone[i]; - copied.age = miniData[key].age; - copied.sexe = miniData[key].sexe; - copied.loc = miniData[key].loc; - copied.reltype = miniData[key].reltype; - copied.reltypeSpecial = miniData[key].reltypeSpecial; - // copied.timestamp = Date.now(); + console.warn('copying fiche#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); + copied = clone[last_index][1]; + copied.uid = clone[i][1].uid; + // copied.timestamp = Date.now(); + copied.hash = 0 lsi.set('p_fiches', copied.uid, copied); - } + /* (5.2) fiche vers mini */ + }else if( clone[last_index][0] == 'fiche' ){ - // clone.timestamp = copied.timestamp+1; - // lsi.set('p_mini-fiches', clone.uid, clone); + console.warn('copying fiche#'+clone[last_index][1].uid+' to mini#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); + copied = clone[i][1]; + copied.age = clone[last_index][1].age; + copied.sexe = clone[last_index][1].sexe; + copied.loc = clone[last_index][1].loc; + copied.reltype = clone[last_index][1].reltype; + copied.reltypeSpecial = clone[last_index][1].reltypeSpecial; + copied.timestamp = Date.now(); + lsi.set('p_mini-fiches', copied.uid, copied); - /* (5.2) Si un clone est le modèle > On copie les données de la FICHE dans la fiche (autres clones) et dans MINI */ - }else if( last_index > -1 ){ + /* (5.3) mini vers fiche */ + }else{ - // {1} On copie dans MINI // - console.warn('copying fiche#'+clone[last_index].uid+' to mini#'+miniData[key].uid, clones_ts[last_index]-global_start_timestamp, mini_ts-global_start_timestamp); - copied = miniData[key]; - copied.age = clone[last_index].age; - copied.sexe = clone[last_index].sexe; - copied.loc = clone[last_index].loc; - copied.reltype = clone[last_index].reltype; - copied.reltypeSpecial = clone[last_index].reltypeSpecial; - // copied.timestamp = Date.now(); - lsi.set('p_mini-fiches', copied.uid, copied); - - // {2} On copie dans les autres fiches // - for( i in clone ){ - // sauf le modele - if( i == last_index ) continue; - - console.warn('copying fiche#'+clone[last_index].uid+' to fiche#'+clone[i].uid, clones_ts[last_index]-global_start_timestamp, clones_ts[i]-global_start_timestamp); - copied = clone[last_index]; - copied.uid = clone[i].uid; + console.warn('copying mini#'+clone[last_index][1].uid+' to fiche#'+clone[i][1].uid, clones_ts[last_index]-input_ts, clones_ts[i]-input_ts); + copied = clone[i][1]; + copied.age = clone[last_index][1].age; + copied.sexe = clone[last_index][1].sexe; + copied.loc = clone[last_index][1].loc; + copied.reltype = clone[last_index][1].reltype; + copied.reltypeSpecial = clone[last_index][1].reltypeSpecial; // copied.timestamp = Date.now(); + copied.hash = 0; lsi.set('p_fiches', copied.uid, copied); } } + } } - // { /* (4) 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 ) - // continue; - // - // /* (3) On récupère la/les autre(s) fiche(s) (clone(s)) */ - // var clone = null; - // var inCall = parseInt( ficheData[key].uid ) < this.top_size; // vrai si dans les APPELS, sinon dans les SMS - // - // for( var i in ficheData ){ - // - // // si on est pas dans le bonne tranche, on passe au suivant - // if( inCall && i < this.top_size || !inCall && i >= this.top_size ) - // continue; - // - // // 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', ficheData[i].contact); - // - // if( i == key || !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 = ficheData[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 clone_ts = ( clone instanceof Object && clone.hasOwnProperty('timestamp') ) ? clone.timestamp : 0; - // if( clone === null || clone_ts > fiche_ts ) - // continue; - // - // console.warn('copying fiche#'+ficheData[key].uid+' to fiche#'+clone.uid, fiche_ts-global_start_timestamp, clone_ts-global_start_timestamp); - // - // - // /* (5) On copie les données de la FICHE dans le CLONE */ - // 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(); }; diff --git a/public_html/js/includes/input-phone-mini.js b/public_html/js/includes/input-phone-mini.js index 13f8584..70e51f9 100644 --- a/public_html/js/includes/input-phone-mini.js +++ b/public_html/js/includes/input-phone-mini.js @@ -60,8 +60,6 @@ inputPhoneMini.prototype.fieldsToStorage = function(){ if( existingData != null && existingData.hash != null && existingData.hash == deflatedHash ) return; - console.warn('> MINI UPDATE'); - var obj = { uid: parseInt(deflated.uid), @@ -82,14 +80,12 @@ inputPhoneMini.prototype.fieldsToStorage = function(){ // On met à jour la date de modification, si on a pas qu'@uid de différent if( diff(existingData, obj, ['hash', 'valid', 'timestamp']).length > 0 ){ console.log( diff(existingData, obj, ['hash', 'valid', 'timestamp']) ); - console.warn('> MINI UPDATE'); - // console.warn('mini-ts', existingData.timestamp, obj.timestamp); - obj.timestamp = Date.now(); - }else if( existingData['timestamp'] == undefined ){ - // console.warn('mini-refresh'); - obj.timestamp = this.defaultData.timestamp; - } + obj.timestamp = Date.now(); + console.warn('> MINI UPDATE ('+(obj.timestamp-input_ts)+')'); + + }else if( existingData['timestamp'] == undefined ) + obj.timestamp = Date.now(); /* (9) On enregistre les données dans le 'localStorage' */ diff --git a/public_html/js/includes/min/input-phone-contact.js b/public_html/js/includes/min/input-phone-contact.js index 6d2dd91..a200fe7 100644 --- a/public_html/js/includes/min/input-phone-contact.js +++ b/public_html/js/includes/min/input-phone-contact.js @@ -1,6 +1,6 @@ function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.callRange=function(a){return 0<=a&&20>a};inputPhoneContact.prototype.smsRange=function(a){return 20<=a&&40>a}; inputPhoneContact.prototype.sameContact=function(a,b,c,d){var e=null,e=null;if("call"===d)e={min:0,max:19};else if("sms"===d)e={min:29,max:39};else if("mini"===d)e={min:40,max:Infinity};else return!1;d=e.min;for(var f=e.max;d"+b[c].name+"\n";this.container.innerHTML+=pContactBuilder.build(a);c=$('[data-sublink="phone"] article.contact-panel .new-contact input[data-name="uid"][value="'+a.uid+'"] ~ span select[data-name="existing"]>option[value="'+ diff --git a/public_html/js/includes/min/input-phone-fiche.js b/public_html/js/includes/min/input-phone-fiche.js index f575ce8..4860f9f 100644 --- a/public_html/js/includes/min/input-phone-fiche.js +++ b/public_html/js/includes/min/input-phone-fiche.js @@ -1,6 +1,7 @@ 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 FICHE UPDATE"),b.timestamp=Date.now()):void 0==d.timestamp&&(b.timestamp=this.defaultData.timestamp);lsi.set("p_fiches",b.uid,b)}}console.groupEnd()}; +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 FICHE UPDATE ("+(b.timestamp-input_ts)+")")):void 0==h.timestamp&&(console.warn("fiche#"+b.uid),b.timestamp= +Date.now());lsi.set("p_fiches",b.uid,b)}}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: @@ -12,11 +13,12 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(c=0;cinput[type="radio"][data-name="loc"]');for(c=0;cinput[type="radio"][data-name="context"]');for(c=0;cinput[type="radio"][data-name="freq"]');for(c=0;cinput[type="radio"][data-name="connect"]');for(c=0;c=d)break}var a=lsi["export"]("p_fiches"),c=lsi["export"]("p_mini-fiches"), -g;for(g in c){var h=lsi.get("p_contacts",c[g].contact);if(h){d=[];for(e in a)b=lsi.get("p_contacts",a[e].contact),e!=g&&b&&(k=0h[e];b=h.indexOf(Math.max.apply(Math,h));if(f)for(e in d)console.warn("copying mini#"+c[g].uid+" to fiche#"+ -d[e].uid,k-global_start_timestamp,h[e]-global_start_timestamp),f=d[e],f.age=c[g].age,f.sexe=c[g].sexe,f.loc=c[g].loc,f.reltype=c[g].reltype,f.reltypeSpecial=c[g].reltypeSpecial,lsi.set("p_fiches",f.uid,f);else if(-1 span.active'),b=0;bAPPELS");20>e&&b'+(e%20+1)+"  ":(20==e&&(this.nav_container.innerHTML+='
   SMS   '),this.nav_container.innerHTML+=''+(e%20+1)+"")}for(var d in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=c&&(!0===a[d].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; +inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,g=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,h;for(h in a){for(ficheUid=0;-1=g)break}var d,e,k,g={};h={};var a=lsi["export"]("p_fiches"), +c=lsi["export"]("p_mini-fiches"),l;for(l in a)if(d=lsi.get("p_contacts",a[l].contact),!(0 span.active'),b=0;bAPPELS");20>g&&b'+(g%20+1)+"  ":(20==g&&(this.nav_container.innerHTML+='
   SMS   '),this.nav_container.innerHTML+=''+(g%20+1)+"")}for(var h in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[h].uid+'"]'),null!=c&&(!0===a[h].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]))&&0a.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()}; diff --git a/public_html/js/includes/min/input-phone-mini.js b/public_html/js/includes/min/input-phone-mini.js index 1a9cbd7..b7e7a64 100644 --- a/public_html/js/includes/min/input-phone-mini.js +++ b/public_html/js/includes/min/input-phone-mini.js @@ -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 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 MINI UPDATE"),b.timestamp=Date.now()):void 0==d.timestamp&&(b.timestamp=this.defaultData.timestamp);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 MINI UPDATE ("+(b.timestamp-input_ts)+")")):void 0==d.timestamp&&(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 Objet à cloner +* +* @return clone Objet identique (cloné) +* +* Note: prise en compte des primitifs && tableaux uniquement +* +*/ +// Object.prototype.clone = function(){ +// return this; +// }; + + /* DEFINITION DES FORMATS UTILES POUR INPUT-CHECKER * */ diff --git a/public_html/js/min/action-script.js b/public_html/js/min/action-script.js index a1d3ce1..65ab563 100644 --- a/public_html/js/min/action-script.js +++ b/public_html/js/min/action-script.js @@ -1,6 +1,5 @@ -var DOM,pageManager,api,Notification,global_start_timestamp;global_start_timestamp=Date.now(); -var navSubMenu=function(a){var c=$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+a+'"]'):b,b=null==b?$("#MENU-SIDE > span[data-link="+pageManager.page+"] + div.sub > span[data-sublink]"):b;if(null==b)return!1;null!=c&&c.remClass("active");c=$$("#CONTAINER > section[data-sublink].active");for(a= -0;a section[data-sublink="'+b.getData("sublink")+'"]'),a=0;a #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b=(b="string"==typeof a?$('#WRAPPER > #MENU-SIDE > span[data-link="'+ +var DOM,pageManager,api,Notification,navSubMenu=function(a){var c=$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+a+'"]'):b,b=null==b?$("#MENU-SIDE > span[data-link="+pageManager.page+"] + div.sub > span[data-sublink]"):b;if(null==b)return!1;null!=c&&c.remClass("active");c=$$("#CONTAINER > section[data-sublink].active"); +for(a=0;a section[data-sublink="'+b.getData("sublink")+'"]'),a=0;a #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b=(b="string"==typeof a?$('#WRAPPER > #MENU-SIDE > span[data-link="'+ a+'"]'):b)||$('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]');if(null==b)return!1;c&&c.remClass("active");b&&b.addClass("active");b.getData("link")&&(DOM.HEADER.addClass("loading"),a=function(){1<=pageManager.vars.length&&null!=$('#CONTAINER > section[data-sublink="'+pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);var a=$("#MENU-SIDE > span[data-link="+pageManager.page+"] + div.sub");null!=a&&a.addEventListener("click",function(a){for(a=a.target;a!= document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1);DOM.HEADER.remClass("loading")},pageManager.page!=b.getData("link")&&pageManager.setPage(b.getData("link")),pageManager.activeXHR?pageManager.activeXHR.addEventListener("loadend",a,!1):a.call())},refresher=function(){navSubMenu()};DOM={WRAPPER:$("body > #WRAPPER"),HEADER:$("body > #WRAPPER > #HEADER"),MENUSIDE:$("body > #WRAPPER > #MENU-SIDE"),CONTAINER:$("body > #WRAPPER > #CONTAINER")};api=new APIClass("/api/"); Notification=new NotificationClass($("#notification-container"));Notification.defaultTimeout=4E3; diff --git a/public_html/view/js/input.js b/public_html/view/js/input.js index 1c20003..f6e563f 100644 --- a/public_html/view/js/input.js +++ b/public_html/view/js/input.js @@ -11,6 +11,7 @@ var sField, sSubmit, sList, fFicheManager = null, fMatriceManager = null; +var input_ts = Date.now(); /*=========================================================*/ /*=========== Gestion de la recherche de sujet ============*/ @@ -680,6 +681,10 @@ var pDynamicUpdate = function(target){ /* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */ pContactManager.storageToFields(); + /* (9) On met à jour les barres de navigation */ + pMiniManager.updateNavBar(); + pFicheManager.updateNavBar(); + }); @@ -690,7 +695,11 @@ var pDynamicUpdate = function(target){ pFicheManager.storageToFields(); pMatriceManager.storageToFields(); - /* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */ + /* (9) On met à jour les barres de navigation */ + pMiniManager.updateNavBar(); + pFicheManager.updateNavBar(); + + /* (10) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */ ( isSaveButton || isNavContact ) && pContactManager.storageToFields(); } diff --git a/public_html/view/js/min/input.js b/public_html/view/js/min/input.js index 9575729..262d4d5 100644 --- a/public_html/view/js/min/input.js +++ b/public_html/view/js/min/input.js @@ -1,4 +1,4 @@ -var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null;sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]'); +var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null,input_ts=Date.now();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.push("
  • "),c.push("
    SUJET
    "),c.push("
    "),c.push("
    "+ a.results[g].name+"
    "),c.push("
    "+a.results[g].creation+"
    "),c.push("
    "),c.push("
    "),c.push("
    "),c.push("
    "),c.push("
  • ");sList.innerHTML= c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1); @@ -21,10 +21,10 @@ pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.f "La fiche compl\u00e8te "+(parseInt(c)+1)+" est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",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;Notification.success("OK","L'identifiant du sujet est "+a.subject_id+" ! Tout s'est bien d\u00e9roul\u00e9.", 1E4);console.log(a)},!1)},!1),console.groupEnd())};include("/js/includes/input-facebook-subject.js",function(){fLoaded[0]=1;facebookRoutine()});include("/js/includes/input-facebook-contact.js",function(){fLoaded[1]=1;facebookRoutine()});include("/js/includes/input-facebook-mini.js",function(){fLoaded[2]=1;facebookRoutine()});include("/js/includes/input-facebook-fiche.js",function(){fLoaded[3]=1;facebookRoutine()});include("/js/includes/input-facebook-matrice.js",function(){fLoaded[4]=1;facebookRoutine()}); var pDynamicUpdate=function(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.groupEnd();console.groupEnd();console.group("[phone] 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 console.groupEnd(),!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());console.groupEnd()}, -fDynamicUpdate=function(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.groupEnd();console.groupEnd();console.group("[facebook] 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 console.groupEnd(),!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());console.groupEnd()}; -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})} +pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return console.groupEnd(),!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields();pMiniManager.updateNavBar();pFicheManager.updateNavBar()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),pMiniManager.updateNavBar(), +pFicheManager.updateNavBar(),(c||b)&&pContactManager.storageToFields());console.groupEnd()},fDynamicUpdate=function(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.groupEnd();console.groupEnd();console.group("[facebook] 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 console.groupEnd(),!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());console.groupEnd()};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="'+