Correction et commentaires de `lsi` (localStorageInterface) + Correction de l'erreur quand on efface toutes les données.
This commit is contained in:
parent
9cef4c086b
commit
fe3ee03188
|
@ -1,7 +1,7 @@
|
|||
function inputPhoneContact(a,c){this.container=a;this.nav_container=c}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:1,handler:null};
|
||||
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 b=(new FormDeflater(a[c],["input"],["data-name"])).deflate(),d=0<b.number.value.length;if(d=d&&0<b.username.value.length+b.firstname.value.length+b.lastname.value.length)d={uid:parseInt(b.uid.value),number:b.number.value,username:b.username.value,firstname:b.firstname.value,lastname:b.lastname.value,call:parseInt(b.call.value),
|
||||
sms:parseInt(b.sms.value),countcall:parseInt(b.countcall.value),countsms:parseInt(b.countsms.value)},d.hash=crc32(JSON.stringify(d)),lsi.set("contacts",parseInt(b.uid.value),d)}};
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a.uid||isNaN("number"))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+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");
|
||||
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN("number"))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+=contactBuilder.build(a);a=$$("article.contact-panel .new-contact");
|
||||
for(var c=this,b=0;b<a.length;b++)a[b].removeEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1),a[b].addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1)};
|
||||
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("contacts");this.container.innerHTML="";for(var c=this.selected+10,b=this.selected;b<c&&b<a.length;b++)this.add(lsi.get("contacts",a[b]));c>=a.length&&this.add({uid:a.length,number:"",firstname:"",lastname:"",username:"",call:-1,sms:-1,countcall:0,countsms:0});this.updateNavBar()};
|
||||
inputPhoneContact.prototype.nav=function(a){if("undefined"==typeof a||isNaN(a.getData("n"))||"nav-contact"!=a.parentNode.id)return!1;for(var c=$$("#nav-contact > span.active"),b=0;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
|
|
|
@ -82,7 +82,7 @@ inputPhoneContact.prototype.add = function(objectData){
|
|||
console.log('CONTACTS: ADD');
|
||||
|
||||
// Si pas d'uid, on quitte
|
||||
if( objectData.uid == null || isNaN('number') )
|
||||
if( objectData == null || objectData.uid == null || isNaN('number') )
|
||||
return false
|
||||
|
||||
// {0} On formatte l'object //
|
||||
|
|
|
@ -14,9 +14,9 @@ b<a.sexe.length;b++)a.sexe[b].status?c[b].setAttribute("checked","checked"):c[b]
|
|||
c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.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");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc2"]');for(b=0;b<c.length&&b<a.loc2.length;b++)a.loc2[b].status?c[b].setAttribute("checked",
|
||||
"checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length&&b<a.context.length;b++)a.context[b].status?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");for(c=0;c<a.freq.length;c++)for(var d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq'+c+'"]'),b=0;b<d.length&&b<a.freq[c].length;b++)a.freq[c][b].status?
|
||||
d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked");for(c=0;c<a.connect.length;c++)for(d=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect'+c+'"]'),b=0;b<d.length&&b<a.connect[c].length;b++)a.connect[c][b].status?d[b].setAttribute("checked","checked"):d[b].removeAttribute("checked")};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("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)};
|
||||
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
|
||||
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b;for(b in a){if(-1<a[b].call){var c=a[b].call,d=lsi.get("fiches",c);null==d&&(d=this.defaultData);d.uid=c;d.contact=b;lsi.set("fiches",c,d)}-1<a[b].sms&&(c=10+a[b].sms,d=lsi.get("fiches",c),null==d&&(d=this.defaultData),d.uid=c,d.contact=b,lsi.set("fiches",c,d))}var a=lsi["export"]("mini-fiches"),d=lsi["export"]("fiches"),e;for(e in d)d[e].timestamp>a[e].timestamp?(a[e].sexe=d[e].sexe,a[e].age=d[e].age,
|
||||
a[e].job=d[e].job,a[e].loc=d[e].loc):(d[e].sexe=a[e].sexe,d[e].age=a[e].age,d[e].job=a[e].job,d[e].loc=a[e].loc),lsi.set("mini-fiches",e,a[e]),lsi.set("fiches",e,d[e])};inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
a[e].job=d[e].job,a[e].loc=d[e].loc):(d[e].sexe=a[e].sexe,d[e].age=a[e].age,d[e].job=a[e].job,d[e].loc=a[e].loc),lsi.set("mini-fiches",e,a[e]),lsi.set("fiches",e,d[e]);for(e in d);};inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=Object.keys(a).length;if(this.nav_container.children.length!=b){this.nav_container.innerHTML="<span>APPELS</span>";for(var c=0;c<b;c++)9==c?this.nav_container.innerHTML+='<span data-n="'+c+'" class="lc">'+(c%10+1)+"</span> ":(10==c&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c%10+1)+"</span>")}for(var d in a)b=this.nav_container.children[a[d].uid],
|
||||
!0===a[d].valid?b.addClass("done"):b.remClass("done");this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))};
|
||||
inputPhoneFiche.prototype.check=function(a){if(isNaN(parseInt(a.age))||2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||!checkRadioValue(a.sexe)||!checkRadioValue(a.famsit)||!checkRadioValue(a.reltype)||!checkRadioValue(a.loc)||!checkRadioValue(a.loc2)||!checkRadioValue(a.context))return!1;for(var b=0;b<a.freq.length;b++)if(!checkRadioValue(a.freq[b]))return!1;
|
||||
|
|
|
@ -313,21 +313,13 @@ inputPhoneFiche.prototype.storageToFields = function(){
|
|||
// On réinitialise le HTML
|
||||
this.container.innerHTML = '';
|
||||
|
||||
// On récupère les UIDS
|
||||
var UIDs = [];
|
||||
//
|
||||
for( var key in ficheData ){
|
||||
var uid = ficheData[key].uid;
|
||||
|
||||
if( uid == this.selected )
|
||||
for( var key in ficheData )
|
||||
if( ficheData[key].uid == this.selected )
|
||||
this.add(ficheData[key]);
|
||||
|
||||
UIDs.push(uid);
|
||||
}
|
||||
|
||||
|
||||
// {4} On met à jour la navigation //
|
||||
this.updateNavBar(UIDs);
|
||||
this.updateNavBar();
|
||||
|
||||
};
|
||||
|
||||
|
@ -428,6 +420,13 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
lsi.set('fiches', key, ficheData[key]);
|
||||
}
|
||||
|
||||
|
||||
/* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS
|
||||
---------------------------------------------------------*/
|
||||
for( var key in ficheData ){
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
function inputPhoneSubject(a,b,c,d,e){this.number=a;this.username=b;this.firstname=c;this.lastname=d;this.store_button=e}inputPhoneSubject.prototype={store_button:this.store_button,number:this.number,username:this.username,firstname:this.firstname,lastname:this.lastname};
|
||||
inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");var a=0<this.number.value.length,a=a&&0<this.username.value.length+this.firstname.value.length+this.lastname.value.length;if(!a)return!1;lsi.set("subject",0,{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("subject",0);null!=a&&(this.number.value=a.number,this.username.value=a.username,this.firstname.value=a.firstname,this.lastname.value=a.lastname)};inputPhoneSubject.prototype.attach=function(){console.log("SUBJECT: ATTACH");lsi.createDataset("subject");var a=this;this.store_button.addEventListener("click",function(b){a.fieldsToStorage()},!1);this.storageToFields()};
|
||||
inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("subject",0);null==a&&(a={number:"",username:"",firstname:"",lastname:""});this.number.value=a.number;this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
|
||||
inputPhoneSubject.prototype.attach=function(){console.log("SUBJECT: ATTACH");lsi.createDataset("subject");var a=this;this.store_button.addEventListener("click",function(b){a.fieldsToStorage()},!1);this.storageToFields()};
|
||||
|
|
|
@ -60,7 +60,8 @@ inputPhoneSubject.prototype.storageToFields = function(){
|
|||
// {1} On récupère les informations du sujet //
|
||||
var subjectData = lsi.get('subject', 0);
|
||||
|
||||
if( subjectData == null ) return;
|
||||
if( subjectData == null )
|
||||
subjectData = { number: '', username: '', firstname: '', lastname: '' };
|
||||
|
||||
// {2} On restore les valeurs //
|
||||
this.number.value = subjectData.number;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
function localStorageInterface(){}
|
||||
localStorageInterface.prototype={dataset:[],dataset_keys:[],set:function(a,b,d){var c=this.dataset.indexOf(a);if(-1==c)return!1;-1==this.dataset_keys[c].indexOf(b)&&(this.dataset_keys[c].push(b),localStorage.setItem(a,JSON.stringify(this.dataset_keys[c])));localStorage.setItem(a+"_"+b,JSON.stringify(d));return!0},get:function(a,b){return-1==this.dataset.indexOf(a)?!1:JSON.parse(localStorage.getItem(a+"_"+b))},del:function(a,b){var d=this.dataset.indexOf(a);if(-1==d)return!1;var c=this.dataset_keys[d].indexOf(b);
|
||||
if(-1==c)return!1;localStorage.removeItem(a+"_"+b);this.dataset_keys[d].splice(c,1);localStorage.setItem(a,JSON.stringify(this.dataset_keys[d]));return!0},createDataset:function(a){if("string"!=typeof a)return!1;if(-1<this.dataset.indexOf(a))return!0;var b=localStorage.getItem(a);null!=b?(this.dataset.push(a),this.dataset_keys.push(JSON.parse(b))):(this.dataset.push(a),this.dataset_keys.push([]),localStorage.setItem(a,JSON.stringify([])));return!0},keys:function(a){a=this.dataset.indexOf(a);return-1==
|
||||
a?!1:this.dataset_keys[a]},"export":function(a){var b=this.dataset.indexOf(a);if(-1==b)return!1;for(var d={},c=0;c<this.dataset_keys[b].length;c++)d[this.dataset_keys[b][c]]=this.get(a,this.dataset_keys[b][c]);return d},"import":function(a,b){if(-1==this.dataset.indexOf(a))this.createDataset(a);else{var d=this["export"](a),c;for(c in d)this.del(a,c)}for(c in b)this.set(a,c,b[c]);return!0}};var lsi=new localStorageInterface;
|
||||
localStorageInterface.prototype={dataset:[],dataset_keys:[],set:function(a,b,d){b=b.toString();var c=this.dataset.indexOf(a);if(-1==c)return!1;-1==this.dataset_keys[c].indexOf(b)&&(this.dataset_keys[c].push(b),localStorage.setItem(a,JSON.stringify(this.dataset_keys[c])));localStorage.setItem(a+"_"+b,JSON.stringify(d));return!0},get:function(a,b){b=b.toString();return-1==this.dataset.indexOf(a)?!1:JSON.parse(localStorage.getItem(a+"_"+b))},del:function(a,b){b=b.toString();var d=this.dataset.indexOf(a);
|
||||
if(-1==d)return!1;var c=this.dataset_keys[d].indexOf(b);if(-1==c)return!1;localStorage.removeItem(a+"_"+b);this.dataset_keys[d].splice(c,1);localStorage.setItem(a,JSON.stringify(this.dataset_keys[d]));return!0},createDataset:function(a){if("string"!=typeof a)return!1;if(-1<this.dataset.indexOf(a))return!0;var b=localStorage.getItem(a);null!=b?(this.dataset.push(a),this.dataset_keys.push(JSON.parse(b))):(this.dataset.push(a),this.dataset_keys.push([]),localStorage.setItem(a,JSON.stringify([])));return!0},
|
||||
keys:function(a){a=this.dataset.indexOf(a);return-1==a?!1:this.dataset_keys[a]},"export":function(a){var b=this.dataset.indexOf(a);if(-1==b)return!1;for(var d={},c=0;c<this.dataset_keys[b].length;c++)d[this.dataset_keys[b][c]]=this.get(a,this.dataset_keys[b][c]);return d},"import":function(a,b){-1==this.dataset.indexOf(a)?this.createDataset(a):this.clear(a);for(var d in b)this.set(a,d,b[d]);return!0},clear:function(a){var b=this.dataset.indexOf(a);if(-1==b)return!1;var d=this["export"](a),c;for(c in d)this.del(a,
|
||||
c);this.dataset_keys[b]=[];localStorage.setItem(a,JSON.stringify(this.dataset_keys[b]));return!0}};var lsi=new localStorageInterface;
|
||||
|
|
|
@ -16,9 +16,11 @@ localStorageInterface.prototype = {
|
|||
*
|
||||
*/
|
||||
set: function(dataset_name, key, value){
|
||||
var index = this.dataset.indexOf(dataset_name);
|
||||
// On met la clé en <String>
|
||||
key = key.toString();
|
||||
|
||||
/* (1) Si le 'dataset' n'existe pas */
|
||||
var index = this.dataset.indexOf(dataset_name);
|
||||
if( index == -1 ) return false; // erreur
|
||||
|
||||
/* (2) On enregistre la nouvelle clé, si elle est nouvelle */
|
||||
|
@ -42,6 +44,9 @@ localStorageInterface.prototype = {
|
|||
*
|
||||
*/
|
||||
get: function(dataset_name, key){
|
||||
// On met la clé en <String>
|
||||
key = key.toString();
|
||||
|
||||
/* (1) Si le 'dataset' n'existe pas */
|
||||
if( this.dataset.indexOf(dataset_name) == -1 ) return false; // erreur
|
||||
|
||||
|
@ -58,6 +63,9 @@ localStorageInterface.prototype = {
|
|||
*
|
||||
*/
|
||||
del: function(dataset, key){
|
||||
// On met la clé en <String>
|
||||
key = key.toString();
|
||||
|
||||
/* (1) Si le 'dataset' n'existe pas */
|
||||
var index = this.dataset.indexOf(dataset);
|
||||
if( index == -1 ) return false; // erreur
|
||||
|
@ -115,9 +123,17 @@ localStorageInterface.prototype = {
|
|||
return true;
|
||||
},
|
||||
|
||||
keys: function(dataset_name){
|
||||
|
||||
/* RENVOIE UN TABLEAU CONTENANT LES CLÉS DU DATASET
|
||||
*
|
||||
* @dataset<String> Le nom du dataset en question
|
||||
*
|
||||
* @return keys<Array> Retourne la liste des clés du dataset
|
||||
*
|
||||
*/
|
||||
keys: function(dataset){
|
||||
/* (1) Si le 'dataset' n'existe pas */
|
||||
var index = this.dataset.indexOf(dataset_name);
|
||||
var index = this.dataset.indexOf(dataset);
|
||||
if( index == -1 ) return false; // erreur
|
||||
|
||||
/* (2) On retourne la liste des clés pour ce dataset */
|
||||
|
@ -126,6 +142,13 @@ localStorageInterface.prototype = {
|
|||
},
|
||||
|
||||
|
||||
/* RENVOIE UN OBJET CORRESPONDANT AUX DONNÉES D'UN DATASET
|
||||
*
|
||||
* @dataset<String> Nom du dataset en question
|
||||
*
|
||||
* @return object<Object> Object correspondant aux valeurs du dataset ({key1: value1, key2: value2})
|
||||
*
|
||||
*/
|
||||
export: function(dataset){
|
||||
/* (1) Si le 'dataset' n'existe pas */
|
||||
var index = this.dataset.indexOf(dataset);
|
||||
|
@ -141,6 +164,14 @@ localStorageInterface.prototype = {
|
|||
},
|
||||
|
||||
|
||||
/* REMPLIT UN DATASET AVEC LES DONNÉES D'UN OBJET SUR LE PRINCIPE {CLÉ: VALEUR}
|
||||
*
|
||||
* @dataset<String> Nom du dataset en question
|
||||
* @data<Object> Objet contenant les données à mettre dan sle dataset, sur le modèle ({key1: value1, key2: value2})
|
||||
*
|
||||
* @return status<Boolean> Retourne TRUE si tout s'est bien passé, sinon FALSE
|
||||
*
|
||||
*/
|
||||
import: function(dataset, data){
|
||||
/* (1) On récupère l'indice du dataset s'il existe déjà */
|
||||
var index = this.dataset.indexOf(dataset);
|
||||
|
@ -149,14 +180,11 @@ localStorageInterface.prototype = {
|
|||
if( index == -1 )
|
||||
this.createDataset(dataset);
|
||||
|
||||
/* (3) Cas 2 : Le dataset existe -> on supprime tout */
|
||||
else{
|
||||
var content = this.export(dataset);
|
||||
// On supprime toutes les valeurs
|
||||
for( var key in content )
|
||||
this.del(dataset, key);
|
||||
/* (3) Cas 2 : Le dataset existe -> on le vide */
|
||||
else
|
||||
this.clear(dataset);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* (2) On remplit le dataset avec toutes les données de l'objet */
|
||||
for( var key in data )
|
||||
|
@ -164,6 +192,36 @@ localStorageInterface.prototype = {
|
|||
|
||||
/* (3) On retourne le résultat */
|
||||
return true;
|
||||
},
|
||||
|
||||
|
||||
/* EFFACE TOUTES LES DONNÉES D'UN DATASET
|
||||
*
|
||||
* @dataset<String> Nom du dataset en question
|
||||
*
|
||||
* @return status<Boolean> Retourne TRUE si tout s'est bien passé, sinon FALSE
|
||||
*
|
||||
*/
|
||||
clear: function(dataset){
|
||||
/* (1) On récupère l'indice du dataset s'il existe déjà */
|
||||
var index = this.dataset.indexOf(dataset);
|
||||
|
||||
// Si le dataset n'existe pas, on retourne une erreur
|
||||
if( index == -1 ) return false;
|
||||
|
||||
/* (2) On supprime toutes les valeurs du dataset */
|
||||
var content = this.export(dataset);
|
||||
|
||||
// On supprime toutes les valeurs
|
||||
for( var key in content )
|
||||
this.del(dataset, key);
|
||||
|
||||
/* (3) Par précaution, on supprime les clés du dataset */
|
||||
this.dataset_keys[index] = [];
|
||||
localStorage.setItem(dataset, JSON.stringify(this.dataset_keys[index]));
|
||||
|
||||
/* (4) On retourne que tout s'est bien passé */
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@ include("/js/includes/input-phone-subject.js",function(){include("/js/includes/i
|
|||
subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-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){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:importCallLog.files[0]};
|
||||
api.send(a,function(b){console.log(b);if(0==b.ModuleError){for(var a=0,f=[],c=0;c<b.calls.length&&10>c;c++)f.push(b.calls[c].number);for(c=0;c<f.length;c++){var d=b.directory[f[c]].name.split(" ");lsi.set("contacts",a,{uid:a,number:f[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[f[c]].sms,countcall:b.directory[f[c]].calls,call:c,sms:-1});a++}for(var g=[],c=0;c<b.sms.length&&10>c;c++)g.push(b.sms[c].number);for(c=0;c<
|
||||
g.length;c++)if(d=f.indexOf(g[c]),-1<d){var k=lsi.get("contacts",d);k.sms=c;lsi.set("contacts",d,k)}else d=b.directory[g[c]].name.split(" "),lsi.set("contacts",a,{uid:a,number:g[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[g[c]].sms,countcall:b.directory[g[c]].calls,call:-1,sms:c}),a++;for(var h in b.directory)-1<f.indexOf(h)||-1<g.indexOf(h)||(d=(null===b.directory[h].name?"":b.directory[h].name).split(" "),lsi.set("contacts",
|
||||
a,{uid:a,number:h,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[h].sms,countcall:b.directory[h].calls,call:-1,sms:-1}),a++);contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){localStorage.clear();reload()},!1);$("#export-all").addEventListener("click",function(a){a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),
|
||||
fiches:lsi["export"]("fiches")};var b=$("#download-target");b.download="local-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#local-upload").files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",
|
||||
a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),
|
||||
mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},!1)},!1)})})})});
|
||||
a,{uid:a,number:h,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[h].sms,countcall:b.directory[h].calls,call:-1,sms:-1}),a++);contactManager.storageToFields();dynamicUpdate(!0)}})},!1);clearAllButton.addEventListener("click",function(a){lsi.clear("subject");lsi.clear("contacts");lsi.clear("mini-fiches");lsi.clear("fiches");subjectManager.storageToFields();contactManager.storageToFields();miniManager.storageToFields();ficheManager.storageToFields()},
|
||||
!1);$("#export-all").addEventListener("click",function(a){a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};var b=$("#download-target");b.download="local-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",
|
||||
file:$("#local-upload").files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);subjectManager.storageToFields();contactManager.storageToFields();dynamicUpdate(!0)})},!1);submitAllButton.addEventListener("click",function(a){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();
|
||||
miniManager.fieldsToStorage();ficheManager.fieldsToStorage();a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches")};api.send(a,function(a){console.log(a)},!1)},!1)})})})});
|
||||
|
|
|
@ -347,8 +347,18 @@ include('/js/includes/input-phone-fiche.js', function(){
|
|||
/* (6) Gestion de l'effacement des données locales
|
||||
---------------------------------------------------------*/
|
||||
clearAllButton.addEventListener('click', function(e){
|
||||
localStorage.clear();
|
||||
reload();
|
||||
/* (1) On vide tous les dataset de données */
|
||||
lsi.clear('subject');
|
||||
lsi.clear('contacts');
|
||||
lsi.clear('mini-fiches');
|
||||
lsi.clear('fiches');
|
||||
|
||||
|
||||
/* (2) On met à jour l'affichage */
|
||||
subjectManager.storageToFields();
|
||||
contactManager.storageToFields();
|
||||
miniManager.storageToFields();
|
||||
ficheManager.storageToFields();
|
||||
}, false);
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue