Application de la gestion de ré-utilisation de données d'anciens sujets pour 'facebook'

This commit is contained in:
xdrm-brackets 2016-05-30 18:44:37 +02:00
parent 58511e142c
commit b71405a37e
14 changed files with 182 additions and 71 deletions

View File

@ -1,7 +1,9 @@
function inputFacebookContact(a,b){this.container=a;this.nav_container=b}inputFacebookContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputFacebookContact.prototype.check=function(a){return 0<a.username.length};
inputFacebookContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="facebook"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),username:c.username,firstname:c.firstname,lastname:c.lastname};d.hash=crc32(JSON.stringify(d));lsi.set("f_contacts",parseInt(c.uid),d)}}};
inputFacebookContact.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.firstname=null!=a.firstname?a.firstname:"";a.lastname=null!=a.lastname?a.lastname:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=fContactBuilder.build(a);a=$$('[data-sublink="facebook"] article.contact-panel .new-contact');
for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1),a[c].addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};inputFacebookContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("f_contacts");this.container.innerHTML="";for(var b=this.selected+10,c=this.selected;c<b&&c<a.length;c++)this.add(lsi.get("f_contacts",a[c]));b>=a.length&&this.add({uid:a.length});this.updateNavBar()};
inputFacebookContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-contact"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="facebook"] #f_nav-contact > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookContact.prototype.updateNavBar=function(){var a=lsi.keys("f_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="facebook"] #f_nav-contact [data-n="'+this.selected+'"]'))};
inputFacebookContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("f_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)};
function inputFacebookContact(a,c){this.container=a;this.nav_container=c}inputFacebookContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputFacebookContact.prototype.check=function(a){return!isNaN(a.existing)||0<a.username.length};
inputFacebookContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="facebook"] article.contact-panel .new-contact'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate();if(this.check(b)){var d={uid:parseInt(b.uid),username:b.username,firstname:b.firstname,lastname:b.lastname,existing:isNaN(b.existing)?".":parseInt(b.existing)};d.hash=crc32(JSON.stringify(d));lsi.set("f_contacts",parseInt(b.uid),
d)}}};
inputFacebookContact.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 c=lsi["export"]("f_friends");a.contacts="";for(var b in c)a.contacts+="\t\t<option value='"+b+"'>"+c[b].name+"</option>\n";this.container.innerHTML+=fContactBuilder.build(a);b=$('[data-sublink="facebook"] article.contact-panel .new-contact input[data-name="uid"][value="'+a.uid+'"] ~ span select[data-name="existing"]>option[value="'+a.existing+
'"]');null!=b&&b.setAttribute("selected","selected");a=$$('[data-sublink="facebook"] article.contact-panel .new-contact');var d=this;for(b=0;b<a.length;b++)a[b].removeEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1),a[b].addEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1)};
inputFacebookContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("f_contacts");this.container.innerHTML="";for(var c=this.selected+10,b=this.selected;b<c&&b<a.length;b++)this.add(lsi.get("f_contacts",a[b]));c>=a.length&&this.add({uid:a.length});this.updateNavBar()};
inputFacebookContact.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-contact"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="facebook"] #f_nav-contact > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookContact.prototype.updateNavBar=function(){var a=lsi.keys("f_contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var c=0;c<a;c+=10)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(1+c/10)+"</span>"}this.nav($('[data-sublink="facebook"] #f_nav-contact [data-n="'+this.selected+'"]'))};
inputFacebookContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("f_contacts");this.storageToFields();this.handler=a;var c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1)};

View File

@ -20,7 +20,7 @@ inputFacebookContact.prototype = {
=========================================================*/
inputFacebookContact.prototype.check = function(deflated){
/* On retourne la validité du formulaire */
return deflated.username.length > 0;
return !isNaN(deflated.existing) || deflated.username.length > 0;
}
@ -34,7 +34,7 @@ inputFacebookContact.prototype.fieldsToStorage = function(){
for( var i = 0 ; i < visibleContacts.length ; i++ ){
// {2} On initialise notre deflater pour récupérer les valeurs //
var deflater = new FormDeflater(visibleContacts[i], ['input'], ['data-name']);
var deflater = new FormDeflater(visibleContacts[i], ['input', 'select'], ['data-name']);
// {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom //
var deflated = deflater.deflate();
@ -47,7 +47,9 @@ inputFacebookContact.prototype.fieldsToStorage = function(){
uid: parseInt(deflated.uid),
username: deflated.username,
firstname: deflated.firstname,
lastname: deflated.lastname
lastname: deflated.lastname,
existing: (!isNaN(deflated.existing)) ? parseInt(deflated.existing) : '.'
};
/* (5) On calcule et ajoute le hash des données */
@ -84,18 +86,26 @@ inputFacebookContact.prototype.add = function(objectData){
// {0} On formatte l'object //
objectData.username = (objectData.username != null) ? objectData.username : '';
objectData.firstname = (objectData.firstname != null) ? objectData.firstname : '';
objectData.lastname = (objectData.lastname != null) ? objectData.lastname : '';
objectData.call = (objectData.call != null) ? objectData.call : -1;
objectData.sms = (objectData.sms != null) ? objectData.sms : -1;
objectData.countcall = (objectData.countcall != null) ? objectData.countcall : 0;
objectData.countsms = (objectData.countsms != null) ? objectData.countsms : 0;
objectData.existing = (objectData.existing != null) ? objectData.existing : '.';
// {1} On ajoute le HTML //
this.container.innerHTML += fContactBuilder.build(objectData);
// {1} On récupére la liste des contacts déja renseignés //
var existing = lsi.export('f_friends');
var buildData = objectData;
buildData.contacts = '';
// {2} On attache les évènements sur les formulaires //
for( var i in existing )
buildData.contacts += "\t\t<option value='"+i+"'>"+existing[i].name+"</option>\n";
// {2} On ajoute le HTML //
this.container.innerHTML += fContactBuilder.build(buildData);
// {3} On remplit @existing s'il y a une valeur //
var existingOption = $('[data-sublink="facebook"] article.contact-panel .new-contact input[data-name="uid"][value="'+objectData.uid+'"] ~ span select[data-name="existing"]>option[value="'+objectData.existing+'"]');
if( existingOption != null )
existingOption.setAttribute('selected', 'selected');
// {4} On attache les évènements sur les formulaires //
var contactForms = $$('[data-sublink="facebook"] article.contact-panel .new-contact');
// On met à jour les listener (remove, puis add)

View File

@ -4,9 +4,10 @@ reltypeSpecial:c.reltypeSpecial,city:c.city,quartier:c.quartier,cp:c.cp,loc:c.lo
inputFacebookFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.quartier=null!=a.quartier?a.quartier:this.defaultData.quartier;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:
this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:
this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;
a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("f_contacts",a.contact);if(!1===b)return!1;this.container.innerHTML+=fFicheBuilder.build({name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],
a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("f_contacts",a.contact);if(!1===b)return!1;if(!isNaN(b.existing)){var c=lsi.get("f_friends",b.existing);b.username=c.name;a.age=c.age;a.sexe=c.sexe;a.loc=c.dist;isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):(a.reltype=c.reltype,a.reltypeSpecial="");null!=c.studies2&&(a.studies=c.studies2,a.job=c.job,a.famsit=c.famsit,a.city=c.city,a.cp=c.cp,a.quartier=c.quartier,a.duration[0]=c.duration[0],a.duration[1]=c.duration[1],
a.context=c.context,a.contextSpecial=c.contextExtra,a.connect=c.connect,a.connectSpecial=c.connectExtra,a.freq=c.freq)}this.container.innerHTML+=fFicheBuilder.build({name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,quartier:a.quartier,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],
connectspecial1:a.connectSpecial[1]});b=$('[data-sublink="facebook"] 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="facebook"] 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="facebook"] 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");for(var c=$$('[data-sublink="facebook"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="facebook"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');
a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");c=$$('[data-sublink="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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="facebook"] 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")};

View File

@ -168,6 +168,46 @@ inputFacebookFiche.prototype.add = function(objectData){
if( associatedContact === false )
return false;
// {2} Si lié à un contact d'une autre étude, on utilise ses informations //
if( !isNaN(associatedContact.existing) ){
var existingData = lsi.get('f_friends', associatedContact.existing);
// On récupère les données communes
associatedContact.username = existingData.name;
objectData.age = existingData.age;
objectData.sexe = existingData.sexe;
objectData.loc = existingData.dist;
// DISTANCE (LOC) : Si valeur
if( !isNaN(existingData.reltype) ){
objectData.reltype = existingData.reltype;
objectData.reltypeSpecial = '';
// DISTANCE (LOC) : Si extra
}else{
objectData.reltype = 10;
objectData.reltypeSpecial = existingData.reltype;
}
// On met à jour les études uniquement si 'studies2' est défini //
if( existingData.studies2 != null ){
objectData.studies = existingData.studies2;
objectData.job = existingData.job;
objectData.famsit = existingData.famsit;
objectData.city = existingData.city;
objectData.cp = existingData.cp;
objectData.quartier = existingData.quartier;
objectData.duration[0] = existingData.duration[0];
objectData.duration[1] = existingData.duration[1];
objectData.context = existingData.context;
objectData.contextSpecial = existingData.contextExtra;
objectData.connect = existingData.connect;
objectData.connectSpecial = existingData.connectExtra;
objectData.freq = existingData.freq;
}
}
// {5} Création physique //
this.container.innerHTML += fFicheBuilder.build({

View File

@ -1,12 +1,13 @@
function inputFacebookMini(a,b){this.container=a;this.nav_container=b}inputFacebookMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",studies:"0",loc:".",reltype:"9",unknown:!1,reltypeSpecial:"",timestamp:0,valid:!1}};
inputFacebookMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="facebook"] article.mini-relation-panel .mini-fiche-relation'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(c)),e=lsi.get("f_mini-fiches",c.uid);if(!1!==e){if(null!=e&&null!=e.hash&&e.hash==d)break;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:d};c.valid=this.check(c);0<diff(e,c,["hash","valid","timestamp"]).length&&(console.log(diff(e,c,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("f_mini-fiches",c.uid,c)}}};
function inputFacebookMini(a,c){this.container=a;this.nav_container=c}inputFacebookMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",studies:"0",loc:".",reltype:"9",unknown:!1,reltypeSpecial:"",timestamp:0,valid:!1}};
inputFacebookMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="facebook"] article.mini-relation-panel .mini-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("f_mini-fiches",b.uid);if(!1!==e){if(null!=e&&null!=e.hash&&e.hash==d)break;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: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("f_mini-fiches",b.uid,b)}}};
inputFacebookMini.prototype.add=function(a){console.log("MINI FICHE: ADD");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("f_contacts",a.uid);if(!1===b)return!1;this.container.innerHTML+=fMiniFicheBuilder.build({name:b.username,countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('[data-sublink="facebook"] 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="facebook"] 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");for(var c=$$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="facebook"] 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="facebook"] 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="facebook"] 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")};inputFacebookMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("f_mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar()};
inputFacebookMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("f_contacts"),b=lsi["export"]("f_fiches"),c=[],d;for(d in b)-1==c.indexOf(b[d].contact)&&c.push(b[d].contact);for(var e in a)-1<c.indexOf(parseInt(e))?lsi.del("f_mini-fiches",e):(b=0==a[e].username.length?e.toString()+"-":e,d=lsi.get("f_mini-fiches",b),null==d&&(d=this.defaultData,d.valid=!1,isNaN(b)&&(d.reltype="9")),d.uid=parseInt(e),lsi.set("f_mini-fiches",b,d));d=lsi["export"]("f_mini-fiches");if(null==
d[this.selected])for(e in d)if(!isNaN(e)){this.selected=parseInt(e);break}};inputFacebookMini.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-mini"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="facebook"] #f_nav-mini > span.active'),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookMini.prototype.updateNavBar=function(){var a=lsi["export"]("f_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="facebook"] #f_nav-mini [data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done")));this.nav($('[data-sublink="facebook"] #f_nav-mini [data-n="'+this.selected+'"]'))};
inputFacebookMini.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};inputFacebookMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("f_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)};
var c=lsi.get("f_contacts",a.uid);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.studies1&&(a.studies=b.studies1)}this.container.innerHTML+=fMiniFicheBuilder.build({name:c.username,uid:a.uid,reltypespecial:a.reltypeSpecial});c=$('[data-sublink="facebook"] 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="facebook"] 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="facebook"] 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==
a.sexe?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="facebook"] article.mini-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.mini-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");c=$('[data-sublink="facebook"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="checkbox"][data-name="unknown"]');null!=c&&a.unknown&&c.setAttribute("checked","checked")};
inputFacebookMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("f_mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar()};
inputFacebookMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("f_contacts"),c=lsi["export"]("f_fiches"),b=[],d;for(d in c)-1==b.indexOf(c[d].contact)&&b.push(c[d].contact);for(var e in a)-1<b.indexOf(parseInt(e))?lsi.del("f_mini-fiches",e):(c=0==a[e].username.length?e.toString()+"-":e,d=lsi.get("f_mini-fiches",c),null==d&&(d=this.defaultData,d.valid=!1,isNaN(c)&&(d.reltype="9")),d.uid=parseInt(e),lsi.set("f_mini-fiches",c,d));d=lsi["export"]("f_mini-fiches");if(null==
d[this.selected])for(e in d)if(!isNaN(e)){this.selected=parseInt(e);break}};inputFacebookMini.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"f_nav-mini"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="facebook"] #f_nav-mini > span.active'),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputFacebookMini.prototype.updateNavBar=function(){var a=lsi["export"]("f_mini-fiches");this.nav_container.innerHTML="";var c=0,b;for(b in a)isNaN(b)||(this.nav_container.innerHTML+='<span data-n="'+b+'">'+ ++c+"</span>");for(b in a)isNaN(b)||(c=$('[data-sublink="facebook"] #f_nav-mini [data-n="'+a[b].uid+'"]'),null!=c&&(!0===a[b].valid?c.addClass("done"):c.remClass("done")));this.nav($('[data-sublink="facebook"] #f_nav-mini [data-n="'+this.selected+'"]'))};
inputFacebookMini.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};inputFacebookMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("f_mini-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)};

View File

@ -64,7 +64,7 @@ inputFacebookMini.prototype.fieldsToStorage = function(){
var obj = {
uid: parseInt(deflated.uid),
sexe: deflated.sexe, // [0] Homme, [1] Femme
sexe: deflated.sexe, // [0] Homme, [1] Femme, [2] Indéterminé
age: deflated.age,
studies: deflated.studies,
reltype: deflated.reltype, // [0] ...
@ -130,12 +130,37 @@ inputFacebookMini.prototype.add = function(objectData){
if( associatedContact === false )
return false;
// {2} Si lié à un contact d'une autre étude, on utilise ses informations //
if( !isNaN(associatedContact.existing) ){
var existingData = lsi.get('f_friends', associatedContact.existing);
// On récupère les données communes
associatedContact.username = existingData.name;
objectData.age = existingData.age;
objectData.sexe = existingData.sexe;
objectData.loc = existingData.dist;
// DISTANCE (LOC) : Si valeur
if( !isNaN(existingData.reltype) ){
objectData.reltype = existingData.reltype;
objectData.reltypeSpecial = '';
// DISTANCE (LOC) : Si extra
}else{
objectData.reltype = 10;
objectData.reltypeSpecial = existingData.reltype;
}
// On met à jour les études uniquement si 'studies1' est défini //
if( existingData.studies1 != null )
objectData.studies = existingData.studies1;
}
// {2} Création physique //
this.container.innerHTML += fMiniFicheBuilder.build({
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,
reltypespecial: objectData.reltypeSpecial
});

View File

@ -1,2 +1,3 @@
function inputFacebookSubject(a,b){this.subject_id=a;this.store_button=b}inputFacebookSubject.prototype={store_button:this.store_button,subject_id:this.subject_id};inputFacebookSubject.prototype.check=function(){return 0<this.subject_id.value.length&&!isNaN(this.subject_id.value)};inputFacebookSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("f_subject",0,{subject_id:this.subject_id.value})};
inputFacebookSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("f_subject",0);null==a&&(a={subject_id:""});this.subject_id.value=a.subject_id};inputFacebookSubject.prototype.attach=function(){function a(a){b.fieldsToStorage()&&b.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("f_subject");var b=this;this.store_button.addEventListener("click",a,!1);this.subject_id.addEventListener("blur",a,!1);this.storageToFields()};
function inputFacebookSubject(a,b){this.subject_id=a;this.store_button=b}inputFacebookSubject.prototype={store_button:this.store_button,subject_id:this.subject_id,handler:null};inputFacebookSubject.prototype.check=function(){return 0<this.subject_id.value.length&&!isNaN(this.subject_id.value)};inputFacebookSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("f_subject",0,{subject_id:this.subject_id.value})};
inputFacebookSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("f_subject",0);null==a&&(a={subject_id:""});this.subject_id.value=a.subject_id};
inputFacebookSubject.prototype.attach=function(a){function b(a){c.fieldsToStorage();c.handler(!0);c.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("f_subject");lsi.createDataset("f_friends");this.handler=a;var c=this;this.store_button.addEventListener("click",b,!1);this.subject_id.addEventListener("blur",b,!1);this.storageToFields()};

View File

@ -2,7 +2,6 @@
=========================================================*/
function inputFacebookSubject(iSubjectId, store_button){
this.subject_id = iSubjectId;
this.store_button = store_button;
}
@ -10,7 +9,8 @@ function inputFacebookSubject(iSubjectId, store_button){
=========================================================*/
inputFacebookSubject.prototype = {
store_button: this.store_button, // Bouton d'ajout d'un formulaire
subject_id: this.subject_id
subject_id: this.subject_id,
handler: null
};
@ -63,23 +63,25 @@ inputFacebookSubject.prototype.storageToFields = function(){
/* [5] Point d'amorçage de la gestion des contacts
=========================================================*/
inputFacebookSubject.prototype.attach = function(){
inputFacebookSubject.prototype.attach = function(handler){
console.log('SUBJECT: ATTACH');
/* (1) On initialise le jeu de données */
lsi.createDataset('f_subject');
lsi.createDataset('f_friends');
// Pointeur pour les scopes des addEventListener()
this.handler = handler;
var ptr = this;
// Handler de mise à jour quand les champs sont bons
function fts(e){ if( ptr.fieldsToStorage() ) ptr.storageToFields(); }
function fts(e){ ptr.fieldsToStorage(); ptr.handler(true); ptr.storageToFields(); }
/* (2) On attache l'évènement sur le bouton d'enregistrement */
this.store_button.addEventListener('click', fts, false);
/* (3) On attache un évènement de 'blur' sur chaque '<input type="text">' */
this.subject_id.addEventListener( 'blur', fts, false);
this.subject_id.addEventListener('blur', fts, false);
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
this.storageToFields();

File diff suppressed because one or more lines are too long

View File

@ -5,17 +5,18 @@ var fContactBuilder = new HTMLBuilder();
fContactBuilder.setLayout(
"<h4 data-icon='o' class='new-contact color2'> \n"+
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
"\t<span class='select-container nobold'><select data-name='existing'>\n"+
"\t\t<option value='.' disabled selected>Contact existant</option>\n"+
"@existinglist"+
"\t</select></span>\n"+
"\t<span class='select-container nobold'><select data-name='existing'>\n"+
"\t\t<option value='.'>Utiliser pseudo</option>\n"+
"@contacts"+
"\t</select></span>\n"+
"\t&nbsp;&nbsp;&nbsp;&nbsp;ou&nbsp;&nbsp;&nbsp;&nbsp;\n"+
"\t&nbsp;&nbsp;&nbsp;&nbsp;ou&nbsp;&nbsp;&nbsp;&nbsp;\n"+
"\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+
"\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+
"\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+
"\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+
"</h4>\n\n");

View File

@ -1,4 +1,4 @@
function inputPhoneContact(a,c){this.container=a;this.nav_container=c}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return"."!=a.existing||0<a.username.length};
function inputPhoneContact(a,c){this.container=a;this.nav_container=c}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return!isNaN(a.existing)||0<a.username.length};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate();if(this.check(b)){var d={uid:parseInt(b.uid),number:b.number,username:b.username,call:parseInt(b.call),sms:parseInt(b.sms),countcall:parseInt(b.countcall),countsms:parseInt(b.countsms),existing:isNaN(b.existing)?".":parseInt(b.existing)};
d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(b.uid),d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;a.existing=null!=a.existing?a.existing:".";var c=lsi["export"]("p_friends");a.contacts="";for(var b in c)a.contacts+="\t\t<option value='"+b+"'>"+c[b].name+"</option>\n";

View File

@ -20,7 +20,7 @@ inputPhoneContact.prototype = {
=========================================================*/
inputPhoneContact.prototype.check = function(deflated){
/* On retourne la validité du formulaire */
return deflated.existing != '.' || deflated.username.length > 0;
return !isNaN(deflated.existing) || deflated.username.length > 0;
}

14
view/js/input-min.js vendored
View File

@ -4,8 +4,8 @@ b.results[g].name+"</span> </div>",a+="<div> <span data-prefix='Cr\u00e9ation'>"
var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager;
function pDynamicUpdate(a){var b=a instanceof Element,f=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(!f&&!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(),(f||b)&&pContactManager.storageToFields())}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(a){var b=a instanceof Element,f=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(!f&&!g&&!b&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(f||b)&&fContactManager.storageToFields()}
function fDynamicUpdate(a){var b=a instanceof Element,f=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(!f&&!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(),(f||b)&&fContactManager.storageToFields())}
include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));
pSubjectManager.attach(pDynamicUpdate);pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));
pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var a=new ShortcutManager,b=!1;a.append("s+n+a+k+e",function(){b||(b=!0,pMatriceManager.snake())});a.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(a){api.send({path:"upload/call_log",
@ -18,11 +18,11 @@ var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-dat
pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,d;for(d in a)if(!isNaN(d)&&(b++,!a[d].valid))return Notification.warning("Attention",
"La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(d in a)if(!a[d].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(d)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;d={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(d,function(a){console.log(a);
if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})});
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact-min.js",function(){include("/js/includes/input-facebook-mini-min.js",function(){include("/js/includes/input-facebook-fiche-min.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));
fSubjectManager.attach();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");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();
fMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');
b.download="local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact.js",function(){include("/js/includes/input-facebook-mini.js",function(){include("/js/includes/input-facebook-fiche.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate);
fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));fFicheManager.attach(fDynamicUpdate);
fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();
Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download=
"local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var b=0,f;for(f in a)if(!isNaN(f)&&(b++,!a[f].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(f in a)if(!a[f].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(f)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;f={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(f,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),

View File

@ -198,14 +198,37 @@ function fDynamicUpdate(target){
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (7) On récupère tous les amis du sujet */
if( target === true ){
api.send({ path: 'subject/getFriends', subject_id: fSubjectManager.subject_id.value }, function(response){
// Si erreur, on quitte
if( response.ModuleError != 0 )
return false;
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
// On enregistre les contacts existants
lsi.import('f_friends', response.subjects);
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
fContactManager.storageToFields();
});
}else{
/* (8) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
}
}
@ -224,6 +247,7 @@ include('/js/includes/input-phone-subject-min.js', function(){
include('/js/includes/input-phone-contact.js', function(){
//TODO: Remettre version min
include('/js/includes/input-phone-mini.js', function(){
//TODO: Remettre version min
include('/js/includes/input-phone-fiche.js', function(){
include('/js/includes/input-phone-matrice-min.js', function(){
@ -636,9 +660,12 @@ include('/js/includes/input-phone-matrice-min.js', function(){
/*=========== Gestion du formulaire facebook ==============*/
/*=========================================================*/
include('/js/includes/input-facebook-subject-min.js', function(){
include('/js/includes/input-facebook-contact-min.js', function(){
include('/js/includes/input-facebook-mini-min.js', function(){
include('/js/includes/input-facebook-fiche-min.js', function(){
//TODO: Remettre version min
include('/js/includes/input-facebook-contact.js', function(){
//TODO: Remettre version min
include('/js/includes/input-facebook-mini.js', function(){
//TODO: Remettre version min
include('/js/includes/input-facebook-fiche.js', function(){
include('/js/includes/input-facebook-matrice-min.js', function(){
@ -651,7 +678,7 @@ include('/js/includes/input-facebook-matrice-min.js', function(){
);
/* (2) On le démarre */
fSubjectManager.attach();
fSubjectManager.attach(fDynamicUpdate);
@ -717,6 +744,7 @@ include('/js/includes/input-facebook-matrice-min.js', function(){
lsi.clear('f_mini-fiches');
lsi.clear('f_fiches');
lsi.clear('f_matrice');
lsi.clear('f_friends');
/* (2) On met à jour l'affichage */