Close #12; Pseudo uniquement + numéro de téléphone pas obligatoire

This commit is contained in:
xdrm-brackets 2016-05-19 15:14:10 +02:00
parent 7083a7a9dc
commit 70a1b8b10d
31 changed files with 207 additions and 457 deletions

View File

@ -1,4 +1,4 @@
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+a.firstname.length+a.lastname.length};
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()};

View File

@ -20,7 +20,7 @@ inputFacebookContact.prototype = {
=========================================================*/
inputFacebookContact.prototype.check = function(deflated){
/* On retourne la validité du formulaire */
return deflated.username.length+deflated.firstname.length+deflated.lastname.length > 0;
return deflated.username.length >= 0;
}

View File

@ -4,8 +4,8 @@ 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:readableName(b.username,b.firstname,b.lastname),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.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],
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"]');
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"]');

View File

@ -171,7 +171,7 @@ inputFacebookFiche.prototype.add = function(objectData){
// {5} Création physique //
this.container.innerHTML += fFicheBuilder.build({
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,

View File

@ -1,5 +1,5 @@
function inputFacebookMatrice(a){this.container=a}inputFacebookMatrice.prototype={container:this.container};
inputFacebookMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("f_matrice",0,d)};
inputFacebookMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("f_fiches"),d=lsi.get("f_matrice",0),b=lsi["export"]("f_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var f=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=readableName(f.username,f.firstname,f.lastname),a+="</td>"):a+="<td></td>";for(var h=0;h<e.length;h++)if(h<e.length-1){var g=b[h];
0==c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=readableName(g.username,g.firstname,g.lastname),a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+f.uid+"_"+g.uid+"' data-name='"+f.uid+"' value='"+g.uid+"' id='matrice_"+f.uid+"_"+g.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+f.uid+"_"+g.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputFacebookMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("f_fiches"),d=lsi.get("f_matrice",0),b=lsi["export"]("f_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var g=b[c],a=a+"<tr>";0<c?(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==c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',
a+=h.username,a+="</span>"):f<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='matrice_"+g.uid+"_"+h.uid+"'",null!=d[c]&&-1<d[c].indexOf(f)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+g.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputFacebookMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("f_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};

View File

@ -108,7 +108,7 @@ inputFacebookMatrice.prototype.storageToFields = function(){
if( A > 0 ){ // Noms sur la première ligne (abscisses)
matrice_html += '<td style="text-align: right;">';
matrice_html += readableName(conA.username, conA.firstname, conA.lastname);
matrice_html += conA.username;
matrice_html += '</td>';
}else // Sinon,
matrice_html += '<td></td>';
@ -121,7 +121,7 @@ inputFacebookMatrice.prototype.storageToFields = function(){
if( A == 0 ){
matrice_html += '<td>';
matrice_html += '<span style="writing-mode: vertical-lr; text-align: right;">';
matrice_html += readableName(conB.username, conB.firstname, conB.lastname),
matrice_html += conB.username;
matrice_html += '</span>';
// {4} Valeurs des relations (boutons) //

View File

@ -1,12 +1,12 @@
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:"0",age:".",studies:".",loc:"0",reltype:"0",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(),e=crc32(JSON.stringify(c)),d=lsi.get("f_mini-fiches",c.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)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,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("f_mini-fiches",c.uid,c)}}};
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,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)}}};
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;var b=lsi.get("f_contacts",a.uid);if(!1===b)return!1;
this.container.innerHTML+=fMiniFicheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),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")};
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")};
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=[],e;for(e in b)-1==c.indexOf(b[e].contact)&&c.push(b[e].contact);for(var d in a)-1<c.indexOf(parseInt(d))?lsi.del("f_mini-fiches",d):(b=0==a[d].username.length+a[d].firstname.length+a[d].lastname.length?d.toString()+"-":d,e=lsi.get("f_mini-fiches",b),null==e&&(e=this.defaultData,e.valid=!1,isNaN(b)&&(e.reltype="9")),e.uid=parseInt(d),lsi.set("f_mini-fiches",
b,e));e=lsi["export"]("f_mini-fiches");if(null==e[this.selected])for(d in e)if(!isNaN(d)){this.selected=parseInt(d);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.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.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)};

View File

@ -130,7 +130,7 @@ inputFacebookMini.prototype.add = function(objectData){
// {2} Création physique //
this.container.innerHTML += fMiniFicheBuilder.build({
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,
@ -240,7 +240,7 @@ inputFacebookMini.prototype.sync = function(){
}
/* (5) Si le contact n'a aucun nominatif, on met inconnu par défaut, mais on ne l'affiche pas */
var noName = contactData[key].username.length+contactData[key].firstname.length+contactData[key].lastname.length == 0;
var noName = contactData[key].username.length == 0;
// On rajoute un '.' après pour dire qu'on affichera pas
var uid = noName ? key.toString()+'-' : key;

View File

@ -1,4 +1,2 @@
function inputFacebookSubject(a,b,c,d){this.username=a;this.firstname=b;this.lastname=c;this.store_button=d}inputFacebookSubject.prototype={store_button:this.store_button,username:this.username,firstname:this.firstname,lastname:this.lastname};inputFacebookSubject.prototype.check=function(){return 0<this.username.value.length+this.firstname.value.length+this.lastname.value.length};
inputFacebookSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("f_subject",0,{username:this.username.value,firstname:this.firstname.value,lastname:this.lastname.value})};
inputFacebookSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("f_subject",0);null==a&&(a={username:"",firstname:"",lastname:""});this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
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.username.addEventListener("blur",a,!1);this.firstname.addEventListener("blur",a,!1);this.lastname.addEventListener("blur",a,!1);this.storageToFields()};
function inputFacebookSubject(a,b){this.username=a;this.store_button=b}inputFacebookSubject.prototype={store_button:this.store_button,username:this.username};inputFacebookSubject.prototype.check=function(){return 0<this.username.value.length};inputFacebookSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("f_subject",0,{username:this.username.value})};
inputFacebookSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("f_subject",0);null==a&&(a={username:""});this.username.value=a.username};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.username.addEventListener("blur",a,!1);this.storageToFields()};

View File

@ -1,9 +1,7 @@
/* [0] Constructeur -> définit le conteneur et le bouton d'ajout
=========================================================*/
function inputFacebookSubject(iUsername, iFirstname, iLastname, store_button){
function inputFacebookSubject(iUsername, store_button){
this.username = iUsername;
this.firstname = iFirstname;
this.lastname = iLastname;
this.store_button = store_button;
}
@ -12,9 +10,7 @@ function inputFacebookSubject(iUsername, iFirstname, iLastname, store_button){
=========================================================*/
inputFacebookSubject.prototype = {
store_button: this.store_button, // Bouton d'ajout d'un formulaire
username: this.username,
firstname: this.firstname,
lastname: this.lastname
username: this.username
};
@ -22,7 +18,7 @@ inputFacebookSubject.prototype = {
=========================================================*/
inputFacebookSubject.prototype.check = function(){
// On renvoie la validité du formulaire
return this.username.value.length+this.firstname.value.length+this.lastname.value.length > 0;
return this.username.value.length > 0;
};
/* [3] Gestion de l'enregistrement des formulaires de contact
@ -35,9 +31,7 @@ inputFacebookSubject.prototype.fieldsToStorage = function(){
// {2} On récupère et met en forme les valeurs du deflater //
var obj = {
username: this.username.value,
firstname: this.firstname.value,
lastname: this.lastname.value
username: this.username.value
};
// {3} On enregistre les données dans le 'localStorage' //
@ -59,12 +53,10 @@ inputFacebookSubject.prototype.storageToFields = function(){
var subjectData = lsi.get('f_subject', 0);
if( subjectData == null )
subjectData = { username: '', firstname: '', lastname: '' };
subjectData = { username: '' };
// {2} On restore les valeurs //
this.username.value = subjectData.username;
this.firstname.value = subjectData.firstname;
this.lastname.value = subjectData.lastname;
};
@ -88,8 +80,6 @@ inputFacebookSubject.prototype.attach = function(){
/* (3) On attache un évènement de 'blur' sur chaque '<input type="text">' */
this.username.addEventListener( 'blur', fts, false);
this.firstname.addEventListener( 'blur', fts, false);
this.lastname.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

@ -8,10 +8,6 @@ fContactBuilder.setLayout(
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
"\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+
"\t<span class='switch-left'></span> \n"+
"\t<input type='text' data-name='firstname' placeholder='Prénom' value='@firstname' > \n"+
"\t<span class='switch-both'></span> \n"+
"\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n"+
"\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+
"</h4>\n\n");

File diff suppressed because one or more lines are too long

View File

@ -14,10 +14,6 @@ pContactBuilder.setLayout(
"\t<input type='text' data-name='number' placeholder='Numéro de téléphone' value='@number' > \n"+
"\t<input type='text' data-name='username' placeholder='Pseudo' value='@username' > \n"+
"\t<span class='switch-left'></span> \n"+
"\t<input type='text' data-name='firstname' placeholder='Prénom' value='@firstname' > \n"+
"\t<span class='switch-both'></span> \n"+
"\t<input type='text' data-name='lastname' placeholder='Nom' value='@lastname' > \n"+
"\t<input type='submit' class='primary sub-number' value='Enregistrer'>\n"+
"</h4>\n\n");

View File

@ -1,8 +1,8 @@
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.check=function(a){var b=0<a.number.length;return b=b&&0<a.username.length+a.firstname.length+a.lastname.length};
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"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,firstname:c.firstname,lastname:c.lastname,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));
lsi.set("p_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.number=null!=a.number?a.number:"";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+=pContactBuilder.build(a);a=$$('[data-sublink="phone"] 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)};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()};
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.check=function(a){return 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'),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),number:c.number,username:c.username,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};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.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;this.container.innerHTML+=pContactBuilder.build(a);a=$$('[data-sublink="phone"] 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)};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.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)};

View File

@ -19,13 +19,9 @@ inputPhoneContact.prototype = {
/* [2] Vérification des données d'un contact
=========================================================*/
inputPhoneContact.prototype.check = function(deflated){
/* (1) Le numéro n'est pas vide */
var validForm = deflated.number.length > 0;
/* (2) ET le pseudo et/ou le prénom et/ou le nom n'est pas vide */
validForm = validForm && deflated.username.length+deflated.firstname.length+deflated.lastname.length > 0;
/* On retourne la validité du formulaire */
return deflated.username.length >= 0;
/* (3) On retourne la validité du formulaire */
return validForm;
}
@ -47,13 +43,12 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
// Si le formulaire n'est pas valide, on ne l'enregistre pas
if( !this.check(deflated) ) continue;
// {4} On récupère et met en forme les valeurs du deflater //
var obj = {
uid: parseInt(deflated.uid),
number: deflated.number,
username: deflated.username,
firstname: deflated.firstname,
lastname: deflated.lastname,
call: parseInt(deflated.call),
sms: parseInt(deflated.sms),
@ -66,7 +61,7 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
obj.hash = crc32( JSON.stringify(obj) );
// {6} On enregistre les données dans le 'localStorage' //
lsi.set('p_p_contacts', parseInt(deflated.uid), obj);
lsi.set('p_contacts', parseInt(deflated.uid), obj);
}
@ -97,8 +92,6 @@ inputPhoneContact.prototype.add = function(objectData){
// {0} On formatte l'object //
objectData.number = (objectData.number != null) ? objectData.number : '';
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;

View File

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

View File

@ -171,7 +171,7 @@ inputPhoneFiche.prototype.add = function(objectData){
// {5} Création physique //
this.container.innerHTML += pFicheBuilder.build({
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,

View File

@ -1,5 +1,5 @@
function inputPhoneMatrice(a){this.container=a}inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("p_matrice",0,d)};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),d=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var f=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=readableName(f.username,f.firstname,f.lastname),a+="</td>"):a+="<td></td>";for(var h=0;h<e.length;h++)if(h<e.length-1){var g=b[h];0==
c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=readableName(g.username,g.firstname,g.lastname),a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+f.uid+"_"+g.uid+"' data-name='"+f.uid+"' value='"+g.uid+"' id='matrice_"+f.uid+"_"+g.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+f.uid+"_"+g.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),d=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var g=b[c],a=a+"<tr>";0<c?(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==c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',
a+=h.username,a+="</span>"):f<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='matrice_"+g.uid+"_"+h.uid+"'",null!=d[c]&&-1<d[c].indexOf(f)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+g.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};

View File

@ -108,7 +108,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
if( A > 0 ){ // Noms sur la première ligne (abscisses)
matrice_html += '<td style="text-align: right;">';
matrice_html += readableName(conA.username, conA.firstname, conA.lastname);
matrice_html += conA.username;
matrice_html += '</td>';
}else // Sinon,
matrice_html += '<td></td>';
@ -121,7 +121,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
if( A == 0 ){
matrice_html += '<td>';
matrice_html += '<span style="writing-mode: vertical-lr; text-align: right;">';
matrice_html += readableName(conB.username, conB.firstname, conB.lastname),
matrice_html += conB.username;
matrice_html += '</span>';
// {4} Valeurs des relations (boutons) //

View File

@ -1,12 +1,12 @@
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:{sexe:"0",age:".",studies:".",loc:"0",reltype:"0",reltypeSpecial:"",timestamp:0,valid:!1}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: 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)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,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)}}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: 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(),d=crc32(JSON.stringify(c)),e=lsi.get("p_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,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("p_mini-fiches",c.uid,c)}}};
inputPhoneMini.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;var b=lsi.get("p_contacts",a.uid);if(!1===b)return!1;
this.container.innerHTML+=pMiniFicheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),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="'+
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");for(var c=$$('[data-sublink="phone"] 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="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")};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: 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()};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("p_contacts"),b=lsi["export"]("p_fiches"),c=[],e;for(e in b)-1==c.indexOf(b[e].contact)&&c.push(b[e].contact);for(var d in a)-1<c.indexOf(parseInt(d))?lsi.del("p_mini-fiches",d):(b=0==a[d].username.length+a[d].firstname.length+a[d].lastname.length?d.toString()+"-":d,e=lsi.get("p_mini-fiches",b),null==e&&(e=this.defaultData,e.valid=!1,isNaN(b)&&(e.reltype="9")),e.uid=parseInt(d),lsi.set("p_mini-fiches",b,e));
e=lsi["export"]("p_mini-fiches");if(null==e[this.selected])for(d in e)if(!isNaN(d)){this.selected=parseInt(d);break}};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.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("p_contacts"),b=lsi["export"]("p_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("p_mini-fiches",e):(b=0==a[e].username.length?e.toString()+"-":e,d=lsi.get("p_mini-fiches",b),null==d&&(d=this.defaultData,d.valid=!1,isNaN(b)&&(d.reltype="9")),d.uid=parseInt(e),lsi.set("p_mini-fiches",b,d));d=lsi["export"]("p_mini-fiches");if(null==
d[this.selected])for(e in d)if(!isNaN(e)){this.selected=parseInt(e);break}};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 [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 [data-n="'+this.selected+'"]'))};
inputPhoneMini.prototype.check=function(a){return""==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.log("MINI FICHE: ATTACH");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)};

View File

@ -130,7 +130,7 @@ inputPhoneMini.prototype.add = function(objectData){
// {2} Création physique //
this.container.innerHTML += pMiniFicheBuilder.build({
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
name: associatedContact.username,
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,
@ -240,7 +240,7 @@ inputPhoneMini.prototype.sync = function(){
}
/* (5) Si le contact n'a aucun nominatif, on met inconnu par défaut, mais on ne l'affiche pas */
var noName = contactData[key].username.length+contactData[key].firstname.length+contactData[key].lastname.length == 0;
var noName = contactData[key].username.length == 0;
// On rajoute un '.' après pour dire qu'on affichera pas
var uid = noName ? key.toString()+'-' : key;

View File

@ -1,4 +1,3 @@
function inputPhoneSubject(a,b,c,d,e,f){this.tmp_id=a;this.number=b;this.username=c;this.firstname=d;this.lastname=e;this.store_button=f}inputPhoneSubject.prototype={store_button:this.store_button,tmp_id:this.tmp_id,number:this.number,username:this.username,firstname:this.firstname,lastname:this.lastname};inputPhoneSubject.prototype.check=function(){var a=0<this.number.value.length;return a=a&&0<this.username.value.length+this.firstname.value.length+this.lastname.value.length};
inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("p_subject",0,{tmp_id:this.tmp_id.value,number:this.number.value,username:this.username.value,firstname:this.firstname.value,lastname:this.lastname.value})};
inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("p_subject",0);null==a&&(a={tmp_id:"",number:"",username:"",firstname:"",lastname:""});this.tmp_id.value=a.tmp_id;this.number.value=a.number;this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
inputPhoneSubject.prototype.attach=function(){function a(a){b.fieldsToStorage()&&b.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("p_subject");var b=this;this.store_button.addEventListener("click",a,!1);this.number.addEventListener("blur",a,!1);this.username.addEventListener("blur",a,!1);this.firstname.addEventListener("blur",a,!1);this.lastname.addEventListener("blur",a,!1);this.storageToFields()};
function inputPhoneSubject(a,b,c,d){this.tmp_id=a;this.number=b;this.username=c;this.store_button=d}inputPhoneSubject.prototype={store_button:this.store_button,tmp_id:this.tmp_id,number:this.number,username:this.username};inputPhoneSubject.prototype.check=function(){return 0<this.number.value.length&&0<this.username.value.length};
inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("p_subject",0,{tmp_id:this.tmp_id.value,number:this.number.value,username:this.username.value})};inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("p_subject",0);null==a&&(a={tmp_id:"",number:"",username:""});this.tmp_id.value=a.tmp_id;this.number.value=a.number;this.username.value=a.username};
inputPhoneSubject.prototype.attach=function(){function a(a){b.fieldsToStorage()&&b.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("p_subject");var b=this;this.store_button.addEventListener("click",a,!1);this.number.addEventListener("blur",a,!1);this.username.addEventListener("blur",a,!1);this.storageToFields()};

View File

@ -1,11 +1,9 @@
/* [0] Constructeur -> définit le conteneur et le bouton d'ajout
=========================================================*/
function inputPhoneSubject(iTmpId, iNumber, iUsername, iFirstname, iLastname, store_button){
function inputPhoneSubject(iTmpId, iNumber, iUsername, store_button){
this.tmp_id = iTmpId;
this.number = iNumber;
this.username = iUsername;
this.firstname = iFirstname;
this.lastname = iLastname;
this.store_button = store_button;
}
@ -16,9 +14,7 @@ inputPhoneSubject.prototype = {
store_button: this.store_button, // Bouton d'ajout d'un formulaire
tmp_id: this.tmp_id,
number: this.number,
username: this.username,
firstname: this.firstname,
lastname: this.lastname
username: this.username
};
@ -26,13 +22,7 @@ inputPhoneSubject.prototype = {
=========================================================*/
inputPhoneSubject.prototype.check = function(){
/* (1) Le numéro n'est pas vide */
var validForm = this.number.value.length > 0;
/* (2) ET le pseudo et/ou le prénom et/ou le nom n'est pas vide */
validForm = validForm && this.username.value.length+this.firstname.value.length+this.lastname.value.length > 0;
// On renvoie la validité du formulaire
return validForm;
return this.number.value.length > 0 && this.username.value.length> 0;
};
/* [3] Gestion de l'enregistrement des formulaires de contact
@ -47,9 +37,7 @@ inputPhoneSubject.prototype.fieldsToStorage = function(){
var obj = {
tmp_id: this.tmp_id.value,
number: this.number.value,
username: this.username.value,
firstname: this.firstname.value,
lastname: this.lastname.value
username: this.username.value
};
// {3} On enregistre les données dans le 'localStorage' //
@ -71,14 +59,12 @@ inputPhoneSubject.prototype.storageToFields = function(){
var subjectData = lsi.get('p_subject', 0);
if( subjectData == null )
subjectData = { tmp_id: '', number: '', username: '', firstname: '', lastname: '' };
subjectData = { tmp_id: '', number: '', username: '' };
// {2} On restore les valeurs //
this.tmp_id.value = subjectData.tmp_id;
this.number.value = subjectData.number;
this.username.value = subjectData.username;
this.firstname.value = subjectData.firstname;
this.lastname.value = subjectData.lastname;
};
@ -101,10 +87,8 @@ inputPhoneSubject.prototype.attach = function(){
this.store_button.addEventListener('click', fts, false);
/* (3) On attache un évènement de 'blur' sur chaque '<input type="text">' */
this.number.addEventListener( 'blur', fts, false);
this.username.addEventListener( 'blur', fts, false);
this.firstname.addEventListener( 'blur', fts, false);
this.lastname.addEventListener( 'blur', fts, false);
this.number.addEventListener( 'blur', fts, false);
this.username.addEventListener( 'blur', fts, false);
/* (4) On charge le sujet depuis la mémoire ('localStorage') */
this.storageToFields();

View File

@ -10,47 +10,6 @@
class input{
/* AFFICHE UN NOM EXPLICITE A PARTIR DE @u username, @f firstname, et @l lastname
*
*/
private static function readableName($u, $f, $l){
/* (1) On calcule les tailles des chaines */
$ul = strlen($u);
$fl = strlen($f);
$ll = strlen($l);
/* (2) Si @username n'est pas vide */
if( $ul > 0 ){
/* (3) Si @username+(@firstname et/ou @lastname) -> username (firstname lastname) */
if( $fl+$ll > 0 )
return $u.' ('.trim($f.' '.$l).')';
/* (4) Si @username uniquement -> username */
else
return $u;
/* (5) Si pas @username */
}else{
/* (6) Si @firstname et/ou @lastname -> firstname lastname*/
if( $fl+$ll > 0 )
return trim($f.' '.$l);
/* (7) Si rien -> Inconnu */
else
return 'Inconnu';
}
}
/* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE TÉLÉPHONIQUE
*
* @subject<Array> Tableau contenant les données du sujet
@ -123,7 +82,7 @@
=========================================================*/
$file['subject'] = array(
'id' => $offset + $subject_id,
'name' => self::readableName($subject['username'], $subject['firstname'], $subject['lastname'])
'name' => $subject['username']
);
@ -141,7 +100,7 @@
// On remplit les données qui iront dans le fichier pour ce contact
array_push($file['contacts'], array(
'id' => $offset + $miniData['uid'],
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
'name' => $contact['username'],
'sexe' => $miniData['sexe'],
'age' => $miniData['age'],
'studies1' => $miniData['studies'],
@ -164,7 +123,7 @@
// On remplit les données qui iront dans le fichier pour ce contact
array_push($file['contacts'], array(
'id' => $offset + $ficheData['uid'],
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
'name' => $contact['username'],
'sexe' => $ficheData['sexe'],
'age' => $ficheData['age'],
'studies2' => $ficheData['studies'],
@ -301,7 +260,7 @@
=========================================================*/
$file['subject'] = array(
'id' => $offset + $subject_id,
'name' => self::readableName($subject['username'], $subject['firstname'], $subject['lastname'])
'name' => $subject['username']
);
@ -319,7 +278,7 @@
// On remplit les données qui iront dans le fichier pour ce contact
array_push($file['contacts'], array(
'id' => $offset + $miniData['uid'],
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
'name' => $contact['username'],
'sexe' => $miniData['sexe'],
'age' => $miniData['age'],
'studies1' => $miniData['studies'],
@ -342,7 +301,7 @@
// On remplit les données qui iront dans le fichier pour ce contact
array_push($file['contacts'], array(
'id' => $offset + $ficheData['uid'],
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
'name' => $contact['username'],
'sexe' => $ficheData['sexe'],
'age' => $ficheData['age'],
'studies2' => $ficheData['studies'],

View File

@ -13,8 +13,8 @@
/* RENVOIE LE CHEMIN D'UN fichier
*
* @prefix<String> Préfixe (dossier parent) du fichier
* @extension<String> Extension du fichier
* @prefix<String> Préfixe (dossier parent) du fichier
* @extension<String> Extension du fichier
*
* @return response<Array> Renvoie le chemin du fichier, ainsi qu'une erreur de 'ManagerError'
*
@ -24,41 +24,41 @@
if( !connected() ) return array( 'error' => ManagerError::PermissionError );
/* [1] Chargement du fichier de config
=========================================================*/
/* (1) On récupère le fichier */
$uploadAuth = ResourceDispatcher::getResource('f/json/upload-auth/conf');
=========================================================*/
/* (1) On récupère le fichier */
$uploadAuth = ResourceDispatcher::getResource('f/json/upload-auth/conf');
/* (2) Si une erreur pour le fichier de conf */
if( $uploadAuth === false )
return array( 'error' => ManagerError::UnreachableResource );
/* (2) Si une erreur pour le fichier de conf */
if( $uploadAuth === false )
return array( 'error' => ManagerError::UnreachableResource );
/* (3) On récupère la config sous forme de tableau */
$uploadAuth = json_decode( $uploadAuth, true );
/* (3) On récupère la config sous forme de tableau */
$uploadAuth = json_decode( $uploadAuth, true );
/* (4) Si erreur de PARSAGE */
if( !is_array($uploadAuth) )
return array( 'error' => ManagerError::ParsingFailed );
/* (4) Si erreur de PARSAGE */
if( !is_array($uploadAuth) )
return array( 'error' => ManagerError::ParsingFailed );
/* [2] Vérification du préfixe
=========================================================*/
// Si le préfixe n'est pas dans la config -> erreur
if( !in_array($prefix, $uploadAuth['directories']) )
return array( 'error' => ManagerError::UploadError );
/* [2] Vérification du préfixe
=========================================================*/
// Si le préfixe n'est pas dans la config -> erreur
if( !in_array($prefix, $uploadAuth['directories']) )
return array( 'error' => ManagerError::UploadError );
/* [3] Construction du chemin
=========================================================*/
/* (1) On construit le chemin */
$path = __ROOT__.$uploadAuth['root'].'/'.$prefix.'/';
/* [3] Construction du chemin
=========================================================*/
/* (1) On construit le chemin */
$path = __ROOT__.$uploadAuth['root'].'/'.$prefix.'/';
/* (2) On crée le dossier s'il n'existe pas */
if ( !file_exists($path) ) mkdir($path, 0775, true);
/* (2) On crée le dossier s'il n'existe pas */
if ( !file_exists($path) ) mkdir($path, 0775, true);
/* (3) On construit le nom du fichier */
$fileName = $_SESSION['username'].'.'.$extension;
/* (3) On construit le nom du fichier */
$fileName = $_SESSION['username'].'.'.$extension;
/* (4) On se place dans le dossier */
chdir( $path );
/* (4) On se place dans le dossier */
chdir( $path );
/* [4] Gestion du retour
@ -73,17 +73,17 @@
/* EFFECTUE UN UPLOAD D'UN fichier
*
* @prefix<String> Préfixe (dossier parent) du fichier
* @extension<String> Extension du fichier
* @file<FILE> Pointeur vers $_FILES['']
* @tester<Function> Fonction qui renvoie TRUE si le format est correct (en prenant le contenu du fichier en paramètre)
*
* @return error<ManagerError> Retourne l'erreur attestant de l'état de l'upload
*
*/
private static function simpleFile($prefix, $extension, $file, $tester){
/* EFFECTUE UN UPLOAD D'UN fichier
*
* @prefix<String> Préfixe (dossier parent) du fichier
* @extension<String> Extension du fichier
* @file<FILE> Pointeur vers $_FILES['']
* @tester<Function> Fonction qui renvoie TRUE si le format est correct (en prenant le contenu du fichier en paramètre)
*
* @return error<ManagerError> Retourne l'erreur attestant de l'état de l'upload
*
*/
private static function simpleFile($prefix, $extension, $file, $tester){
// Si on est pas connecté, on retourne une erreur -> impossible via token
if( !connected() ) return array( 'error' => ManagerError::PermissionError );
@ -111,18 +111,18 @@
}
/* [3] Création du fichier (temporaire->permanent)
=========================================================*/
/* [3] Création du fichier (temporaire->permanent)
=========================================================*/
/* (1) On déplace le fichier avec le nom formel */
if( move_uploaded_file($file['tmp_name'], $pathResponse['path']) ){
// on modifie les droits du fichier
chmod($pathResponse['path'], 0774);
if( move_uploaded_file($file['tmp_name'], $pathResponse['path']) ){
// on modifie les droits du fichier
chmod($pathResponse['path'], 0774);
return ManagerError::Success;
/* (2) Si une erreur occure -> 'UploadError' */
}else
return ManagerError::UploadError;
}
}else
return ManagerError::UploadError;
}
@ -136,17 +136,17 @@
/* IMPORT D'UN JOURNAL D'APPEL
*
* @file<FILE> Pointeur vers $_FILES['']
*
*/
public static function call_log($params){
extract($params);
/* IMPORT D'UN JOURNAL D'APPEL
*
* @file<FILE> Pointeur vers $_FILES['']
*
*/
public static function call_log($params){
extract($params);
/* [1] Gestion de l'upload du fichier et de la vžérification du format
=========================================================*/
$uploadError = self::simpleFile(
$uploadError = self::simpleFile(
'call_log', // nom du dossier d'upload
'xml', // format du fichier
$file, // Fichier lui-même
@ -195,7 +195,7 @@
array( 'ModuleError' => $response->error ),
$response->getAll()
);
}
}
@ -216,17 +216,17 @@
/* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL
*
* @file<FILE> Pointeur vers $_FILES['']
*
*/
public static function local_data($params){
extract($params);
/* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL
*
* @file<FILE> Pointeur vers $_FILES['']
*
*/
public static function local_data($params){
extract($params);
/* [1] Upload et vérifiaction du format du fichier
=========================================================*/
$uploadError = self::simpleFile(
$uploadError = self::simpleFile(
'local_data', // nom du dossier d'upload
'json', // format du fichier
$file, // Fichier lui-même
@ -252,9 +252,6 @@
/* (3) Vérification du sujet */
$checkSubject = isset($json['subject']['tmp_id']) && ( is_string($json['subject']['tmp_id']) || is_null($json['subject']['tmp_id']) );
$checkSubject = $checkSubject && isset($json['subject']['username']) && is_string($json['subject']['username']);
$checkSubject = $checkSubject && isset($json['subject']['firstname']) && is_string($json['subject']['firstname']);
$checkSubject = $checkSubject && isset($json['subject']['lastname']) && is_string($json['subject']['lastname']);
$checkSubject = $checkSubject && isset($json['subject']['number']) && is_string($json['subject']['number']);
// Erreur des attributs du sujet incorrects ou manquants
if( !$checkSubject )
@ -265,9 +262,6 @@
foreach($json['contacts'] as $contact){
$checkContact = isset($contact['uid']) && is_numeric($contact['uid']);
$checkContact = $checkContact && isset($contact['username']) && is_string($contact['username']);
$checkContact = $checkContact && isset($contact['firstname']) && is_string($contact['firstname']);
$checkContact = $checkContact && isset($contact['lastname']) && is_string($contact['lastname']);
$checkContact = $checkContact && isset($contact['number']) && ( is_numeric($contact['number']) || is_string($contact['number']) );
$checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']);
$checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']);
$checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']);
@ -367,7 +361,7 @@
'ModuleError' => ManagerError::Success,
'local_data' => $json
);
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -45,14 +45,11 @@
<h3 data-n='1' class='color4'>Identifier l'enquêté</h3>
<span data-space></span>
<h5 data-text="Renseigner au moins un des nominatifs pour chaque contact. (pseudo, prénom et/ou nom)"></h5>
<article class='subject-panel'>
<h4 class='self color2' data-icon='a'>
<input type='hidden' data-name='tmp_id' value=''>
<input type='text' data-name='number' id='p_subject_phone_number' placeholder='Numéro de téléphone'>
<input type='text' data-name='username' placeholder='Pseudo'>
<input type='text' data-name='firstname' placeholder='Prénom'>
<input type='text' data-name='lastname' placeholder='Nom'>
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
</h4>
</article>
@ -76,9 +73,6 @@
<!-- GESTION DE L'AJOUT DES CONTACTS -->
<span data-space></span>
<h5 data-text="Renseigner au moins un des nominatifs pour chaque contact. (pseudo, prénom et/ou nom)"></h5>
<span data-space></span>
<div class='arrow-container line' id='p_nav-contact'></div>
@ -170,12 +164,9 @@
<h3 data-n='1' class='color4'>Identifier l'enquêté</h3>
<span data-space></span>
<h5 data-text="Renseigner au moins un des nominatifs pour chaque amis. (pseudo, prénom et/ou nom)"></h5>
<article class='subject-panel'>
<h4 class='self color2' data-icon='a'>
<input type='text' data-name='username' placeholder='Pseudo'>
<input type='text' data-name='firstname' placeholder='Prénom'>
<input type='text' data-name='lastname' placeholder='Nom'>
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
</h4>
</article>

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

@ -1,27 +1,24 @@
function readableName(a,c,b){var e=c.length,d=b.length;return 0<a.length?0<e+d?a+" ("+(c+" "+b).trim()+")":a:0<e+d?(c+" "+b).trim():"Inconnu"}var cSubjectManager,cContactManager,cMiniManager,cFicheManager,cMatriceManager;
function cDynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,e=c&&"SPAN"==a.tagName&&"switch-both"==a.className,d=c&&"INPUT"==a.tagName&&"submit"==a.type,f=c&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!(e||b||d||f||c)&&!0!==a)return!1;if(e)console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[8],b=b.children[10],e=a.value,a.value=b.value,
b.value=e;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNode;e=b.children[6];a=b.children[8];b=b.children[10];if(0<e.value.length||0==a.value.length&&0==b.value.length)return!1;e.value=a.value+" "+b.value;a.value="";b.value=""}else console.log("> dynamic update"),cMiniManager.fieldsToStorage(),cFicheManager.fieldsToStorage(),cContactManager.fieldsToStorage(),cMatriceManager.fieldsToStorage(),cFicheManager.sync(),cMiniManager.sync(),cMiniManager.storageToFields(),cFicheManager.storageToFields(),
cMatriceManager.storageToFields(),(d||c)&&cContactManager.storageToFields()}
var cSubjectManager,cContactManager,cMiniManager,cFicheManager,cMatriceManager;
function cDynamicUpdate(b){var a=b instanceof Element,d=a&&"INPUT"==b.tagName&&"submit"==b.type,e=a&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!d&&!e&&!a&&!0!==b)return!1;console.log("> dynamic update");cMiniManager.fieldsToStorage();cFicheManager.fieldsToStorage();cContactManager.fieldsToStorage();cMatriceManager.fieldsToStorage();cFicheManager.sync();cMiniManager.sync();cMiniManager.storageToFields();
cFicheManager.storageToFields();cMatriceManager.storageToFields();(d||a)&&cContactManager.storageToFields()}
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",function(){cSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="username"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="firstname"]'),$('[data-sublink="phone"] article.subject-panel [data-name="lastname"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));cSubjectManager.attach();cContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));cContactManager.attach(cDynamicUpdate);cMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),
$('[data-sublink="phone"] #p_nav-mini'));cMiniManager.attach(cDynamicUpdate);cFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));cFicheManager.attach(cDynamicUpdate);cMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));cMatriceManager.attach(cDynamicUpdate);$('[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){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur","Il est n\u00e9cessaire de saisir les informations du <b>sujet</b> avant d'exporter son journal d'appel"):Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");cSubjectManager.tmp_id.value=a.tmp_id;cSubjectManager.fieldsToStorage();
cSubjectManager.storageToFields();for(var e=0;e<a.call.length;e++){var d=a.directory[a.call[e]],f=d.name.split(" ");lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:1==f.length?f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:e,sms:-1})}for(e=0;e<a.sms.length;e++)d=a.directory[a.sms[e]],-1<a.call.indexOf(a.sms[e])?(f=lsi.get("p_contacts",d.id),f.sms=e,lsi.set("p_contacts",d.id,f)):(f=d.name.split(" "),lsi.set("p_contacts",
d.id,{uid:d.id,number:d.number,username:1==f.length?f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:-1,sms:e}));for(var g in a.directory)g=parseInt(g),-1<a.call.indexOf(g)||-1<a.sms.indexOf(g)||(d=a.directory[g],f=d.name.split(" "),lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:1==f.length?f[0]:"",firstname:1<f.length?f[0]:"",lastname:1<f.length?f.splice(1).join(" "):"",countsms:d.sms,countcall:d.call,call:-1,sms:-1}));
cContactManager.storageToFields();cDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[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");cSubjectManager.storageToFields();cContactManager.storageToFields();cMiniManager.storageToFields();cFicheManager.storageToFields();cMatriceManager.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 c=$('[data-sublink="phone"] #p_download-target');c.download="local-phone-data.json";
c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.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);cSubjectManager.storageToFields();cContactManager.storageToFields();cMatriceManager.storageToFields();cDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");cSubjectManager.fieldsToStorage();cContactManager.fieldsToStorage();cMiniManager.fieldsToStorage();cFicheManager.fieldsToStorage();if(!cSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var c=0,b;for(b in a)if(!isNaN(b)&&(c++,!a[b].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+c+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;b={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(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})});var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,e=c&&"SPAN"==a.tagName&&"switch-both"==a.className,d=c&&"INPUT"==a.tagName&&"submit"==a.type,f=c&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!(e||b||d||f||c)&&!0!==a)return!1;if(e)console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[2],b=b.children[3],e=a.value,a.value=b.value,
b.value=e;else if(b){console.log("> switch firstname+lastname -> username");b=a.parentNode;e=b.children[1];a=b.children[2];b=b.children[3];if(0<e.value.length||0==a.value.length&&0==b.value.length)return!1;e.value=a.value+" "+b.value;a.value="";b.value=""}else console.log("> dynamic update"),fMiniManager.fieldsToStorage(),fFicheManager.fieldsToStorage(),fContactManager.fieldsToStorage(),fMatriceManager.fieldsToStorage(),fFicheManager.sync(),fMiniManager.sync(),fMiniManager.storageToFields(),fFicheManager.storageToFields(),
fMatriceManager.storageToFields(),(d||c)&&fContactManager.storageToFields()}
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="username"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="firstname"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="lastname"]'),
$('[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 c=$('[data-sublink="facebook"] #f_download-target');c.download="local-facebook-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.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 c=0,b;for(b in a)if(!isNaN(b)&&
(c++,!a[b].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+c+"</b> est incompl\u00e8te et/ou incorrecte"),!1;b={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(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})});
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));cSubjectManager.attach();cContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));cContactManager.attach(cDynamicUpdate);cMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));cMiniManager.attach(cDynamicUpdate);cFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
$('[data-sublink="phone"] #p_nav-fiche'));cFicheManager.attach(cDynamicUpdate);cMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));cMatriceManager.attach(cDynamicUpdate);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(b){b.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(b){b={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,
file:b.target.files[0]};api.send(b,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur","Il est n\u00e9cessaire de saisir les informations du <b>sujet</b> avant d'exporter son journal d'appel"):Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");cSubjectManager.tmp_id.value=a.tmp_id;cSubjectManager.fieldsToStorage();cSubjectManager.storageToFields();for(var e=0;e<a.call.length;e++){var c=a.directory[a.call[e]];
lsi.set("p_contacts",c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:e,sms:-1})}for(e=0;e<a.sms.length;e++)if(c=a.directory[a.sms[e]],-1<a.call.indexOf(a.sms[e])){var g=lsi.get("p_contacts",c.id);g.sms=e;lsi.set("p_contacts",c.id,g)}else lsi.set("p_contacts",c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:-1,sms:e});for(var f in a.directory)f=parseInt(f),-1<a.call.indexOf(f)||-1<a.sms.indexOf(f)||(c=a.directory[f],lsi.set("p_contacts",
c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:-1,sms:-1}));cContactManager.storageToFields();cDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(b){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");cSubjectManager.storageToFields();cContactManager.storageToFields();cMiniManager.storageToFields();
cFicheManager.storageToFields();cMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={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 a=$('[data-sublink="phone"] #p_download-target');a.download="local-phone-data.json";a.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));a.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(b){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(b){b.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(b){b=
{path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(b,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);cSubjectManager.storageToFields();cContactManager.storageToFields();cMatriceManager.storageToFields();
cDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(b){console.log("> GATHERING ALL DATA");cSubjectManager.fieldsToStorage();cContactManager.fieldsToStorage();cMiniManager.fieldsToStorage();cFicheManager.fieldsToStorage();if(!cSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;b=lsi["export"]("p_mini-fiches");var a=0,d;for(d in b)if(!isNaN(d)&&(a++,!b[d].valid))return Notification.warning("Attention",
"La <i>fiche rapide</i> <b>"+a+"</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;console.log(a)},!1)},!1)})})})})});var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(b){var a=b instanceof Element,d=a&&"INPUT"==b.tagName&&"submit"==b.type,e=a&&"SPAN"==b.tagName&&("f_nav-mini"==b.parentNode.id||"f_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"f_nav-contact"==b.parentNode.id;if(!d&&!e&&!a&&!0!==b)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(d||a)&&fContactManager.storageToFields()}
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="username"]'),$('[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(b){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(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var a=$('[data-sublink="facebook"] #f_download-target');a.download="local-facebook-data.json";
a.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));a.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(b){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(b){b.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(b){b={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
api.send(b,function(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(b){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;b=lsi["export"]("f_mini-fiches");var a=0,d;for(d in b)if(!isNaN(d)&&(a++,!b[d].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+a+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;d={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(d,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})});

View File

@ -1,41 +1,3 @@
/* AFFICHE UN NOM EXPLICITE A PARTIR DE @u username, @f firstname, et @l lastname
*
*/
function readableName(u, f, l){
/* (1) On calcule les tailles des chaines */
var ul = u.length,
fl = f.length,
ll = l.length;
/* (2) Si @username n'est pas vide */
if( ul > 0 ){
/* (3) Si @username+(@firstname et/ou @lastname) -> username (firstname lastname) */
if( fl+ll > 0 )
return u+' ('+(f+' '+l).trim()+')';
/* (4) Si @username uniquement -> username */
else
return u;
/* (5) Si pas @username */
}else{
/* (6) Si @firstname et/ou @lastname -> firstname lastname*/
if( fl+ll > 0 )
return (f+' '+l).trim();
/* (7) Si rien -> Inconnu */
else
return 'Inconnu';
}
}
/*=========================================================*/
/*********** Gestion du formulaire téléphonique ************/
/*=========================================================*/
@ -56,92 +18,46 @@ function cDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSwitchLeft = isElement && target.tagName == 'SPAN' && target.className == 'switch-left';
var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both';
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'p_nav-mini' || target.parentNode.id == 'p_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'p_nav-contact';
// Si erreur, on retourne une erreur
if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true )
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
/* (1) Gestion de l'échange de nom/prénom
---------------------------------------------------------*/
if( isSwitchBoth ){
console.log('> switch firstname <-> lastname');
/* (1) On récupère le formulaire parent */
var currentForm = target.parentNode;
console.log('> dynamic update');
/* (2) On récupère Nom et Prénom */
var firstname = currentForm.children[8];
var lastname = currentForm.children[10];
/* (1) On enregistre les MINI fiches relation */
cMiniManager.fieldsToStorage();
/* (3) On échange leurs valeurs */
var tmp = firstname.value;
firstname.value = lastname.value;
lastname.value = tmp;
/* (2) On enregister les FICHES relation */
cFicheManager.fieldsToStorage();
}else if( isSwitchLeft ){
/* (2) Gestion de l'échange Prénom+Nom = Pseudo
---------------------------------------------------------*/
console.log('> switch firstname+lastname -> username');
/* (3) On enregistre les CONTACTS */
cContactManager.fieldsToStorage();
/* (1) On récupère le formulaire parent */
var currentForm = target.parentNode;
/* (4) On enregistre la MATRICE */
cMatriceManager.fieldsToStorage();
/* (2) On récupère Pseudo, Nom et Prénom */
var username = currentForm.children[6];
var firstname = currentForm.children[8];
var lastname = currentForm.children[10];
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
cFicheManager.sync();
/* (3) Vérification de la validité */
// Si pseudo pas vide, ou nom et prenom vide -> on ne fais rien
if( username.value.length > 0 || firstname.value.length == 0 && lastname.value.length == 0 )
return false;
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
cMiniManager.sync();
/* (4) On attribue à Pseudo, la valeur de Prénom+Nom */
username.value = firstname.value +' '+ lastname.value;
firstname.value = '';
lastname.value = '';
/* (7) On affiche le tout */
cMiniManager.storageToFields();
cFicheManager.storageToFields();
cMatriceManager.storageToFields();
/* (3) Gestion de la mise à jour dynamique
---------------------------------------------------------*/
}else{
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
cMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
cFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
cContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
cMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
cFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
cMiniManager.sync();
/* (7) On affiche le tout */
cMiniManager.storageToFields();
cFicheManager.storageToFields();
cMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
cContactManager.storageToFields();
}
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
cContactManager.storageToFields();
}
@ -173,8 +89,6 @@ include('/js/includes/input-phone-matrice.js', function(){
$('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="username"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="firstname"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="lastname"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')
);
@ -288,14 +202,10 @@ include('/js/includes/input-phone-matrice.js', function(){
// Données du cnotact
var conData = response.directory[ response.call[i] ];
var splittedName = conData.name.split(' ');
lsi.set('p_contacts', conData.id, {
uid: conData.id,
number: conData.number,
username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo
firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom
username: conData.name, // nom
countsms: conData.sms, // Nombre de sms
countcall: conData.call, // Nombre d'appels
call: i, // classement dans le top 10 des APPELS
@ -321,15 +231,11 @@ include('/js/includes/input-phone-matrice.js', function(){
continue;
}
var splittedName = conData.name.split(' ');
lsi.set('p_contacts', conData.id, {
uid: conData.id,
number: conData.number,
username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo
firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom
username: conData.name, // nom
countsms: conData.sms, // Nombre de sms
countcall: conData.call, // Nombre d'appels
call: -1, // classement dans le top 10 des APPELS
@ -354,16 +260,11 @@ include('/js/includes/input-phone-matrice.js', function(){
// On récupère les données du contact
var conData = response.directory[id];
// On découpe le nom par espaces
var splittedName = conData.name.split(' ');
lsi.set('p_contacts', conData.id, {
uid: conData.id,
number: conData.number,
username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo
firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom
username: conData.name, // nom
countsms: conData.sms, // Nombre de sms
countcall: conData.call, // Nombre d'appels
call: -1,
@ -664,92 +565,46 @@ function fDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSwitchLeft = isElement && target.tagName == 'SPAN' && target.className == 'switch-left';
var isSwitchBoth = isElement && target.tagName == 'SPAN' && target.className == 'switch-both';
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
// Si erreur, on retourne une erreur
if( !isSwitchBoth && !isSwitchLeft && !isSaveButton && !isNavButton && !isNavContact && target !== true )
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
/* (1) Gestion de l'échange de nom/prénom
---------------------------------------------------------*/
if( isSwitchBoth ){
console.log('> switch firstname <-> lastname');
console.log('> dynamic update');
/* (1) On récupère le formulaire parent */
var currentForm = target.parentNode;
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On récupère Nom et Prénom */
var firstname = currentForm.children[2];
var lastname = currentForm.children[3];
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On échange leurs valeurs */
var tmp = firstname.value;
firstname.value = lastname.value;
lastname.value = tmp;
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
}else if( isSwitchLeft ){
/* (2) Gestion de l'échange Prénom+Nom = Pseudo
---------------------------------------------------------*/
console.log('> switch firstname+lastname -> username');
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (1) On récupère le formulaire parent */
var currentForm = target.parentNode;
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (2) On récupère Pseudo, Nom et Prénom */
var username = currentForm.children[1];
var firstname = currentForm.children[2];
var lastname = currentForm.children[3];
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (3) Vérification de la validité */
// Si pseudo pas vide, ou nom et prenom vide -> on ne fais rien
if( username.value.length > 0 || firstname.value.length == 0 && lastname.value.length == 0 )
return false;
/* (7) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (4) On attribue à Pseudo, la valeur de Prénom+Nom */
username.value = firstname.value +' '+ lastname.value;
firstname.value = '';
lastname.value = '';
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
/* (3) Gestion de la mise à jour dynamique
---------------------------------------------------------*/
}else{
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) 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();
}
}
@ -779,8 +634,6 @@ include('/js/includes/input-facebook-matrice.js', function(){
/* (1) On crée une instance du manager du sujet */
fSubjectManager = new inputFacebookSubject(
$('[data-sublink="facebook"] article.subject-panel [data-name="username"]'),
$('[data-sublink="facebook"] article.subject-panel [data-name="firstname"]'),
$('[data-sublink="facebook"] article.subject-panel [data-name="lastname"]'),
$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')
);