Optimisation, on ne charge qu'une fois les contacts

This commit is contained in:
xdrm-brackets 2016-04-28 18:49:49 +02:00
parent 092a09088f
commit c053ebd155
9 changed files with 61 additions and 41 deletions

View File

@ -1,4 +1,5 @@
function inputPhoneContact(a){this.container=a}inputPhoneContact.prototype={container:this.container,handler:null}; function inputPhoneContact(a){this.container=a}inputPhoneContact.prototype={container:this.container,handler:null};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),b=0;b<a.length;b++){var d=a[b].parentNode.children.indexOf(a[b]),c=(new FormDeflater(a[b],["input"],["data-name"])).deflate(),e=0<c.number.value.length;(e=e&&0<c.username.value.length+c.firstname.value.length+c.lastname.value.length)&&lsi.set("contacts","form"+d,{uid:d,number:c.number.value,username:c.username.value,firstname:c.firstname.value,lastname:c.lastname.value})}}; inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$("article.contact-panel .new-contact"),c=0;c<a.length;c++){var d=a[c].parentNode.children.indexOf(a[c]),b=(new FormDeflater(a[c],["input"],["data-name"])).deflate(),e=0<b.number.value.length;if(e=e&&0<b.username.value.length+b.firstname.value.length+b.lastname.value.length)b={uid:d,number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value},b.hash=
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");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:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var b=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){b.handler(a.target)},!1),a[d].addEventListener("click",function(a){b.handler(a.target)},!1)}; crc32(JSON.stringify(b)),lsi.set("contacts","form"+d,b)}};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var b in a)this.add(a[b]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a;this.storageToFields()}; inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");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:"";this.container.innerHTML+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");for(var c=this,d=0;d<a.length;d++)a[d].removeEventListener("click",function(a){c.handler(a.target)},!1),a[d].addEventListener("click",function(a){c.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi["export"]("contacts");this.container.innerHTML="";for(var c in a)this.add(a[c]);this.add({number:"",firstname:"",lastname:"",username:""})};inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("contacts");this.handler=a;this.storageToFields()};

View File

@ -47,7 +47,10 @@ inputPhoneContact.prototype.fieldsToStorage = function(){
lastname: deflated.lastname.value lastname: deflated.lastname.value
}; };
// {6} On enregistre les données dans le 'localStorage' // /* (6) On calcule et ajoute le hash des données */
obj.hash = crc32( JSON.stringify(obj) );
// {7} On enregistre les données dans le 'localStorage' //
lsi.set('contacts', 'form'+indexInParent, obj); lsi.set('contacts', 'form'+indexInParent, obj);
} }

View File

@ -1,11 +1,10 @@
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:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}}; 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:{firstname:"",lastname:"",username:"",sexe:[{status:!0},{status:!1}],age:"",job:".",loc:[{status:!0},{status:!1},{status:!1},{status:!1}]}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate();console.log(c);var d=lsi.get("mini-fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value, inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate();console.log(c);var d=lsi.get("mini-fiches","form"+c.uid.value);!1===d&&(d.username="inconnu",d.firstname="inconnu",d.lastname="inconnu");c={uid:c.uid.value,firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,
job:c.job.value,loc:c.loc};c.valid=this.check(c);lsi.set("mini-fiches","form"+c.uid,c)}}; job:c.job.value,loc:c.loc};c.valid=this.check(c);lsi.set("mini-fiches","form"+c.uid,c)}};
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+= inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.firstname=null!=a.firstname?a.firstname:this.defaultData.firstname;a.lastname=null!=a.lastname?a.lastname:this.defaultData.lastname;a.username=null!=a.username?a.username:this.defaultData.username;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.job=null!=a.job?a.job:this.defaultData.job;a.loc=null!=a.loc?a.loc:this.defaultData.loc;this.container.innerHTML+=
miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-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");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked", miniFicheBuilder.build({firstname:a.firstname,lastname:a.lastname,username:a.username,uid:a.uid,age:a.age,job:a.job});var b=$('article.mini-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");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length&&b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked",
"checked"):c[b].removeAttribute("checked");c=$$('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<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")}; "checked"):c[b].removeAttribute("checked");c=$$('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<a.loc.length;b++)a.loc[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";this.add(a["form"+this.selected]);this.updateNavBar()};
inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi["export"]("mini-fiches");this.container.innerHTML="";var b=[],c;for(c in a){var d=a[c].uid;d==this.selected&&this.add(a[c]);b.push(d)}this.updateNavBar(b)}; inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){var c=lsi.get("mini-fiches",b);null==c&&(c=this.defaultData,c.valid=!1);console.log(a[b]);c.uid=a[b].uid;c.firstname=a[b].firstname;c.lastname=a[b].lastname;c.username=a[b].username;lsi.set("mini-fiches",b,c)}};
inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1}; inputPhoneMini.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.innerHTML))return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.innerHTML)-1};
inputPhoneMini.prototype.updateNavBar=function(a){if(this.nav_container.children.length!=a.length){this.nav_container.innerHTML="";for(var b=0;b<a.length;b++)this.nav_container.innerHTML+="<span>"+(parseInt(a[b])+1)+"</span>"}a=lsi["export"]("mini-fiches");for(var c in a)!0===a[c].valid?this.nav_container.children[a[c].uid].addClass("done"):this.nav_container.children[a[c].uid].remClass("done");this.nav(this.nav_container.children[this.selected])}; inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),a=Object.keys(a).length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var b=0;b<a;b++)this.nav_container.innerHTML+="<span></span>"}var a=lsi["export"]("mini-fiches"),c;for(c in a)b=this.nav_container.children[a[c].uid],b.innerHTML=a[c].uid+1,!0===a[c].valid?b.addClass("done"):b.remClass("done");this.nav(this.nav_container.children[this.selected])};
inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)}; inputPhoneMini.prototype.check=function(a){return!isNaN(parseInt(a.age))&&checkRadioValue(a.sexe)&&"."!=a.job&&checkRadioValue(a.loc)?!0:!1};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};

View File

@ -65,11 +65,11 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
loc: deflated.loc // [0] Choix 1 -> [3] Choix 4 loc: deflated.loc // [0] Choix 1 -> [3] Choix 4
}; };
/* (6) On vérifie la validité des données et on l'enregistre dans l'objet */ /* (8) On vérifie la validité des données et on l'enregistre dans l'objet */
obj.valid = this.check(obj); obj.valid = this.check(obj);
// {7} On enregistre les données dans le 'localStorage' // /* (9) On enregistre les données dans le 'localStorage' */
lsi.set('mini-fiches', 'form'+obj.uid, obj); lsi.set('mini-fiches', 'form'+obj.uid, obj);
} }
@ -94,7 +94,7 @@ inputPhoneMini.prototype.add = function(objectData){
console.log('MINI FICHE: ADD'); console.log('MINI FICHE: ADD');
// Si pas d'UID, on retourne une erreur // Si pas d'UID, on retourne une erreur
if( objectData.uid == null ) if( objectData == null || objectData.uid == null )
return false; return false;
/* (0) Gestion du formattage des valeur */ /* (0) Gestion du formattage des valeur */
@ -157,24 +157,11 @@ inputPhoneMini.prototype.storageToFields = function(){
// On réinitialise le HTML // On réinitialise le HTML
this.container.innerHTML = ''; this.container.innerHTML = '';
// On récupère les UIDS // {2} On affiche la MINI fiche sélectionnée //
var UIDs = []; this.add(miniData['form'+this.selected]);
for( var key in miniData ){ // {3} On met à jour la navigation //
var uid = miniData[key].uid; this.updateNavBar();
// {3} On affiche la MINI fiche sélectionnée //
if( uid == this.selected )
this.add(miniData[key]);
// {4} On enregistre l'UID //
UIDs.push(uid);
}
// {4} On met à jour la navigation //
this.updateNavBar(UIDs);
}; };
@ -209,8 +196,6 @@ inputPhoneMini.prototype.sync = function(){
miniData.valid = false; miniData.valid = false;
} }
console.log(contactData[key]);
/* (5) On met à jour la MINI fiche */ /* (5) On met à jour la MINI fiche */
miniData.uid = contactData[key].uid; miniData.uid = contactData[key].uid;
miniData.firstname = contactData[key].firstname; miniData.firstname = contactData[key].firstname;
@ -259,26 +244,33 @@ inputPhoneMini.prototype.nav = function(element){
/* [7] Mise à jour de la navigation /* [7] Mise à jour de la navigation
=========================================================*/ =========================================================*/
inputPhoneMini.prototype.updateNavBar = function(uid_list){ inputPhoneMini.prototype.updateNavBar = function(){
var miniData = lsi.export('mini-fiches');
var len = Object.keys(miniData).length;
/* (1) On vérifie si la barre de navigation est à jour */ /* (1) On vérifie si la barre de navigation est à jour */
var navBarUpToDate = this.nav_container.children.length == uid_list.length; var navBarUpToDate = this.nav_container.children.length == len;
/* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */ /* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */
if( !navBarUpToDate ){ if( !navBarUpToDate ){
this.nav_container.innerHTML = ''; this.nav_container.innerHTML = '';
for( var i = 0 ; i < uid_list.length ; i++ ) for( var i = 0 ; i < len ; i++ )
this.nav_container.innerHTML += '<span>'+( parseInt(uid_list[i])+1 )+'</span>'; this.nav_container.innerHTML += '<span></span>';
} }
/* (3) On montre les MINI fiches qui sont correctes dans la navbar */ /* (3) On montre les MINI fiches qui sont correctes dans la navbar */
var miniData = lsi.export('mini-fiches'); var miniData = lsi.export('mini-fiches');
for( var key in miniData ){ for( var key in miniData ){
var currentElement = this.nav_container.children[miniData[key].uid];
currentElement.innerHTML = miniData[key].uid+1;
// Si la MINI fiche est valide // Si la MINI fiche est valide
if( miniData[key].valid === true ) this.nav_container.children[miniData[key].uid].addClass('done'); if( miniData[key].valid === true ) currentElement.addClass('done');
// Si elle est invalide // Si elle est invalide
else this.nav_container.children[miniData[key].uid].remClass('done'); else currentElement.remClass('done');
} }

1
js/lib/crc32-min.js vendored Normal file
View File

@ -0,0 +1 @@
var makeCRCTable=function(){for(var a,d=[],b=0;256>b;b++){a=b;for(var c=0;8>c;c++)a=a&1?3988292384^a>>>1:a>>>1;d[b]=a}return d},crc32=function(a){for(var d=window.crcTable||(window.crcTable=makeCRCTable()),b=-1,c=0;c<a.length;c++)b=b>>>8^d[(b^a.charCodeAt(c))&255];return(b^-1)>>>0};

23
js/lib/crc32.js Normal file
View File

@ -0,0 +1,23 @@
var makeCRCTable = function(){
var c;
var crcTable = [];
for(var n =0; n < 256; n++){
c = n;
for(var k =0; k < 8; k++){
c = ((c&1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
}
crcTable[n] = c;
}
return crcTable;
}
var crc32 = function(str) {
var crcTable = window.crcTable || (window.crcTable = makeCRCTable());
var crc = 0 ^ (-1);
for (var i = 0; i < str.length; i++ ) {
crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF];
}
return (crc ^ (-1)) >>> 0;
};

View File

@ -25,6 +25,7 @@
<!-- Dépendences Javascript --> <!-- Dépendences Javascript -->
<script type='text/javascript' src='/f/js/crc32-min/js/lib' ></script> <!-- Système de hash unique et rapide -->
<script type='text/javascript' src='/f/js/local-storage-interface-min/js/lib' ></script> <!-- Interface de gestion du 'localStorage' --> <script type='text/javascript' src='/f/js/local-storage-interface-min/js/lib' ></script> <!-- Interface de gestion du 'localStorage' -->
<script type='text/javascript' src='/f/js/html-builder-min/js/lib' ></script> <!-- Gestion de construction de HTML --> <script type='text/javascript' src='/f/js/html-builder-min/js/lib' ></script> <!-- Gestion de construction de HTML -->
<script type='text/javascript' src='/f/js/input-checker-min/js/lib' ></script> <!-- Gestion dynamique des saisies --> <script type='text/javascript' src='/f/js/input-checker-min/js/lib' ></script> <!-- Gestion dynamique des saisies -->

View File

@ -1,7 +1,7 @@
var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager; var clearAllButton=$("#clear-all"),importCallLog=$('input#call_log-import[type="file"]'),subjectManager,contactManager,miniManager,ficheManager;
function dynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,d=c&&"SPAN"==a.tagName&&"switch-both"==a.className,e=c&&"INPUT"==a.tagName&&"submit"==a.type,c=c&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!(d||b||e||c)&&!0!==a)return!1;d?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],d=a.value,a.value=b.value,b.value=d):b?(console.log("> switch firstname+lastname -> username"), function dynamicUpdate(a){var c=a instanceof Element,b=c&&"SPAN"==a.tagName&&"switch-left"==a.className,d=c&&"SPAN"==a.tagName&&"switch-both"==a.className,e=c&&"INPUT"==a.tagName&&"submit"==a.type,c=c&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id);if(!(d||b||e||c)&&!0!==a)return!1;d?(console.log("> switch firstname <-> lastname"),b=a.parentNode,a=b.children[3],b=b.children[5],d=a.value,a.value=b.value,b.value=d):b?(console.log("> switch firstname+lastname -> username"),
b=a.parentNode,d=b.children[1],a=b.children[3],b=b.children[5],d.value=a.value+" "+b.value,a.value="",b.value=""):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),contactManager.storageToFields())}function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0} b=a.parentNode,d=b.children[1],a=b.children[3],b=b.children[5],d.value=a.value+" "+b.value,a.value="",b.value=""):(console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields())}function checkRadioValue(a){for(var c=0,b=0;b<a.length;b++)!0===a[b].status&&c++;return 1!=c?!1:!0}
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(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]')); 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(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),$('article.subject-panel [data-name="submit"]'));
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a); subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("h4.add-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);importCallLog.addEventListener("change",function(a){api.send({path:"upload/call_log",file:importCallLog.files[0]},function(a){console.log(a);
0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var d=0;d<a.directory.length;d++){console.log(a.directory[d]);var c=(null===a.directory[d].name?"":a.directory[d].name).split(" ");lsi.set("contacts","form"+d,{uid:d,number:a.directory[d].number,username:1==c.length?c[0]:"",firstname:1<c.length?c[0]:"",lastname:1<c.length?c.splice(1).join(" "):""})}dynamicUpdate(!0)}}))})}, 0==a.ModuleError&&(importCallLog.addClass("active"),a={path:"call_log/unserialize",phone_number:$("#subject_phone_number").value},api.send(a,function(a){console.log(a);if(0==a.ModuleError){for(var d=0;d<a.directory.length;d++){var c=(null===a.directory[d].name?"":a.directory[d].name).split(" ");lsi.set("contacts","form"+d,{uid:d,number:a.directory[d].number,username:1==c.length?c[0]:"",firstname:1<c.length?c[0]:"",lastname:1<c.length?c.splice(1).join(" "):""})}contactManager.storageToFields();dynamicUpdate(!0)}}))})},
!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1)})})})}); !1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1)})})})});

View File

@ -94,7 +94,7 @@ function dynamicUpdate(target){
/* (6) On affiche le tout */ /* (6) On affiche le tout */
miniManager.storageToFields(); miniManager.storageToFields();
ficheManager.storageToFields(); ficheManager.storageToFields();
contactManager.storageToFields(); // contactManager.storageToFields();
} }
} }
@ -214,7 +214,6 @@ include('/js/includes/input-phone-fiche.js', function(){
/* (5) Pour chaque contact de l'annuaire, on ajoute un contact */ /* (5) Pour chaque contact de l'annuaire, on ajoute un contact */
for( var i = 0 ; i < dataResponse.directory.length ; i++ ){ for( var i = 0 ; i < dataResponse.directory.length ; i++ ){
console.log(dataResponse.directory[i]);
// On découpe le nom par espaces // On découpe le nom par espaces
var name = dataResponse.directory[i].name===null ? '' : dataResponse.directory[i].name; var name = dataResponse.directory[i].name===null ? '' : dataResponse.directory[i].name;
@ -230,6 +229,7 @@ include('/js/includes/input-phone-fiche.js', function(){
} }
/* (6) On met à jour l'affichage */ /* (6) On met à jour l'affichage */
contactManager.storageToFields();
dynamicUpdate(true); dynamicUpdate(true);
}); });
} }