diff --git a/js/action-script.js b/js/action-script.js index 8feeaa8..6c4adfa 100755 --- a/js/action-script.js +++ b/js/action-script.js @@ -63,7 +63,7 @@ var navSubMenu = function(subsection){ // navMenu(pageManager.page); pageManager.updateURL(); -} +}; /* [4] Toggle du side-menu <-> navigation @@ -108,16 +108,14 @@ var navMenu = function(section){ if( target.getData('link') ){ DOM.HEADER.addClass('loading'); // Animation de chargement - pageManager.setPage( target.getData('link') ); - - pageManager.activeXHR.addEventListener('loadend', function(){ - + var handlerX = function(){ + console.log(pageManager.vars[0], $$('#CONTAINER > section[data-sublink]')); // On gere la navigation du sous-menu (si defini, utilise) var subSectionExists = pageManager.vars.length >= 1 && $('#CONTAINER > section[data-sublink="'+pageManager.vars[0]+'"]') != null; - if( subSectionExists ) // Si le lien du menu associe existe - navSubMenu(pageManager.vars[0]); // on charge la page associee - else // sinon - navSubMenu(null); // on charge le lien par defaut + + // 1. Si le lien du menu associe existe -> on charge la page associee + // 2. Sinon -> on charge le lien par defaut + subSectionExists ? navSubMenu(pageManager.vars[0]) : navSubMenu(null); // GESTION DE LA NAVIGATION DU SOUS-MENU @@ -136,59 +134,66 @@ var navMenu = function(section){ // On retire l'icone de chargement DOM.HEADER.remClass('loading'); - }, false); - } - -} - - - - - - - /* [0] Initialisation des variables en local - =========================================================*/ - DOM = { - WRAPPER: $('body > #WRAPPER'), - HEADER: $('body > #WRAPPER > #HEADER'), - MENUSIDE: $('body > #WRAPPER > #MENU-SIDE'), - CONTAINER: $('body > #WRAPPER > #CONTAINER') }; - // On cree une instance de l'api - api = new APIClass('/api/'); + /* (x) Si on change de page, on charge la nouvelle charge */ + if( target.getData('link') != pageManager.page ) + pageManager.setPage( target.getData('link') ); - // On crée une instance du gestionnaire des notifications - var Notification = new NotificationClass( $('#notification-container') ); - // Temps d'une notification : ~4s - Notification.defaultTimeout = 4000; + pageManager.activeXHR.addEventListener('loadend', handlerX, false); - // Définition des codes d'erreurs - Notification.errorCodes = { - '-1': 'Erreur de réseau, veuillez recharger la page et réessayer', - 0: 'Erreur interne', - 1: 'Erreur interne', - 2: 'Erreur interne', - 3: 'Le fichier est introuvable', - 4: 'Erreur interne', - 5: 'Erreur interne', - 6: 'Erreur interne', - 7: 'Erreur interne', - 8: 'Erreur interne', - 9: 'Certaines données sont manquantes', - 10: 'Erreur interne', - 11: 'Erreur interne', - 12: 'Erreur interne', - 13: 'Erreur interne', - 14: 'Erreur interne', - 15: 'Erreur interne', - 16: 'Vous n\'avez pas la permission d\'effectuer cette action', - 17: 'Le téléchargement a échoué', - 18: 'Le fichier est invalide (format incorrect)' + } + +}; + + + + + + +/* [0] Initialisation des variables en local +=========================================================*/ +DOM = { + WRAPPER: $('body > #WRAPPER'), + HEADER: $('body > #WRAPPER > #HEADER'), + MENUSIDE: $('body > #WRAPPER > #MENU-SIDE'), + CONTAINER: $('body > #WRAPPER > #CONTAINER') }; - // On définit qu'on veut utiliser le 'sessionStorage' - lsi.setStorage(localStorage); +// On cree une instance de l'api +api = new APIClass('/api/'); + +// On crée une instance du gestionnaire des notifications +var Notification = new NotificationClass( $('#notification-container') ); +// Temps d'une notification : ~4s +Notification.defaultTimeout = 4000; + +// Définition des codes d'erreurs +Notification.errorCodes = { + '-1': 'Erreur de réseau, veuillez recharger la page et réessayer', + 0: 'Erreur interne', + 1: 'Erreur interne', + 2: 'Erreur interne', + 3: 'Le fichier est introuvable', + 4: 'Erreur interne', + 5: 'Erreur interne', + 6: 'Erreur interne', + 7: 'Erreur interne', + 8: 'Erreur interne', + 9: 'Certaines données sont manquantes', + 10: 'Erreur interne', + 11: 'Erreur interne', + 12: 'Erreur interne', + 13: 'Erreur interne', + 14: 'Erreur interne', + 15: 'Erreur interne', + 16: 'Vous n\'avez pas la permission d\'effectuer cette action', + 17: 'Le téléchargement a échoué', + 18: 'Le fichier est invalide (format incorrect)' +}; + +// On définit qu'on veut utiliser le 'sessionStorage' +lsi.setStorage(localStorage); @@ -196,62 +201,62 @@ var navMenu = function(section){ - /* [5] Gestion de la navigation (physique) - ===========================================*/ - DOM.MENUSIDE.addEventListener('click', function(e){ - var target = e.target; +/* [5] Gestion de la navigation (physique) +===========================================*/ +DOM.MENUSIDE.addEventListener('click', function(e){ + var target = e.target; - // On remonte dans les parents au bon niveau - while( target != document.body && !target.getData('link') ) - target = target.parentNode; + // On remonte dans les parents au bon niveau + while( target != document.body && !target.getData('link') ) + target = target.parentNode; - // Si on a trouve l'element, on l'utilise pour la page - if( target.getData('link') ) - navMenu(target.getData('link')); - }, false); + // Si on a trouve l'element, on l'utilise pour la page + if( target.getData('link') ) + navMenu(target.getData('link')); +}, false); - /* [6] Gestion du rechargement de page - =========================================================*/ - function reload(){ navMenu( pageManager.page ); } +/* [6] Gestion du rechargement de page +=========================================================*/ +function reload(){ navMenu( pageManager.page ); } - /* [7] Gestion du toggle de la page de login - =========================================================*/ - var LOGIN = { - show: document.getElementById('user-data'), - hide: document.getElementById('login-close'), - page: document.getElementById('LOGIN') - }; +/* [7] Gestion du toggle de la page de login +=========================================================*/ +var LOGIN = { + show: document.getElementById('user-data'), + hide: document.getElementById('login-close'), + page: document.getElementById('LOGIN') +}; - /* (1) Gestion de l'affichage de la page de login */ - LOGIN.show.addEventListener('click', function(e){ LOGIN.page.className = 'active'; }, false); +/* (1) Gestion de l'affichage de la page de login */ +LOGIN.show.addEventListener('click', function(e){ LOGIN.page.className = 'active'; }, false); - /* (2) Gestion de la fermeture de la page de login */ - LOGIN.hide.addEventListener('click', function(e){ LOGIN.page.className = ''; }, false); +/* (2) Gestion de la fermeture de la page de login */ +LOGIN.hide.addEventListener('click', function(e){ LOGIN.page.className = ''; }, false); - /* [7] On recupere la liste des pages et on lance pageManager - =========================================================*/ - api.send({path:'download/menu'}, function(response){ +/* [7] On recupere la liste des pages et on lance pageManager +=========================================================*/ +api.send({path:'download/menu'}, function(response){ - // si erreur - if( response.ModuleError != 0 ) - return; + // si erreur + if( response.ModuleError != 0 ) + return; - // On initialise la liste des pages - pagelist = []; + // On initialise la liste des pages + pagelist = []; - // On recupere chaque page - for( var i = 0 ; i < response.menu.length; i++ ) - pagelist.push( response.menu[i].attributes['data-link'] ); + // On recupere chaque page + for( var i = 0 ; i < response.menu.length; i++ ) + pagelist.push( response.menu[i].attributes['data-link'] ); - /* (1) On initialisa pageManager */ - pageManager = new pageManagerClass(); - pageManager.setPage(null, '/view', DOM.CONTAINER, pagelist, null ); + /* (1) On initialisa pageManager */ + pageManager = new pageManagerClass(); + pageManager.setPage(null, '/view', DOM.CONTAINER, pagelist, null ); - /* (2) On charge la premiere page */ - navMenu(pageManager.page); - }); + /* (2) On charge la premiere page */ + navMenu(pageManager.page); +}); diff --git a/js/includes/input-facebook-matrice.js b/js/includes/input-facebook-matrice.js index c0bfce5..67ebaf5 100644 --- a/js/includes/input-facebook-matrice.js +++ b/js/includes/input-facebook-matrice.js @@ -171,6 +171,6 @@ inputFacebookMatrice.prototype.attach = function(){ ptr.fieldsToStorage(); setTimeout(function(){ ptr.storageToFields(); }, 500); - + }, false); }; diff --git a/js/includes/input-phone-contact-min.js b/js/includes/input-phone-contact-min.js deleted file mode 100644 index 283b3b6..0000000 --- a/js/includes/input-phone-contact-min.js +++ /dev/null @@ -1,8 +0,0 @@ -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=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+'"]'))}; -inputPhoneContact.prototype.attach=function(a){console.log("CONTACTS: ATTACH");lsi.createDataset("p_contacts");this.storageToFields();this.handler=a;var c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1)}; diff --git a/js/includes/input-phone-fiche-min.js b/js/includes/input-phone-fiche-min.js deleted file mode 100644 index fc9f816..0000000 --- a/js/includes/input-phone-fiche-min.js +++ /dev/null @@ -1,21 +0,0 @@ -function inputPhoneFiche(a,c){this.container=a;this.nav_container=c}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"2",age:".",job:".",famsit:"0",studies:"0",reltype:"0",reltypeSpecial:"",city:"",quartier:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["4","9","14","19","24"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}}; -inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.relation-panel .fiche-relation'),c=0;c FICHE UPDATE"),b.timestamp=Date.now());lsi.set("p_fiches",b.uid,b)}}}; -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 c=lsi.get("p_contacts",a.contact);if(!1===c)return!1;var b="";isNaN(c.existing)||(b=lsi.get("p_friends",c.existing),c.username=b.name,a.age=b.age,a.sexe=b.sexe,a.loc=b.dist,isNaN(b.reltype)?(a.reltype=10,a.reltypeSpecial=b.reltype):(a.reltype=b.reltype,a.reltypeSpecial=""),null!=b.studies2?(a.studies=b.studies2,a.job=b.job,a.famsit=b.famsit,a.city=b.city,a.cp=b.cp,a.quartier=b.quartier,a.duration[0]=b.duration[0],a.duration[1]=b.duration[1], -a.context=b.context,a.contextSpecial=b.contextExtra,a.connect=b.connect,a.connectSpecial=b.connectExtra,a.freq=b.freq,b="Contact import\u00e9: non modifiable!"):b="Contact import\u00e9 (incomplet): modifiable partiellement!");this.container.innerHTML+=pFicheBuilder.build({importedfiche:b,name:c.username,countcall:c.countcall,countsms:c.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]});c=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+ -'"]');null!=c&&c.setAttribute("selected","selected");c=$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=c&&c.setAttribute("selected","selected");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(c=0;cinput[type="radio"][data-name="famsit"]');for(c=0;cinput[type="radio"][data-name="reltype"]');for(c=0;cinput[type="radio"][data-name="loc"]');for(c=0;cinput[type="radio"][data-name="context"]');for(c=0;cinput[type="radio"][data-name="freq"]');for(c=0;cinput[type="radio"][data-name="connect"]');for(c=0;clsi.keys("p_contacts").length?lsi.keys("p_contacts").length:40,e;for(e in a){for(ficheUid=0;-1=d)break}var a=lsi["export"]("p_fiches"),f;for(f in a)if(d=lsi.get("p_contacts",a[f].contact)){c= -null;e=20>parseInt(a[f].uid);for(var g in a)if(!(e&&20>g||!e&&20<=g)&&(b=lsi.get("p_contacts",a[g].contact),g!=f&&b)){var h=0a[f].timestamp||(d=a[f],d.uid=c.uid,lsi.set("p_fiches",c.uid,d))}}; -inputPhoneFiche.prototype.nav=function(a){if(!(a instanceof Element&&a.getData("n"))||isNaN(a.getData("n"))||"p_nav-fiche"!=a.parentNode.id)return!1;for(var c=$$('[data-sublink="phone"] #p_nav-fiche > span.active'),b=0;bAPPELS");20>d&&b'+(d%20+1)+"  ":(20==d&&(this.nav_container.innerHTML+='
   SMS   '),this.nav_container.innerHTML+=''+(d%20+1)+"")}for(var e in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[e].uid+'"]'),null!=c&&(!0===a[e].valid?c.addClass("done"):c.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 c=this;this.nav_container.addEventListener("click",function(a){c.nav(a.target);c.handler(a.target)},!1)}; diff --git a/js/includes/input-phone-matrice-min.js b/js/includes/input-phone-matrice-min.js deleted file mode 100644 index 74da075..0000000 --- a/js/includes/input-phone-matrice-min.js +++ /dev/null @@ -1,6 +0,0 @@ -var inputPhoneMatrice=function(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 c={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b])));lsi.set("p_matrice",0,c)}; -inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);a="";for(d=0;d";0',a+=g.username,a+=""):a+="";for(var f=0;f",a+='', -a+=h.username,a+=""):f",a+=""):a+=""}a+=""}this.container.innerHTML=a+"
"}; -inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(c){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1)}; -inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),c;for(c in a)if(a[c]instanceof Element){var b=a[c].getData("name"),e=a[c].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][e]=a[c]}}; diff --git a/js/includes/input-phone-matrice.js b/js/includes/input-phone-matrice.js index c8d774b..dbc0cb2 100644 --- a/js/includes/input-phone-matrice.js +++ b/js/includes/input-phone-matrice.js @@ -178,7 +178,7 @@ inputPhoneMatrice.prototype.attach = function(){ }, false); - + console.groupEnd('[phone.matrice] attaching events'); }; diff --git a/js/includes/input-phone-mini-min.js b/js/includes/input-phone-mini-min.js deleted file mode 100644 index e4d723f..0000000 --- a/js/includes/input-phone-mini-min.js +++ /dev/null @@ -1,13 +0,0 @@ -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:{contact:null,sexe:"2",age:".",studies:"0",loc:".",reltype:"9",reltypeSpecial:"",unknown:!1,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 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,unknown:null!=c.unknown,hash:e};c.valid=this.check(c);0 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;a.unknown=null!=a.unknown?a.unknown:this.defaultData.unknown; -var b=lsi.get("p_contacts",a.uid);if(!1===b)return!1;if(!isNaN(b.existing)){var c=lsi.get("p_friends",b.existing);b.username=c.name;a.contact=b.uid;a.age=c.age;a.sexe=c.sexe;a.loc=c.dist;isNaN(c.reltype)?(a.reltype=10,a.reltypeSpecial=c.reltype):(a.reltype=c.reltype,a.reltypeSpecial="");null!=c.studies1&&(a.studies=c.studies1)}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");c=$$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]');for(b=0;binput[type="radio"][data-name="reltype"]');for(b=0;binput[type="radio"][data-name="loc"]');for(b=0;binput[type="checkbox"][data-name="unknown"]');null!=b&&a.unknown&&b.setAttribute("checked","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;ficheIndexes=lsi.keys("p_fiches");for(b in ficheIndexes)delete a[ficheIndexes[b]];for(var c in a){var e=0==a[c].username.length?c.toString()+"-":c;b=lsi.get("p_mini-fiches",e);null==b&&(b=this.defaultData,b.contact=a[c].uid,b.valid=!1);b.uid=parseInt(c);lsi.set("p_mini-fiches",e,b)}b=lsi["export"]("p_mini-fiches");if(null==b[this.selected])for(c in b)if(!isNaN(c)){this.selected=parseInt(c); -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+"");for(c in a)isNaN(c)||(b=$('[data-sublink="phone"] #p_nav-mini span[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 span[data-n="'+this.selected+'"]'))}; -inputPhoneMini.prototype.check=function(a){return a.unknown?!0:""==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)}; diff --git a/js/includes/input-phone-subject-min.js b/js/includes/input-phone-subject-min.js deleted file mode 100644 index 1ddee60..0000000 --- a/js/includes/input-phone-subject-min.js +++ /dev/null @@ -1,2 +0,0 @@ -function inputPhoneSubject(a,b,c){this.tmp_id=a;this.subject_id=b;this.store_button=c}inputPhoneSubject.prototype={store_button:this.store_button,tmp_id:this.tmp_id,subject_id:this.subject_id,handler:null};inputPhoneSubject.prototype.check=function(){return 0b;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>>8^d[(b^a.charCodeAt(c))&255];return(b^-1)>>>0}; diff --git a/js/lib/crc32.js b/js/lib/crc32.js index 77b8a06..6415258 100644 --- a/js/lib/crc32.js +++ b/js/lib/crc32.js @@ -1,23 +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 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); + 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]; - } + for (var i = 0; i < str.length; i++ ) { + crc = (crc >>> 8) ^ crcTable[(crc ^ str.charCodeAt(i)) & 0xFF]; + } - return (crc ^ (-1)) >>> 0; + return (crc ^ (-1)) >>> 0; }; diff --git a/js/lib/form-builder-min-min.js b/js/lib/form-builder-min-min.js deleted file mode 100644 index 8b13789..0000000 --- a/js/lib/form-builder-min-min.js +++ /dev/null @@ -1 +0,0 @@ - diff --git a/js/lib/form-builder-min.js b/js/lib/form-builder-min.js deleted file mode 100644 index 9d55bff..0000000 --- a/js/lib/form-builder-min.js +++ /dev/null @@ -1,31 +0,0 @@ -var ref=function(a,b){for(var d=null;null==d||a.hasOwnProperty(d);)d="$"+(268435456+Math.floor(4026531839*Math.random())).toString(16)+"$";a[d]=b;return d},WrapperTable={},Wrapper=function(a){do a=268435456+Math.floor(4294967295*Math.random());while(WrapperTable[a]);return{}},FormBuilder=function(a){this.form_object=a;this.observer=new MutationObserver(FormBuilder.DOMUpdates)}; -FormBuilder.prototype={form_object:this.form_object,defs_object:{},parent_element:null,built_form:null,root_element:null,ref_table:{$00000000$:null},ref_assoc:{NULL:"$00000000$"},observer:this.observer,scope:{}};FormBuilder.regex={reg_in_key:/^\/\^(.+)\$\/$/,reg_out_val:/\{(\$[1-9])\}/,pri_out_val:/\{([a-z_]+)\}/g,pri_in_key:/^\$([a-z_]+)$/,arr_out_set:/^\{([a-z_]+)\[\]\}$/,arr_out_val:/\{([a-z_]+)([\.:])([a-z_]+)\}/g,arr_in_key:/^\$([a-z_]+)$/,fun_out_val:/^\{([a-z_]+)\(\)\}$/,ref_pri:/^\$[a-f0-9]{8}\$$/}; -FormBuilder.spread_attr="children next_nodes prev_nodes attributes node_link listeners repeat browse funcs".split(" ");FormBuilder.spec_attr=["_value","_selected"];FormBuilder.observe={attributes:{attributes:!0,attributeOldValue:!1,childList:!1,characterData:!1,subtree:!1,characterDataOldValue:!1},characterData:{attributes:!1,attributeOldValue:!1,childList:!1,characterData:!0,subtree:!1,characterDataOldValue:!0}};FormBuilder.debug_time=!1;FormBuilder.debug_time_details=!1; -FormBuilder.debugStart=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};var d="["+parseInt(64424509439*Math.random()).toString(16)+"]";console.time(d);console.group(a);return{type:b,time_r:d,group:a}};FormBuilder.debug=function(a,b){if(1!=b||!FormBuilder.debug_time)if(2!=b||!FormBuilder.debug_time_details)return{type:0};console.debug(a)}; -FormBuilder.debugStop=function(a){if(1!=a.type||!FormBuilder.debug_time)if(2!=a.type||!FormBuilder.debug_time_details)return null;console.timeEnd(a.time_r);console.groupEnd(a.group)};FormBuilder.prototype.add_definition=function(a){var b=FormBuilder.debugStart("FormBuilder.add_definition",1),d;for(d in a)this.defs_object[d]=a[d];FormBuilder.debugStop(b)}; -FormBuilder.prototype.build=function(a){var b=FormBuilder.debugStart("FormBuilder.build",1);a=null==a?{}:a;for(var d in a)a[d]=ref(this.ref_table,a[d]),this.ref_assoc[d]=a[d],this.scope["$"+d]=this.ref_assoc[d],this.__defineGetter__("$"+d,function(a,b){return function(){return a.ref_table[a.scope["$"+b]]}}(this,d)),this.__defineSetter__("$"+d,function(a,b){return function(d){a.ref_table[a.scope["$"+b]]=d;a.attach()}}(this,d));this.built_form=JSON.parse(JSON.stringify(this.form_object));this.built_form= -FormBuilder.replaceStatements(this.built_form,a,this.defs_object,this.ref_table,this.ref_assoc);FormBuilder.debugStop(b)};FormBuilder.prototype.update=function(a){var b=FormBuilder.debugStart("FormBuilder.update",1);a=null==a?{}:a;for(var d in a)this.ref_assoc.hasOwnProperty(d)&&(this.ref_table[this.ref_assoc[d]]=a[d]);FormBuilder.debugStop(b)}; -FormBuilder.prototype.attach=function(a){var b=FormBuilder.debugStart("FormBuilder.attach",1);if(!(a instanceof Element)&&null===this.parent_element)return!1;this.parent_element=a instanceof Element?a:this.parent_element;this.built_form.hasOwnProperty("dom")&&(this.observer.disconnect(),FormBuilder.detachElements(this.parent_element,this.built_form.dom));FormBuilder.createElements(this.built_form,this.ref_table,this.ref_assoc);FormBuilder.attachElements(this.parent_element,this.built_form.dom);this.observer.observe(this.parent_element, -FormBuilder.observe.attributes);FormBuilder.debugStop(b)}; -FormBuilder.fetchNodeDefinition=function(a,b){var d=FormBuilder.debugStart("FormBuilder::fetchNodeDefinition",2);FormBuilder.debug('node = "'+a+'"',2);var e,f;r=FormBuilder.regex.reg_in_key;if("undefined"!=typeof b&&b.hasOwnProperty(a))return FormBuilder.debugStop(d),{def:b[a]};for(e in b)if(r.test(e)&&(f=new RegExp(e.slice(1,-1)),f.test(a))){matches={};for(f=1;ff;f++)matches["$"+f]=RegExp["$"+f];FormBuilder.debugStop(d);return{def:b[e],scope:matches}}FormBuilder.debugStop(d);return{}}; -FormBuilder.replaceStatements=function(a,b,d,e,f){var g=FormBuilder.debugStart("FormBuilder::replaceStatements",2);a=a instanceof Object?a:{};b=b instanceof Object?JSON.parse(JSON.stringify(b)):{};var c,h;if(a.hasOwnProperty("scope")&&a.scope instanceof Object)for(c in a.scope)b[c]=a.scope[c];if(a.hasOwnProperty("node")&&"string"==typeof a.node&&(h=FormBuilder.fetchNodeDefinition(a.node,d),h.hasOwnProperty("def")&&(a.node_link=JSON.parse(JSON.stringify(h.def)),h.hasOwnProperty("scope"))))for(c in h.scope)b[c]= -h.scope[c];a.hasOwnProperty("browse")&&(a.browse.hasOwnProperty("array")&&FormBuilder.regex.arr_out_set.test(a.browse.array)?a.browse.id=RegExp.$1:delete a.browse);for(c in a)"string"==typeof a[c]?(a[c]=[a[c]],h=FormBuilder.replaceStatementsFunction(a[c][0],b,e),!1!==h?a[c]=h:(h=FormBuilder.replaceStatementsArray(a[c][0],b,e),!1!==h?a[c]=h:(a[c]=FormBuilder.replaceStatementsRegex(a[c],b),a[c]=FormBuilder.replaceStatementsPrimary(a[c],b),a[c]=FormBuilder.replaceStatementsArrayValue(a[c],b,e,f)))): -"number"===typeof a[c]&&(a[c]=[ref(e,a[c])]);for(c in a)FormBuilder.regex.pri_in_key.test(c)?b[c.substring(1)]=ref(e,a[c]):FormBuilder.regex.arr_in_key.test(c)&&(b[c.substring(2)]=ref(e,a[c]));b=JSON.parse(JSON.stringify(b));for(c in a)if(-1=d.lastIndex);)g=d.lastIndex,f.push(e);for(e=g=0;e",2);FormBuilder.debugStop(e);return a.dom=f}; -FormBuilder.attachElements=function(a,b){var d=FormBuilder.debugStart("FormBuilder::attachElements",2),e,f;for(e in b){for(f in b[e].prev)b[e].prev[f]instanceof Element&&a.appendChild(b[e].prev[f]),b[e].prev[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].prev[f]]);for(f in b[e].node)b[e].node[f]instanceof Element&&a.appendChild(b[e].node[f]),b[e].node[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].node[f]]);for(f in b[e].next)b[e].next[f]instanceof Element&&a.appendChild(b[e].next[f]), -b[e].next[f]instanceof Object&&FormBuilder.attachElements(a,[b[e].next[f]])}FormBuilder.debugStop(d)}; -FormBuilder.detachElements=function(a,b){var d,e;for(d in b){for(e in b[d].prev)b[d].prev[e]instanceof Element&&a.hasChildNodes(b[d].prev[e])&&a.removeChild(b[d].prev[e]),b[d].prev[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].prev[e]]);for(e in b[d].node)b[d].node[e]instanceof Element&&a.hasChildNodes(b[d].node[e])&&a.removeChild(b[d].node[e]),b[d].node[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].node[e]]);for(e in b[d].next)b[d].next[e]instanceof Element&&a.hasChildNodes(b[d].next[e])&& -a.removeChild(b[d].next[e]),b[d].next[e]instanceof Object&&FormBuilder.detachElements(a,[b[d].next[e]])}};FormBuilder.applyCSS=function(a,b){for(var d in b)a.style[d]=b[d]};FormBuilder.fetchNodeType=function(a){if(a.hasOwnProperty("node_type"))return a.node_type;if(a.hasOwnProperty("node_link"))return FormBuilder.fetchNodeType(a.node_link)}; -FormBuilder.DOMUpdates=function(a,b,d){var e,f,g,c=FormBuilder.regex.ref_pri;for(e in b)if(f=b[e].attributeName,a.hasOwnProperty("attributes")&&a.attributes.hasOwnProperty(f)&&(g=a.attributes[f]),g instanceof Array&&1==g.length&&c.test(g[0])||c.test(g))g=g[0]||g,g=FormBuilder.fetchRef(d,g),d[g]=b[e].target.getAttribute(f)}; diff --git a/js/lib/api-min.js b/js/lib/min/api.js similarity index 100% rename from js/lib/api-min.js rename to js/lib/min/api.js diff --git a/js/lib/element-object-min.js b/js/lib/min/element-object.js similarity index 100% rename from js/lib/element-object-min.js rename to js/lib/min/element-object.js diff --git a/js/lib/form-deflater-min.js b/js/lib/min/form-deflater.js similarity index 100% rename from js/lib/form-deflater-min.js rename to js/lib/min/form-deflater.js diff --git a/js/lib/html-builder-min.js b/js/lib/min/html-builder.js similarity index 100% rename from js/lib/html-builder-min.js rename to js/lib/min/html-builder.js diff --git a/js/lib/input-checker-min.js b/js/lib/min/input-checker.js similarity index 100% rename from js/lib/input-checker-min.js rename to js/lib/min/input-checker.js diff --git a/js/lib/local-storage-interface-min.js b/js/lib/min/local-storage-interface.js similarity index 100% rename from js/lib/local-storage-interface-min.js rename to js/lib/min/local-storage-interface.js diff --git a/js/lib/notif-min.js b/js/lib/min/notif.js similarity index 100% rename from js/lib/notif-min.js rename to js/lib/min/notif.js diff --git a/js/lib/min/page-manager.js b/js/lib/min/page-manager.js new file mode 100644 index 0000000..6462ef4 --- /dev/null +++ b/js/lib/min/page-manager.js @@ -0,0 +1,10 @@ +function pageManagerClass(){}var ptrPageManagerClass; +pageManagerClass.prototype={depJS:null,depCSS:null,xhr:[],activeXHR:null,page:null,vars:[],root:"",path:"",jsPath:"js",cssPath:"css",pagelist:null,container:null,ajax:function(b,c,d,a){var e;e=this.xhr.push(window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest"))-1;this.activeXHR=this.xhr[e];this.xhr[e].addEventListener("readystatechange",function(a){if(void 0!=this.xhr[a]&&4===this.xhr[a].readyState){-1<[0,200].indexOf(this.xhr[a].status)?c(this.xhr[a].responseText): +c();this.xhr[a]=null;var b=!0;for(a=0;a -1 ) // si fichier existe et reçu - pHandler(self.xhr[index].responseText); + if( [0,200].indexOf(this.xhr[i].status) > -1 ) // si fichier existe et reçu + pHandler(this.xhr[i].responseText); else // si code d'erreur retourne null pHandler(); // On supprime la requête - self.xhr[index] = null; + this.xhr[i] = null; // S'il n'y a plus de requête active, on supprime tout var empty = true; - for( var i = 0 ; i < self.xhr.length ; i++ ) - if( self.xhr[i] !== null ){ + for( var i = 0 ; i < this.xhr.length ; i++ ) + if( this.xhr[i] !== null ){ empty = false; break; } // Si tout est vide, on efface - empty && ( self.xhr = [] ); + empty && ( this.xhr = [] ); } - }, false); + }.bind(this, index), false); // gestion de la méthode var method = ( typeof pMethod == 'string' && /^POST|GET$/i.test(pMethod) ) ? pMethod.toUpperCase() : 'POST'; @@ -231,37 +229,31 @@ pageManagerClass.prototype = { /* on attribue le paramètre pContainer à l'attribut si il est spécifié */ this.container = ( typeof pContainer == 'object' && pContainer instanceof Element ) ? pContainer : this.container; - // si this.pagelist && this.container ne sont pas null && + // si this.pagelist && this.container ne sont pas null if( this.pagelist != null && this.container != null ){ + // si le pName est renseigné et qu'il est dans pagelist if( typeof pName == 'string' && this.pagelist.indexOf(pName) > -1 ){ // affecte pName à l'attribut page this.page = pName; - // charge le contenu de la page dans le container - var ptrPageManagerClass = this; - // formulaire POST var fd = new FormData(); for( var i = 0 ; i < this.vars.length ; i++ ) fd.append(this.vars[i], null); this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){ - ptrPageManagerClass.container.innerHTML = e; - ptrPageManagerClass.loadDependencies(); - }, 'POST', fd); + this.container.innerHTML = e; + this.loadDependencies(); + }.bind(this), 'POST', fd); // change l'URL en conséquences(stateObj, titre, url) this.updateURL(); }else{ // si la page n'est pas spécifiée ou qu'elle n'est pas dans la liste des pages var urlGet = this.explodeURL(); - // si on a récupéré le numéro de la page dans l'URL et qu'elle fait partie de la liste des pages if( urlGet != null ){ - this.page = urlGet.page; - // charge le contenu de la page dans le container - var ptrThis = this; // formulaire POST var fd = new FormData(); @@ -272,10 +264,18 @@ pageManagerClass.prototype = { fd.append(this.vars[i], null); } + + // si différent de la page actuelle, on charge la page + if( urlGet.page == this.page ){ + return this; + } + + this.page = urlGet.page; + this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){ - ptrThis.container.innerHTML = e; - ptrThis.loadDependencies(); - }, 'POST', fd); + this.container.innerHTML = e; + this.loadDependencies(); + }.bind(this), 'POST', fd); // change l'URL en conséquences(stateObj, titre, url) this.updateURL(); diff --git a/js/min/action-script.js b/js/min/action-script.js new file mode 100644 index 0000000..f7a073c --- /dev/null +++ b/js/min/action-script.js @@ -0,0 +1,8 @@ +var DOM,pageManager,api,Notification,navSubMenu=function(a){var c=$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?$("#MENU-SIDE > span[data-link="+pageManager.page+'] + div.sub > span[data-sublink="'+a+'"]'):b,b=null==b?$("#MENU-SIDE > span[data-link="+pageManager.page+"] + div.sub > span[data-sublink]"):b;if(null==b)return!1;null!=c&&c.remClass("active");c=$$("#CONTAINER > section[data-sublink].active"); +for(a=0;a section[data-sublink="'+b.getData("sublink")+'"]'),a=0;a #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?$('#WRAPPER > #MENU-SIDE > span[data-link="'+ +a+'"]'):b,b=null==b?$('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]'):b;if(null==b)return!1;null!=c&&c.remClass("active");null!=b&&b.addClass("active");b.getData("link")&&(DOM.HEADER.addClass("loading"),b.getData("link")!=pageManager.page&&pageManager.setPage(b.getData("link")),pageManager.activeXHR.addEventListener("loadend",function(){console.log(pageManager.vars[0],$$("#CONTAINER > section[data-sublink]"));1<=pageManager.vars.length&&null!=$('#CONTAINER > section[data-sublink="'+ +pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);var a=$("#MENU-SIDE > span[data-link="+pageManager.page+"] + div.sub");null!=a&&a.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1);DOM.HEADER.remClass("loading")},!1))};DOM={WRAPPER:$("body > #WRAPPER"),HEADER:$("body > #WRAPPER > #HEADER"),MENUSIDE:$("body > #WRAPPER > #MENU-SIDE"),CONTAINER:$("body > #WRAPPER > #CONTAINER")}; +api=new APIClass("/api/");Notification=new NotificationClass($("#notification-container"));Notification.defaultTimeout=4E3; +Notification.errorCodes={"-1":"Erreur de r\u00e9seau, veuillez recharger la page et r\u00e9essayer",0:"Erreur interne",1:"Erreur interne",2:"Erreur interne",3:"Le fichier est introuvable",4:"Erreur interne",5:"Erreur interne",6:"Erreur interne",7:"Erreur interne",8:"Erreur interne",9:"Certaines donn\u00e9es sont manquantes",10:"Erreur interne",11:"Erreur interne",12:"Erreur interne",13:"Erreur interne",14:"Erreur interne",15:"Erreur interne",16:"Vous n'avez pas la permission d'effectuer cette action", +17:"Le t\u00e9l\u00e9chargement a \u00e9chou\u00e9",18:"Le fichier est invalide (format incorrect)"};lsi.setStorage(localStorage);DOM.MENUSIDE.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("link");)a=a.parentNode;a.getData("link")&&navMenu(a.getData("link"))},!1);function reload(){navMenu(pageManager.page)}var LOGIN={show:document.getElementById("user-data"),hide:document.getElementById("login-close"),page:document.getElementById("LOGIN")}; +LOGIN.show.addEventListener("click",function(a){LOGIN.page.className="active"},!1);LOGIN.hide.addEventListener("click",function(a){LOGIN.page.className=""},!1);api.send({path:"download/menu"},function(a){if(0==a.ModuleError){pagelist=[];for(var c=0;c - - - - - - - - - - + + + + + + + + + + - - + + @@ -117,7 +117,7 @@ - + diff --git a/view/js/input.js b/view/js/input.js index 61771ed..252f2e3 100644 --- a/view/js/input.js +++ b/view/js/input.js @@ -90,16 +90,18 @@ sField.addEventListener('keypress', function(e){ + /*=========================================================*/ /*========== Gestion du formulaire téléphonique ===========*/ /*=========================================================*/ -var phoneRoutineExecuted = false; +var pAlready = false; +var pLoaded = [ false, false, false, false, false ]; var phoneRoutine = function(){ - if( phoneRoutineExecuted ) - return; - - phoneRoutineExecuted = true; + if( !(pLoaded[0] && pLoaded[1] && pLoaded[2] && pLoaded[3] && pLoaded[4] && !pAlready) ) + return; + + pAlready = true; // console.log( phoneRoutineExecuted, typeof inputPhoneSubject ); // console.log( phoneRoutineExecuted, typeof inputPhoneContact ); @@ -343,16 +345,11 @@ var phoneRoutine = function(){ }; - -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', phoneRoutine); - }); - }); - }); -}); +include('/js/includes/input-phone-subject.js', function(){ pLoaded[0] = true; phoneRoutine(); }); +include('/js/includes/input-phone-contact.js', function(){ pLoaded[1] = true; phoneRoutine(); }); +include('/js/includes/input-phone-mini.js', function(){ pLoaded[2] = true; phoneRoutine(); }); +include('/js/includes/input-phone-fiche.js', function(){ pLoaded[3] = true; phoneRoutine(); }); +include('/js/includes/input-phone-matrice.js', function(){ pLoaded[4] = true; phoneRoutine(); }); diff --git a/view/js/min/input.js b/view/js/min/input.js index 2f19925..62c42a8 100644 --- a/view/js/min/input.js +++ b/view/js/min/input.js @@ -2,7 +2,7 @@ var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager= var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c=[],g;for(g in a.results)c.push("
  • "),c.push("
    SUJET
    "),c.push("
    "),c.push("
    "+ a.results[g].name+"
    "),c.push("
    "+a.results[g].creation+"
    "),c.push("
    "),c.push("
    "),c.push("
    "),c.push("
    "),c.push("
  • ");sList.innerHTML= c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1); -var phoneRoutineExecuted=!1,phoneRoutine=function(){phoneRoutineExecuted||(phoneRoutineExecuted=!0,console.group("[phone] Initialization"),pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')),pSubjectManager.attach(pDynamicUpdate),pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'), +var pAlready=!1,pLoaded=[!1,!1,!1,!1,!1],phoneRoutine=function(){pLoaded[0]&&pLoaded[1]&&pLoaded[2]&&pLoaded[3]&&pLoaded[4]&&!pAlready&&(pAlready=!0,console.group("[phone] Initialization"),pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')),pSubjectManager.attach(pDynamicUpdate),pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'), $('[data-sublink="phone"] #p_nav-contact')),pContactManager.attach(pDynamicUpdate),pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini')),pMiniManager.attach(pDynamicUpdate),pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche')),pFicheManager.attach(pDynamicUpdate),pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel')), pMatriceManager.attach(pDynamicUpdate),$('[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");lsi.clear("p_friends");pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.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 b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a)); @@ -10,7 +10,7 @@ b.click()},!1),$('[data-sublink="phone"] #p_import-all').addEventListener("click 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);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1),$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage(); pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du sujet"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La fiche rapide "+b+" est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention", "La fiche compl\u00e8te "+(parseInt(c)+1)+" est incompl\u00e8te et/ou incorrecte"),!1;c={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(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est "+a.subject_id+" ! Tout s'est bien d\u00e9roul\u00e9.", -1E4);console.log(a)},!1)},!1),console.groupEnd("[phone] Initialization"))};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",phoneRoutine)})})})}); +1E4);console.log(a)},!1)},!1),console.groupEnd("[phone] Initialization"))};include("/js/includes/input-phone-subject.js",function(){pLoaded[0]=!0;phoneRoutine()});include("/js/includes/input-phone-contact.js",function(){pLoaded[1]=!0;phoneRoutine()});include("/js/includes/input-phone-mini.js",function(){pLoaded[2]=!0;phoneRoutine()});include("/js/includes/input-phone-fiche.js",function(){pLoaded[3]=!0;phoneRoutine()});include("/js/includes/input-phone-matrice.js",function(){pLoaded[4]=!0;phoneRoutine()}); 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="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));fSubjectManager.attach(fDynamicUpdate); 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");lsi.clear("f_friends");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();