Prototype matrice + fieldsToStorage et structure en mémoire
This commit is contained in:
parent
980666beb1
commit
fd9fa8dbab
|
@ -1,10 +1,9 @@
|
|||
function inputPhoneMatrice(a){this.container=a}inputPhoneMatrice.prototype={container:this.container};
|
||||
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: 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(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid.value);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:parseInt(c.uid.value),firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age.value,
|
||||
studies:c.studies.value,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial.value,loc:c.loc,hash:e};c.valid=this.check(c);0<diff(d,c).length&&(console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("mini-fiches",c.uid,c)}}};
|
||||
inputPhoneMatrice.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("contacts",a.uid);if(!1===b)return!1;
|
||||
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));console.log(a);var b={},c;for(c in a)if(a[c]instanceof Array)for(var d in a[c])!0===a[c][d].status&&(null==b[c]&&(b[c]=[]),b[c].push(parseInt(a[c][d].value)));else!0===a[c].status&&(null==b[c]&&(b[c]=[]),b[c].push(parseInt(a[c].value)));lsi.set("matrice",0,b)};
|
||||
inputPhoneMatrice.prototype.add=function(a){console.log("MATRICE: 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("contacts",a.uid);if(!1===b)return!1;
|
||||
this.container.innerHTML+=miniFicheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('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=$('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=$$('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="reltype"]');for(b=0;b<c.length&&b<a.reltype.length;b++)a.reltype[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")};inputPhoneMatrice.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);this.container.innerHTML="";this.add(a);this.updateNavBar()};
|
||||
inputPhoneMatrice.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;lsi.set("mini-fiches",b,c)}};inputPhoneMatrice.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-mini"!=a.parentNode.id)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.getData("n"))};
|
||||
inputPhoneMatrice.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if($$("#nav-mini [data-n]").length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c+1)+"</span>"}for(var e in a)b=$('#nav-mini [data-n="'+a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))};
|
||||
inputPhoneMatrice.prototype.check=function(a){return!checkRadioValue(a.sexe)||"."==a.studies||"."==a.age||!checkRadioValue(a.loc)||!checkRadioValue(a.reltype)||a.reltype[8].status&&2>a.reltypeSpecial.length?!1:!0};inputPhoneMatrice.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("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)};
|
||||
"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")};inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);this.container.innerHTML="";this.add(a);this.updateNavBar()};
|
||||
inputPhoneMatrice.prototype.sync=function(){console.log("MATRICE: 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;lsi.set("mini-fiches",b,c)}};inputPhoneMatrice.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-mini"!=a.parentNode.id)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.getData("n"))};
|
||||
inputPhoneMatrice.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches"),b=Object.keys(a).length;if($$("#nav-mini [data-n]").length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c+1)+"</span>"}for(var d in a)b=$('#nav-mini [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))};
|
||||
inputPhoneMatrice.prototype.check=function(a){return!checkRadioValue(a.sexe)||"."==a.studies||"."==a.age||!checkRadioValue(a.loc)||!checkRadioValue(a.reltype)||a.reltype[8].status&&2>a.reltypeSpecial.length?!1:!0};inputPhoneMatrice.prototype.attach=function(a){console.log("MATRICE: ATTACH");lsi.createDataset("matrice");this.storageToFields();this.handler=a};
|
||||
|
|
|
@ -16,65 +16,50 @@ inputPhoneMatrice.prototype = {
|
|||
inputPhoneMatrice.prototype.fieldsToStorage = function(){
|
||||
console.log('MATRICE: FIELDS TO STORAGE');
|
||||
|
||||
// {1} Pour chaque formulaire de contact présent //
|
||||
var existingMiniFiches = $$('article.mini-relation-panel .mini-fiche-relation');
|
||||
for( var i = 0 ; i < existingMiniFiches.length ; i++ ){
|
||||
// {2} On initialise notre deflater pour récupérer les valeurs //
|
||||
var deflater = new FormDeflater(existingMiniFiches[i], ['input', 'select'], ['data-name']);
|
||||
|
||||
// {3} On enregistre ce contact si le numéro n'est pas vide et soit pseudo/prénom/nom //
|
||||
var deflated = deflater.deflate();
|
||||
// On crée le hash
|
||||
var deflatedHash = crc32(JSON.stringify(deflated));
|
||||
// {1} On initialise notre deflater pour récupérer les valeurs //
|
||||
var deflater = new FormDeflater(this.container, ['input'], ['data-name']);
|
||||
|
||||
// {2} On extrait les données //
|
||||
var deflated = deflater.deflate();
|
||||
// On crée le hash
|
||||
var deflatedHash = crc32(JSON.stringify(deflated));
|
||||
|
||||
|
||||
// console.log(deflated);
|
||||
console.log(deflated);
|
||||
|
||||
/* (3) On crée l'objet et on le remplit avec les relations */
|
||||
var obj = {};
|
||||
|
||||
// {4} On récupère les données du LSI si elles existent //
|
||||
var existingData = lsi.get('mini-fiches', deflated.uid.value);
|
||||
for( var i in deflated )
|
||||
|
||||
// Si n'existe pas, on passe à la suivante
|
||||
if( existingData === false )
|
||||
continue;
|
||||
// {1} Si c'est un tableau de sujets //
|
||||
if( deflated[i] instanceof Array ){
|
||||
|
||||
// Pour chacune des différentes relations, on ajoute si TRUE
|
||||
for( var a in deflated[i] )
|
||||
if( deflated[i][a].status === true ){
|
||||
if( obj[i] == null )
|
||||
obj[i] = [];
|
||||
|
||||
// {5} On récupère et met en forme les valeurs du deflater //
|
||||
// Si le hash est le même, on ne fait rien
|
||||
if( existingData.hash != null && existingData.hash == deflatedHash )
|
||||
return;
|
||||
obj[i].push( parseInt(deflated[i][a].value) );
|
||||
}
|
||||
|
||||
console.warn('> MINI UPDATE');
|
||||
// {2} Si il n'y a qu'un sujet //
|
||||
}else if( deflated[i].status === true ){
|
||||
if( obj[i] == null )
|
||||
obj[i] = [];
|
||||
|
||||
|
||||
var obj = {
|
||||
uid: parseInt(deflated.uid.value),
|
||||
firstname: existingData.firstname,
|
||||
lastname: existingData.lastname,
|
||||
username: existingData.username,
|
||||
sexe: deflated.sexe, // [0] Homme, [1] Femme
|
||||
age: deflated.age.value,
|
||||
studies: deflated.studies.value,
|
||||
reltype: deflated.reltype, // [0] ...
|
||||
reltypeSpecial: deflated.reltypeSpecial.value,
|
||||
loc: deflated.loc, // [0] Choix 1 -> [3] Choix 4
|
||||
hash: deflatedHash
|
||||
};
|
||||
|
||||
/* (8) On vérifie la validité des données et on l'enregistre dans l'objet avec la date de modification */
|
||||
obj.valid = this.check(obj);
|
||||
|
||||
// On met à jour la date de modification, si on a pas qu'@uid de différent
|
||||
if( diff(existingData, obj).length > 0 ){
|
||||
console.warn('> FICHE UPDATE');
|
||||
obj.timestamp = Date.now();
|
||||
obj[i].push( parseInt(deflated[i].value) );
|
||||
}
|
||||
|
||||
|
||||
/* (9) On enregistre les données dans le 'localStorage' */
|
||||
lsi.set('mini-fiches', obj.uid, obj);
|
||||
|
||||
}
|
||||
lsi.set( 'matrice', 0, obj );
|
||||
// Objet de la forme
|
||||
//
|
||||
// idA: [idV, idW], # A connait V et W (et réciproquement)
|
||||
// idB: [idX, idY], # B connait X et Y (et réciproquement)
|
||||
// ...
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
|
@ -93,7 +78,7 @@ inputPhoneMatrice.prototype.fieldsToStorage = function(){
|
|||
*
|
||||
*/
|
||||
inputPhoneMatrice.prototype.add = function(objectData){
|
||||
console.log('MINI FICHE: ADD');
|
||||
console.log('MATRICE: ADD');
|
||||
|
||||
// Si pas d'UID, on retourne une erreur
|
||||
if( objectData == null || objectData.uid == null )
|
||||
|
@ -170,7 +155,7 @@ inputPhoneMatrice.prototype.add = function(objectData){
|
|||
/* [4] Gestion de l'affichage depuis le 'localStorage'
|
||||
=========================================================*/
|
||||
inputPhoneMatrice.prototype.storageToFields = function(){
|
||||
console.log('MINI FICHE: STORAGE TO FIELDS');
|
||||
console.log('MATRICE: STORAGE TO FIELDS');
|
||||
|
||||
// {1} Pour chaque contact du 'localStorage' //
|
||||
var miniData = lsi.get('mini-fiches', this.selected);
|
||||
|
@ -199,7 +184,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
|
|||
/* [5] Synchronisation des CONTACT vers les MINI fiches
|
||||
=========================================================*/
|
||||
inputPhoneMatrice.prototype.sync = function(){
|
||||
console.log('MINI FICHE: SYNC');
|
||||
console.log('MATRICE: SYNC');
|
||||
|
||||
/* (1) On récupère les clés de tous les CONTACTS */
|
||||
var contactData = lsi.export('contacts');
|
||||
|
@ -342,10 +327,10 @@ inputPhoneMatrice.prototype.check = function(miniData){
|
|||
/* [9] Point d'amorçage de la gestion des contacts
|
||||
=========================================================*/
|
||||
inputPhoneMatrice.prototype.attach = function(handler){
|
||||
console.log('MINI FICHE: ATTACH');
|
||||
console.log('MATRICE: ATTACH');
|
||||
|
||||
/* (1) On initialise le jeu de données */
|
||||
lsi.createDataset('mini-fiches');
|
||||
lsi.createDataset('matrice');
|
||||
|
||||
/* (2) On charge les mini fiches depuis la mémoire ('localStorage') */
|
||||
this.storageToFields();
|
||||
|
@ -353,14 +338,4 @@ inputPhoneMatrice.prototype.attach = function(handler){
|
|||
/* (3) On attache la barre de navigation à une fonction */
|
||||
// On enregistre le handler
|
||||
this.handler = handler;
|
||||
|
||||
/* (2) On attache l'évènement sur le conteneur de navigation */
|
||||
var ptr = this;
|
||||
this.nav_container.addEventListener('click', function(e){
|
||||
// 1. On gère la navigation
|
||||
ptr.nav(e.target);
|
||||
// 2. On gere le chargement dynamique
|
||||
ptr.handler(e.target);
|
||||
}, false);
|
||||
|
||||
};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
var subjectManager,contactManager,miniManager,ficheManager,defTrue={status:!0,value:"on"},defFalse={status:!1,value:"on"};
|
||||
var subjectManager,contactManager,miniManager,ficheManager,matriceManager,defTrue={status:!0,value:"on"},defFalse={status:!1,value:"on"};
|
||||
function dynamicUpdate(a){var b=a instanceof Element,e=b&&"SPAN"==a.tagName&&"switch-left"==a.className,f=b&&"SPAN"==a.tagName&&"switch-both"==a.className,c=b&&"INPUT"==a.tagName&&"submit"==a.type,d=b&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(f||e||c||d||b)&&!0!==a)return!1;if(f)console.log("> switch firstname <-> lastname"),e=a.parentNode,a=e.children[8],e=e.children[10],f=a.value,a.value=e.value,e.value=
|
||||
f;else if(e){console.log("> switch firstname+lastname -> username");e=a.parentNode;f=e.children[6];a=e.children[8];e=e.children[10];if(0<f.value.length||0==a.value.length&&0==e.value.length)return!1;f.value=a.value+" "+e.value;a.value="";e.value=""}else console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),miniManager.sync(),ficheManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),(c||b)&&contactManager.storageToFields()}
|
||||
function checkRadioValue(a){for(var b=0,e=0;e<a.length;e++)!0===a[e].status&&b++;return 1!=b?!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(){include("/js/includes/input-phone-matrice.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"),$("#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);$('input#call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",
|
||||
phone_number:$("#subject_phone_number").value,file:a.target.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);$("#clear-all").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);$("#submit-all").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)})})})})});
|
||||
$('article.subject-panel [data-name="submit"]'));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);matriceManager=new inputPhoneMatrice($("article.matrice-panel"));matriceManager.attach(dynamicUpdate);
|
||||
$('input#call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:a.target.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);$("#clear-all").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);$("#submit-all").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)})})})})});
|
||||
|
|
|
@ -13,6 +13,7 @@ var subjectManager;
|
|||
var contactManager;
|
||||
var miniManager;
|
||||
var ficheManager;
|
||||
var matriceManager;
|
||||
|
||||
// CONSTANTES
|
||||
var defTrue = {status: true, value: 'on'};
|
||||
|
@ -205,6 +206,15 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
ficheManager.attach(dynamicUpdate);
|
||||
|
||||
|
||||
/* (5) Gestion de la matrice de relations
|
||||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du gestionnaire de la matrice */
|
||||
matriceManager = new inputPhoneMatrice(
|
||||
$('article.matrice-panel')
|
||||
);
|
||||
|
||||
/* (2) On le démarre */
|
||||
matriceManager.attach(dynamicUpdate);
|
||||
|
||||
|
||||
|
||||
|
@ -214,7 +224,9 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
|
||||
/* (5) Gestion de l'import du fichier
|
||||
|
||||
|
||||
/* (6) Gestion de l'import du fichier
|
||||
---------------------------------------------------------*/
|
||||
$('input#call_log-import[type="file"]').addEventListener('change', function(e){
|
||||
/* (1) On rédige la requête */
|
||||
|
@ -340,7 +352,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
|
||||
/* (6) Gestion de l'effacement des données locales
|
||||
/* (7) Gestion de l'effacement des données locales
|
||||
---------------------------------------------------------*/
|
||||
$('#clear-all').addEventListener('click', function(e){
|
||||
/* (1) On vide tous les dataset de données */
|
||||
|
@ -359,7 +371,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
|
||||
/* (7) Gestion de l'export des données locales
|
||||
/* (8) Gestion de l'export des données locales
|
||||
---------------------------------------------------------*/
|
||||
$('#export-all').addEventListener('click', function(e){
|
||||
/* (1) On construit les données */
|
||||
|
@ -381,7 +393,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
|
||||
/* (8) Gestion de l'import des données locales
|
||||
/* (9) Gestion de l'import des données locales
|
||||
---------------------------------------------------------*/
|
||||
// Le bouton lance l'<input> file
|
||||
$('#import-all').addEventListener('click', function(e){
|
||||
|
@ -423,7 +435,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
|
||||
|
||||
|
||||
/* (9) Gestion de la validation et de l'envoi des données
|
||||
/* (10) Gestion de la validation et de l'envoi des données
|
||||
---------------------------------------------------------*/
|
||||
$('#submit-all').addEventListener('click', function(e){
|
||||
console.log('> GATHERING ALL DATA');
|
||||
|
|
Loading…
Reference in New Issue