diff --git a/js/includes/input-phone-contact-min.js b/js/includes/input-phone-contact-min.js index 677a6cf..283b3b6 100644 --- a/js/includes/input-phone-contact-min.js +++ b/js/includes/input-phone-contact-min.js @@ -1,8 +1,7 @@ function inputPhoneContact(a,c){this.container=a;this.nav_container=c}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return!isNaN(a.existing)||0"+c[b].name+"\n";this.container.innerHTML+=pContactBuilder.build(a); -b=$('[data-sublink="phone"] article.contact-panel .new-contact input[data-name="uid"][value="'+a.uid+'"] ~ span select[data-name="existing"]>option[value="'+a.existing+'"]');null!=b&&b.setAttribute("selected","selected");a=$$('[data-sublink="phone"] article.contact-panel .new-contact');var d=this;for(b=0;b"+c[b].name+"\n";this.container.innerHTML+=pContactBuilder.build(a);b=$('[data-sublink="phone"] article.contact-panel .new-contact input[data-name="uid"][value="'+a.uid+'"] ~ span select[data-name="existing"]>option[value="'+ +a.existing+'"]');null!=b&&b.setAttribute("selected","selected");a=$$('[data-sublink="phone"] article.contact-panel .new-contact');var d=this;for(b=0;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 c=$$('[data-sublink="phone"] #p_nav-contact > span.active'),b=0;b'+(1+c/10)+""}this.nav($('[data-sublink="phone"] #p_nav-contact [data-n="'+this.selected+'"]'))}; diff --git a/js/includes/input-phone-contact.js b/js/includes/input-phone-contact.js index bc82b4e..ef58275 100644 --- a/js/includes/input-phone-contact.js +++ b/js/includes/input-phone-contact.js @@ -50,12 +50,6 @@ inputPhoneContact.prototype.fieldsToStorage = function(){ // number: deflated.number, username: deflated.username, - call: parseInt(deflated.call), - sms: parseInt(deflated.sms), - - countcall: parseInt(deflated.countcall), - countsms: parseInt(deflated.countsms), - existing: (!isNaN(deflated.existing)) ? parseInt(deflated.existing) : '.' }; @@ -94,10 +88,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.call = (objectData.call != null) ? objectData.call : -1; - objectData.sms = (objectData.sms != null) ? objectData.sms : -1; - objectData.countcall = (objectData.countcall != null) ? objectData.countcall : 0; - objectData.countsms = (objectData.countsms != null) ? objectData.countsms : 0; objectData.existing = (objectData.existing != null) ? objectData.existing : '.'; diff --git a/js/includes/input-phone-fiche-min.js b/js/includes/input-phone-fiche-min.js index 137b867..64e769c 100644 --- a/js/includes/input-phone-fiche-min.js +++ b/js/includes/input-phone-fiche-min.js @@ -12,10 +12,9 @@ for(b=0;binput[type="radio"][data-name="context"]');for(b=0;binput[type="radio"][data-name="freq"]'); for(b=0;binput[type="radio"][data-name="connect"]');for(b=0;blsi.keys("p_contacts").length?lsi.keys("p_contacts").length:20;if(b.length< -e)for(c in a){for(a=0;-1=e)break}var d=lsi["export"]("p_fiches"),f;for(f in d)b=lsi.get("p_contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],null==b||b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("p_fiches",b.uid,c)))}; -inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;cAPPELS");10>e&&c'+(e%10+1)+"  ":(10==e&&(this.nav_container.innerHTML+='SMS'),this.nav_container.innerHTML+=''+(e%10+1)+"")}for(var d in a)b= -$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; +inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("p_contacts"),b=[],c=40>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:40;if(b.length=c)break}var a=lsi["export"]("p_fiches"),f;for(f in a)b=lsi.get("p_contacts",a[f].contact),null!=b&&(b=20>parseInt(f)?20+b.sms: +b.call,b=a[b],null==b||b.timestamp>=a[f].timestamp||(c=a[f],c.uid=b.uid,lsi.set("p_fiches",b.uid,c)))};inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var b=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),c=0;cAPPELS");20>e&&c'+(e%20+1)+"  ":(20==e&&(this.nav_container.innerHTML+='
SMS'),this.nav_container.innerHTML+=''+(e%20+ +1)+"")}for(var d in a)b=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0a.reltypeSpecial.length|| "11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("p_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)}; diff --git a/js/includes/input-phone-fiche.js b/js/includes/input-phone-fiche.js index 4a1d9af..7566762 100644 --- a/js/includes/input-phone-fiche.js +++ b/js/includes/input-phone-fiche.js @@ -349,64 +349,14 @@ inputPhoneFiche.prototype.sync = function(){ var contacts = lsi.export('p_contacts'); var addedFicheUids = []; // Contiendra les uids des fiches qui seront crées - /* (2) Pour chaque CONTACT, on met à jour/crée la FICHE associée, si dans le TOP 10 des APPELS ou des SMS */ - for( var uid in contacts ){ - - var inCallTop10 = false; - - /* (3) Indice de 0 à 9 si dans le TOP 10 des APPELS */ - if( contacts[uid].call > -1 ){ - // On calcule le rang de la fiche en fonction du classement - var ficheIndex = contacts[uid].call; - addedFicheUids.push(ficheIndex); - - // On récupère les informations de la FICHE (si elle existe) */ - var ficheData = lsi.get('p_fiches', ficheIndex); - - // Si la fiche n'existe pas, on la crée avec les valeurs par défaut - if( ficheData == null ) - ficheData = this.defaultData; - - // On met à jour la fiche ET on l'enregistre - ficheData.uid = ficheIndex; - ficheData.contact = parseInt(uid); - lsi.set('p_fiches', ficheIndex, ficheData); - } - - - /* (4) Indice de 10 à 19 si dans le TOP 10 des SMS */ - if( contacts[uid].sms > -1 ){ - // On calcule le rang de la fiche en fonction du classement - var ficheIndex = 10+contacts[uid].sms; - addedFicheUids.push(ficheIndex); - - // On récupère les informations de la FICHE (si elle existe) */ - var ficheData = lsi.get('p_fiches', ficheIndex); - - // Si la fiche n'existe pas, on la crée avec les valeurs par défaut - if( ficheData == null ) - ficheData = this.defaultData; - - // On met à jour la fiche ET on l'enregistre - ficheData.uid = ficheIndex; - ficheData.contact = parseInt(uid); - lsi.set('p_fiches', ficheIndex, ficheData); - - - } - - - } - - /* (2) Mise à jour en fonction des contacts APRÈS SAISIE MANUELLE ---------------------------------------------------------*/ - // Nombre maximum de fiches (20, sauf si moins de 20 contacts, dans ce cas, le nombre de contacts); - var nbMaxFiche = lsi.keys('p_contacts').length < 20 ? lsi.keys('p_contacts').length : 20; + // Nombre maximum de fiches (40, sauf si moins de 40 contacts, dans ce cas, le nombre de contacts); + var nbMaxFiche = lsi.keys('p_contacts').length < 40 ? lsi.keys('p_contacts').length : 40; - // Si moins de 10+10 contacts crées, on les complètes en fonction des contacts séquentiellement + // Si moins de 20+20 contacts crées, on les complètes en fonction des contacts séquentiellement if( addedFicheUids.length < nbMaxFiche ){ /* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée*/ @@ -433,14 +383,14 @@ inputPhoneFiche.prototype.sync = function(){ lsi.set('p_fiches', ficheUid, ficheData); - /* (5) Si on a déja crée 10+10 fiches, on arrête */ + /* (5) Si on a déja crée 20+20 fiches, on arrête */ if( addedFicheUids.length >= nbMaxFiche ) break; } } - /* (3) Mise à jour des fiches dupliquées entre le top 10 des APPELS et celui des SMS + /* (3) Mise à jour des fiches dupliquées entre le top 20 des APPELS et celui des SMS ---------------------------------------------------------*/ ficheData = lsi.export('p_fiches'); @@ -452,13 +402,9 @@ inputPhoneFiche.prototype.sync = function(){ if( associatedContact == null ) continue; - /* (2) Si la fiche n'est pas dans les 2 top 10 (APPELS et SMS) */ - if( associatedContact.sms == -1 || associatedContact.call == -1 ) - continue; // On passe au suivant - /* (3) On récupère l'autre fiche (clone) */ - var inCall = parseInt(key) < 10; // Si on est dans le top 10 des APPELS, sinon dans celui des SMS - var cloneIndex = inCall ? 10+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS) + var inCall = parseInt(key) < 20; // Si on est dans le top 20 des APPELS, sinon dans celui des SMS + var cloneIndex = inCall ? 20+associatedContact.sms : associatedContact.call; // Contient l'index du clone dans l'autre top (APPELS ou SMS) var clone = ficheData[cloneIndex]; @@ -524,22 +470,22 @@ inputPhoneFiche.prototype.updateNavBar = function(){ - // Si 1ère valeur du top 10 des APPELS, on ajoute le bandeau "APPELS" + // Si 1ère valeur du top 20 des APPELS, on ajoute le bandeau "APPELS" if( i == 0 ) this.nav_container.innerHTML += 'APPELS'; - // Si fin du top 10 des APPELS, on met un espace et un border-right - if( i < 10 && k < keys.length-1 && keys[k+1] >= 10 ) - this.nav_container.innerHTML += ''+(i%10 + 1)+'  '; + // Si fin du top 20 des APPELS, on met un espace et un border-right + if( i < 20 && k < keys.length-1 && keys[k+1] >= 20 ) + this.nav_container.innerHTML += ''+(i%20 + 1)+'  '; - // Si début du top 10 des SMS, on met le label 'SMS' et un border-left - else if( i == 10 ){ - this.nav_container.innerHTML += 'SMS'; - this.nav_container.innerHTML += ''+(i%10 + 1)+''; + // Si début du top 20 des SMS, on met le label 'SMS' et un border-left + else if( i == 20 ){ + this.nav_container.innerHTML += '
SMS'; + this.nav_container.innerHTML += ''+(i%20 + 1)+''; // Sinon, on ajoute juste le bouton }else - this.nav_container.innerHTML += ''+(i%10 + 1)+''; + this.nav_container.innerHTML += ''+(i%20 + 1)+''; } /* (3) On montre les FICHES qui sont correctes */ diff --git a/js/lib/local-storage-interface-min.js b/js/lib/local-storage-interface-min.js index d1b96c1..21c56b9 100644 --- a/js/lib/local-storage-interface-min.js +++ b/js/lib/local-storage-interface-min.js @@ -1,5 +1,5 @@ function localStorageInterface(){} -localStorageInterface.prototype={dataset:[],dataset_keys:[],storage:localStorage,setStorage:function(a){if(a!=localStorage&&a!=sessionStorage)return!1;this.storage=a},set:function(a,b,d){b=!isNaN(b)&&b.toString()||null;if(!b)return!1;var c=this.dataset.indexOf(a);if(-1==c)return!1;-1==this.dataset_keys[c].indexOf(b)&&(this.dataset_keys[c].push(b),this.storage.setItem(a,JSON.stringify(this.dataset_keys[c])));this.storage.setItem(a+"_"+b,JSON.stringify(d));return!0},get:function(a,b){return(b=!isNaN(b)&& -b.toString()||null)&&-1!=this.dataset.indexOf(a)?JSON.parse(this.storage.getItem(a+"_"+b)):!1},del:function(a,b){b=!isNaN(b)&&b.toString()||null;if(!b)return!1;var d=this.dataset.indexOf(a);if(-1==d)return!1;var c=this.dataset_keys[d].indexOf(b);if(-1==c)return!1;this.storage.removeItem(a+"_"+b);this.dataset_keys[d].splice(c,1);this.storage.setItem(a,JSON.stringify(this.dataset_keys[d]));return!0},createDataset:function(a){if("string"!=typeof a)return!1;if(-1 - key = !isNaN(key) && key.toString() || null; + key = key != null && key.toString() || null; - if( !key ) return false; + if( key === false ) return false; /* (1) Si le 'dataset' n'existe pas */ var index = this.dataset.indexOf(dataset_name); @@ -58,9 +58,9 @@ localStorageInterface.prototype = { */ get: function(dataset_name, key){ // On met la clé en - key = !isNaN(key) && key.toString() || null; + key = key != null && key.toString() || null; - if( !key ) return false; + if( key === false ) return false; /* (1) Si le 'dataset' n'existe pas */ if( this.dataset.indexOf(dataset_name) == -1 ) return false; // erreur @@ -79,9 +79,9 @@ localStorageInterface.prototype = { */ del: function(dataset, key){ // On met la clé en - key = !isNaN(key) && key.toString() || null; + key = key != null && key.toString() || null; - if( !key ) return false; + if( key === false ) return false; /* (1) Si le 'dataset' n'existe pas */ var index = this.dataset.indexOf(dataset);