Gestion du log propre

This commit is contained in:
xdrm-brackets 2016-10-10 10:58:44 +02:00
parent 74afa03eed
commit d1aed90146
12 changed files with 1064 additions and 976 deletions

View File

@ -90,7 +90,7 @@ inputPhoneContact.prototype.check = function(deflated){
/* [3] Gestion de l'enregistrement des formulaires de contact
=========================================================*/
inputPhoneContact.prototype.fieldsToStorage = function(){
console.log('CONTACTS: FIELDS TO STORAGE');
console.group('[phone.contact] fields to storage');
// {1} Pour chaque formulaire de contact présent //
var visibleContacts = $$('[data-sublink="phone"] article.contact-panel .new-contact');
@ -123,6 +123,7 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
}
console.groupEnd('[phone.contact] fields to storage');
};
@ -141,8 +142,6 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
*
*/
inputPhoneContact.prototype.add = function(objectData){
console.log('CONTACTS: ADD');
// Si pas d'uid, on quitte
if( objectData == null || objectData.uid == null || isNaN(objectData.uid) )
return false
@ -192,7 +191,7 @@ inputPhoneContact.prototype.add = function(objectData){
/* [5] Gestion de l'affichage depuis le 'localStorage'
=========================================================*/
inputPhoneContact.prototype.storageToFields = function(){
console.log('CONTACTS: STORAGE TO FIELDS');
console.group('[phone.contact] storage to fields');
// {1} Pour chaque contact du 'localStorage' //
var contactKeys = lsi.keys('p_contacts');
@ -215,6 +214,8 @@ inputPhoneContact.prototype.storageToFields = function(){
/* (3) On met à jour la barre de navigation */
this.updateNavBar();
console.groupEnd('[phone.contact] storage to fields');
};
@ -280,7 +281,7 @@ inputPhoneContact.prototype.updateNavBar = function(){
/* [8] Point d'amorçage de la gestion des contacts
=========================================================*/
inputPhoneContact.prototype.attach = function(handler){
console.log('CONTACTS: ATTACH');
console.group('[phone.contact] attaching events');
/* (1) On initialise le jeu de données */
lsi.createDataset('p_contacts');
@ -301,4 +302,6 @@ inputPhoneContact.prototype.attach = function(handler){
ptr.handler(e.target);
}, false);
console.groupEnd('[phone.contact] attaching events');
};

View File

@ -39,7 +39,7 @@ inputPhoneFiche.prototype = {
/* [2] Gestion de l'enregistrement des formulaires fiche fiches relation
=========================================================*/
inputPhoneFiche.prototype.fieldsToStorage = function(){
console.log('FICHE: FIELDS TO STORAGE');
console.group('[phone.fiche] fields to storage');
// {1} Pour chaque formulaire de contact présent //
var existingFiches = $$('[data-sublink="phone"] article.relation-panel .fiche-relation');
@ -109,6 +109,9 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
/* (7) On enregistre les données dans le 'localStorage' */
lsi.set('p_fiches', obj.uid, obj);
}
console.groupEnd('[phone.fiche] fields to storage');
};
@ -127,7 +130,7 @@ inputPhoneFiche.prototype.fieldsToStorage = function(){
*
*/
inputPhoneFiche.prototype.add = function(objectData){
console.log('FICHE: ADD');
// console.log('FICHE: ADD');
// Si pas d'UID ou d'UID de contact, on retourne une erreur
if( objectData.uid == null || isNaN(objectData.uid) || objectData.contact == null || isNaN(objectData.contact) )
@ -317,7 +320,7 @@ inputPhoneFiche.prototype.add = function(objectData){
/* [4] Gestion de l'affichage depuis le 'localStorage'
=========================================================*/
inputPhoneFiche.prototype.storageToFields = function(){
console.log('FICHE: STORAGE TO FIELDS');
console.group('[phone.fiche] storage to fields');
// {1} Pour chaque contact du 'localStorage' //
var ficheData = lsi.export('p_fiches');
@ -333,6 +336,8 @@ inputPhoneFiche.prototype.storageToFields = function(){
// {4} On met à jour la navigation //
this.updateNavBar();
console.groupEnd('[phone.fiche] storage to fields');
};
@ -348,7 +353,7 @@ inputPhoneFiche.prototype.storageToFields = function(){
/* [5] Synchronisation des CONTACT vers les MINI fiches
=========================================================*/
inputPhoneFiche.prototype.sync = function(){
console.log('FICHE: SYNC');
console.group('[phone.fiche] Synchronisation');
/* (1) Initialisation
---------------------------------------------------------*/
@ -448,6 +453,8 @@ inputPhoneFiche.prototype.sync = function(){
}
console.groupEnd('[phone.fiche] Synchronisation');
};
@ -623,7 +630,7 @@ inputPhoneFiche.prototype.check = function(ficheData){
/* [9] Point d'amorçage de la gestion des contacts
=========================================================*/
inputPhoneFiche.prototype.attach = function(handler){
console.log('FICHE: ATTACH');
console.group('[phone.fiche] attaching events');
/* (1) On initialise le jeu de données */
lsi.createDataset('p_fiches');
@ -644,4 +651,6 @@ inputPhoneFiche.prototype.attach = function(handler){
ptr.handler(e.target);
}, false);
console.groupEnd('[phone.fiche] attaching events');
};

View File

@ -14,7 +14,7 @@ inputPhoneMatrice.prototype = {
/* [2] Gestion de l'enregistrement de la matrice
=========================================================*/
inputPhoneMatrice.prototype.fieldsToStorage = function(){
console.log('MATRICE: FIELDS TO STORAGE');
console.group('[phone.matrice] fields to storage');
// {1} On initialise notre deflater pour récupérer les valeurs //
@ -59,6 +59,9 @@ inputPhoneMatrice.prototype.fieldsToStorage = function(){
// idB: [idX, idY], # B connait X et Y (et réciproquement)
// ...
//
console.groupEnd('[phone.matrice] fields to storage');
};
@ -74,7 +77,7 @@ inputPhoneMatrice.prototype.fieldsToStorage = function(){
/* [4] Gestion de l'affichage depuis le 'localStorage'
=========================================================*/
inputPhoneMatrice.prototype.storageToFields = function(){
console.log('MATRICE: STORAGE TO FIELDS');
console.group('[phone.matrice] storage to fields');
/* (1) On récupère la liste des contacts à mettre dans la matrice */
// On récupère les fiches
@ -149,6 +152,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
/* (3) On affiche la matrice */
this.container.innerHTML = matrice_html;
console.groupEnd('[phone.matrice] storage to fields');
};
@ -156,7 +160,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
/* [9] Point d'amorçage de la gestion des contacts
=========================================================*/
inputPhoneMatrice.prototype.attach = function(){
console.log('MATRICE: ATTACH');
console.group('[phone.matrice] attaching events');
/* (1) On initialise le jeu de données */
lsi.createDataset('p_matrice');
@ -173,6 +177,9 @@ inputPhoneMatrice.prototype.attach = function(){
setTimeout(function(){ ptr.storageToFields(); }, 500);
}, false);
console.groupEnd('[phone.matrice] attaching events');
};

View File

@ -30,7 +30,7 @@ inputPhoneMini.prototype = {
/* [2] Gestion de l'enregistrement des formulaires mini fiches relation
=========================================================*/
inputPhoneMini.prototype.fieldsToStorage = function(){
console.log('MINI FICHE: FIELDS TO STORAGE');
console.group('[phone.mini] fields to storage');
// {1} Pour chaque formulaire de MINI fiche à l'écran //
var existingMiniFiches = $$('[data-sublink="phone"] article.mini-relation-panel .mini-fiche-relation');
@ -91,6 +91,9 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
lsi.set('p_mini-fiches', obj.uid, obj);
}
console.groupEnd('[phone.mini] fields to storage');
};
@ -109,7 +112,7 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
*
*/
inputPhoneMini.prototype.add = function(objectData){
console.log('MINI FICHE: ADD');
// console.log('MINI FICHE: ADD');
// Si pas d'UID, on retourne une erreur
if( objectData == null || objectData.uid == null )
@ -220,7 +223,7 @@ inputPhoneMini.prototype.add = function(objectData){
/* [4] Gestion de l'affichage depuis le 'localStorage'
=========================================================*/
inputPhoneMini.prototype.storageToFields = function(){
console.log('MINI FICHE: STORAGE TO FIELDS');
console.group('[phone.mini] storage to fields');
// {1} Pour chaque contact du 'localStorage' //
var miniData = lsi.get('p_mini-fiches', this.selected);
@ -240,6 +243,8 @@ inputPhoneMini.prototype.storageToFields = function(){
// {3} On met à jour la navigation //
this.updateNavBar();
console.groupEnd('[phone.mini] storage to fields');
};
@ -255,7 +260,7 @@ inputPhoneMini.prototype.storageToFields = function(){
/* [5] Synchronisation des CONTACT vers les MINI fiches
=========================================================*/
inputPhoneMini.prototype.sync = function(){
console.log('MINI FICHE: SYNC');
console.group('[phone.mini] synchronisation');
/* (1) On récupère les clés de tous les CONTACTS */
var contactData = lsi.export('p_contacts');
@ -313,6 +318,7 @@ inputPhoneMini.prototype.sync = function(){
}
console.groupEnd('[phone.mini] synchronisation');
};
@ -433,7 +439,7 @@ inputPhoneMini.prototype.check = function(miniData){
/* [9] Point d'amorçage de la gestion des contacts
=========================================================*/
inputPhoneMini.prototype.attach = function(handler){
console.log('MINI FICHE: ATTACH');
console.group('[phone.mini] attaching events');
/* (1) On initialise le jeu de données */
lsi.createDataset('p_mini-fiches');
@ -454,4 +460,6 @@ inputPhoneMini.prototype.attach = function(handler){
ptr.handler(e.target);
}, false);
console.groupEnd('[phone.mini] attaching events');
};

View File

@ -26,7 +26,7 @@ inputPhoneSubject.prototype.check = function(){
/* [3] Gestion de l'enregistrement des formulaires de contact
=========================================================*/
inputPhoneSubject.prototype.fieldsToStorage = function(){
console.log('SUBJECT: FIELDS TO STORAGE');
console.group('[phone.subject] fields to storage');
// {1} Si le formulaire n'est pas valide, on ne l'enregistre pas //
if( !this.check() ) return false;
@ -41,6 +41,8 @@ inputPhoneSubject.prototype.fieldsToStorage = function(){
// {3} On enregistre les données dans le 'localStorage' //
lsi.set('p_subject', 0, obj);
console.groupEnd('[phone.subject] fields to storage');
};
@ -51,7 +53,7 @@ inputPhoneSubject.prototype.fieldsToStorage = function(){
/* [4] Gestion de l'affichage depuis le 'localStorage'
=========================================================*/
inputPhoneSubject.prototype.storageToFields = function(){
console.log('SUBJECT: STORAGE TO FIELDS');
console.group('[phone.subject] storage to fields');
// {1} On récupère les informations du sujet //
var subjectData = lsi.get('p_subject', 0);
@ -61,6 +63,9 @@ inputPhoneSubject.prototype.storageToFields = function(){
// {2} On restore les valeurs //
this.tmp_id.value = subjectData.tmp_id;
this.subject_id.value = subjectData.subject_id;
console.groupEnd('[phone.subject] storage to fields');
};
@ -68,7 +73,7 @@ inputPhoneSubject.prototype.storageToFields = function(){
/* [5] Point d'amorçage de la gestion des contacts
=========================================================*/
inputPhoneSubject.prototype.attach = function(handler){
console.log('SUBJECT: ATTACH');
console.group('[phone.subject] attaching events');
/* (1) On initialise le jeu de données */
lsi.createDataset('p_subject');
@ -93,4 +98,7 @@ inputPhoneSubject.prototype.attach = function(handler){
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
this.storageToFields();
console.groupEnd('[phone.subject] attaching events');
};

View File

@ -1,10 +1,10 @@
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<f;d++){e=lsi.get("p_contacts",d);if(null===e)break;if(parseInt(e.uid)!==parseInt(a)&&(0<e.username.length&&b===e.username||0===b.length&&parseInt(c)===parseInt(e.existing)))return!0}return!1};
inputPhoneContact.prototype.check=function(a){if(isNaN(a.existing)&&!(0<a.username.length))return!1;var b=this.callRange(a.uid)?"call":this.smsRange(a.uid)?"sms":"mini";return this.sameContact(a.uid,a.username,a.existing,b)?(0<a.username.length?Notification.error("Contact dupliqu\u00e9","Le contact de nom "+a.username+" est d\u00e9ja utilis\u00e9 dans cette partie"):Notification.error("Contact dupliqu\u00e9","Le contact "+lsi.get("p_friends",a.existing).name+" est d\u00e9ja utilis\u00e9 dans cette partie"),
!1):!0};inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),username:c.username,existing:isNaN(c.existing)?".":parseInt(c.existing)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(c.uid),d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.username=null!=a.username?a.username:"";a.existing=null!=a.existing?a.existing:".";var b=lsi["export"]("p_friends");a.contacts="";for(var c in b)a.contacts+="\t\t<option value='"+c+"'>"+b[c].name+"</option>\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="'+
!1):!0};inputPhoneContact.prototype.fieldsToStorage=function(){console.group("[phone.contact] fields to storage");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),username:c.username,existing:isNaN(c.existing)?".":parseInt(c.existing)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(c.uid),d)}}console.groupEnd("[phone.contact] fields to storage")};
inputPhoneContact.prototype.add=function(a){if(null==a||null==a.uid||isNaN(a.uid))return!1;a.username=null!=a.username?a.username:"";a.existing=null!=a.existing?a.existing:".";var b=lsi["export"]("p_friends");a.contacts="";for(var c in b)a.contacts+="\t\t<option value='"+c+"'>"+b[c].name+"</option>\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="'+
a.existing+'"]');null!=c&&c.setAttribute("selected","selected");a=$$('[data-sublink="phone"] article.contact-panel .new-contact');var d=this;for(c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1),a[c].addEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("p_contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("p_contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar()};
inputPhoneContact.prototype.storageToFields=function(){console.group("[phone.contact] storage to fields");var a=lsi.keys("p_contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("p_contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar();console.groupEnd("[phone.contact] storage to fields")};
inputPhoneContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-contact > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("p_contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b+=10)this.nav_container.innerHTML+='<span data-n="'+b+'">'+(1+b/10)+"</span>"}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))};
inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("p_contacts");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};
inputPhoneContact.prototype.attach=function(a){console.group("[phone.contact] attaching events");lsi.createDataset("p_contacts");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1);console.groupEnd("[phone.contact] attaching events")};

View File

@ -0,0 +1,21 @@
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.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("[phone.fiche] fields to storage")};
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("[phone.fiche] storage to fields")};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] Synchronisation");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))}console.groupEnd("[phone.fiche] Synchronisation")};
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||
"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;var c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1);console.groupEnd("[phone.fiche] attaching events")};

View File

@ -0,0 +1,6 @@
var inputPhoneMatrice=function(a){this.container=a};inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.group("[phone.matrice] fields to storage");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var c={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b])));lsi.set("p_matrice",0,c);console.groupEnd("[phone.matrice] fields to storage")};
inputPhoneMatrice.prototype.storageToFields=function(){console.group("[phone.matrice] storage to fields");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);a="<table class='line'>";for(d=0;d<e.length;d++){var g=b[d],a=a+"<tr>";0<d?(a+='<td style="text-align: right;">',a+=g.username,a+="</td>"):a+="<td></td>";for(var f=0;f<e.length;f++)if(f<e.length-1){var h=b[f];0==d?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',
a+=h.username,a+="</span>"):f<d?(a+="<td>",a+="<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='p_matrice_"+g.uid+"_"+h.uid+"'",null!=c[d]&&-1<c[d].indexOf(f)&&(a+=" checked"),a+=" >",a+="<label for='p_matrice_"+g.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>";console.groupEnd("[phone.matrice] storage to fields")};
inputPhoneMatrice.prototype.attach=function(){console.group("[phone.matrice] attaching events");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(c){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd("[phone.matrice] attaching events")};
inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),c;for(c in a)if(a[c]instanceof Element){var b=a[c].getData("name"),e=a[c].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][e]=a[c]}};

View File

@ -0,0 +1,13 @@
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,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'),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_mini-fiches",c.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)return;console.warn("> MINI UPDATE");c={uid:parseInt(c.uid),sexe:c.sexe,age:c.age,studies:c.studies,reltype:c.reltype,
reltypeSpecial:c.reltypeSpecial,loc:c.loc,unknown:null!=c.unknown,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_mini-fiches",c.uid,c)}}console.groupEnd("[phone.mini] fields to storage")};
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 b=lsi.get("p_contacts",
a.uid);if(!1===b)return!1;if(!isNaN(b.existing)){var c=lsi.get("p_friends",b.existing);b.username=c.name;a.contact=b.uid;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.studies1&&(a.studies=c.studies1)}this.container.innerHTML+=pMiniFicheBuilder.build({name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('[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!=b&&b.setAttribute("selected","selected");b=$('[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!=b&&b.setAttribute("selected","selected");c=$$('[data-sublink="phone"] article.mini-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.mini-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.mini-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");b=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="checkbox"][data-name="unknown"]');null!=b&&a.unknown&&b.setAttribute("checked","checked")};
inputPhoneMini.prototype.storageToFields=function(){console.group("[phone.mini] storage to fields");var a=lsi.get("p_mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar();console.groupEnd("[phone.mini] storage to fields")};
inputPhoneMini.prototype.sync=function(){console.group("[phone.mini] synchronisation");var a=lsi["export"]("p_contacts"),b;ficheIndexes=lsi.keys("p_fiches");for(b in ficheIndexes)delete a[ficheIndexes[b]];for(var c in a){var e=0==a[c].username.length?c.toString()+"-":c;b=lsi.get("p_mini-fiches",e);null==b&&(b=this.defaultData,b.contact=a[c].uid,b.valid=!1);b.uid=parseInt(c);lsi.set("p_mini-fiches",e,b)}b=lsi["export"]("p_mini-fiches");if(null==b[this.selected])for(c in b)if(!isNaN(c)){this.selected=
parseInt(c);break}console.groupEnd("[phone.mini] synchronisation")};inputPhoneMini.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-mini"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-mini > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("p_mini-fiches");this.nav_container.innerHTML="";var b=0,c;for(c in a)isNaN(c)||(this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>");for(c in a)isNaN(c)||(b=$('[data-sublink="phone"] #p_nav-mini span[data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done")));this.nav($('[data-sublink="phone"] #p_nav-mini span[data-n="'+this.selected+'"]'))};
inputPhoneMini.prototype.check=function(a){return a.unknown?!0:""==a.sexe||"."==a.studies||"."==a.age||""==a.loc||""==a.reltype||"10"==a.reltype&&2>a.reltypeSpecial.length?!1:!0};inputPhoneMini.prototype.attach=function(a){console.group("[phone.mini] attaching events");lsi.createDataset("p_mini-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);console.groupEnd("[phone.mini] attaching events")};

View File

@ -0,0 +1,3 @@
function inputPhoneSubject(a,b,c){this.tmp_id=a;this.subject_id=b;this.store_button=c}inputPhoneSubject.prototype={store_button:this.store_button,tmp_id:this.tmp_id,subject_id:this.subject_id,handler:null};inputPhoneSubject.prototype.check=function(){return 0<this.subject_id.value.length&&!isNaN(this.subject_id.value)};
inputPhoneSubject.prototype.fieldsToStorage=function(){console.group("[phone.subject] fields to storage");if(!this.check())return!1;lsi.set("p_subject",0,{tmp_id:this.tmp_id.value,subject_id:this.subject_id.value});console.groupEnd("[phone.subject] fields to storage")};inputPhoneSubject.prototype.storageToFields=function(){console.group("[phone.subject] storage to fields");var a=lsi.get("p_subject",0),a=a||{tmp_id:"",subject_id:""};this.tmp_id.value=a.tmp_id;this.subject_id.value=a.subject_id;console.groupEnd("[phone.subject] storage to fields")};
inputPhoneSubject.prototype.attach=function(a){console.group("[phone.subject] attaching events");lsi.createDataset("p_subject");lsi.createDataset("p_friends");this.handler=a;var b=this;this.store_button.addEventListener("click",function(a){b.fieldsToStorage();b.handler(!0);b.storageToFields()},!1);this.storageToFields();console.groupEnd("[phone.subject] attaching events")};

File diff suppressed because it is too large Load Diff

View File

@ -2,15 +2,15 @@ var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=
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("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+
a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML=
c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);
var phoneRoutineExecuted=0,phoneRoutine=function(){phoneRoutineExecuted++;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);$('[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();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,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-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){include("/js/includes/input-phone-matrice.js",phoneRoutine)})})})});
var phoneRoutineExecuted=!1,phoneRoutine=function(){phoneRoutineExecuted||(phoneRoutineExecuted=!0,console.group("[phone] Initialization"),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),$('[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();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,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),console.groupEnd("[phone] Initialization"))};include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){include("/js/includes/input-phone-matrice.js",phoneRoutine)})})})});
include("/js/includes/input-facebook-subject.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.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();
@ -20,10 +20,11 @@ api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.er
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)})})})})});
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.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())},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.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())};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})}
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.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!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("[phone] Dynamic Update")},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.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!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("[facebook] Dynamic Update")};
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="'+