Correction du pb du double chargement des pages (niveau de 'navMenu' avec 'page-manager.js' DONE PUTAINNNNNN!!!!!!

This commit is contained in:
xdrm-brackets 2016-10-10 12:24:03 +02:00
parent d1aed90146
commit edf94ab9ac
35 changed files with 196 additions and 268 deletions

View File

@ -63,7 +63,7 @@ var navSubMenu = function(subsection){
// navMenu(pageManager.page); // navMenu(pageManager.page);
pageManager.updateURL(); pageManager.updateURL();
} };
/* [4] Toggle du side-menu <-> navigation /* [4] Toggle du side-menu <-> navigation
@ -108,16 +108,14 @@ var navMenu = function(section){
if( target.getData('link') ){ if( target.getData('link') ){
DOM.HEADER.addClass('loading'); // Animation de chargement DOM.HEADER.addClass('loading'); // Animation de chargement
pageManager.setPage( target.getData('link') ); var handlerX = function(){
console.log(pageManager.vars[0], $$('#CONTAINER > section[data-sublink]'));
pageManager.activeXHR.addEventListener('loadend', function(){
// On gere la navigation du sous-menu (si defini, utilise) // On gere la navigation du sous-menu (si defini, utilise)
var subSectionExists = pageManager.vars.length >= 1 && $('#CONTAINER > section[data-sublink="'+pageManager.vars[0]+'"]') != null; 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 // 1. Si le lien du menu associe existe -> on charge la page associee
else // sinon // 2. Sinon -> on charge le lien par defaut
navSubMenu(null); // on charge le lien par defaut subSectionExists ? navSubMenu(pageManager.vars[0]) : navSubMenu(null);
// GESTION DE LA NAVIGATION DU SOUS-MENU // GESTION DE LA NAVIGATION DU SOUS-MENU
@ -136,59 +134,66 @@ var navMenu = function(section){
// On retire l'icone de chargement // On retire l'icone de chargement
DOM.HEADER.remClass('loading'); 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 /* (x) Si on change de page, on charge la nouvelle charge */
api = new APIClass('/api/'); if( target.getData('link') != pageManager.page )
pageManager.setPage( target.getData('link') );
// On crée une instance du gestionnaire des notifications pageManager.activeXHR.addEventListener('loadend', handlerX, false);
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', /* [0] Initialisation des variables en local
7: 'Erreur interne', =========================================================*/
8: 'Erreur interne', DOM = {
9: 'Certaines données sont manquantes', WRAPPER: $('body > #WRAPPER'),
10: 'Erreur interne', HEADER: $('body > #WRAPPER > #HEADER'),
11: 'Erreur interne', MENUSIDE: $('body > #WRAPPER > #MENU-SIDE'),
12: 'Erreur interne', CONTAINER: $('body > #WRAPPER > #CONTAINER')
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' // On cree une instance de l'api
lsi.setStorage(localStorage); 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) /* [5] Gestion de la navigation (physique)
===========================================*/ ===========================================*/
DOM.MENUSIDE.addEventListener('click', function(e){ DOM.MENUSIDE.addEventListener('click', function(e){
var target = e.target; var target = e.target;
// On remonte dans les parents au bon niveau // On remonte dans les parents au bon niveau
while( target != document.body && !target.getData('link') ) while( target != document.body && !target.getData('link') )
target = target.parentNode; target = target.parentNode;
// Si on a trouve l'element, on l'utilise pour la page // Si on a trouve l'element, on l'utilise pour la page
if( target.getData('link') ) if( target.getData('link') )
navMenu(target.getData('link')); navMenu(target.getData('link'));
}, false); }, false);
/* [6] Gestion du rechargement de page /* [6] Gestion du rechargement de page
=========================================================*/ =========================================================*/
function reload(){ navMenu( pageManager.page ); } function reload(){ navMenu( pageManager.page ); }
/* [7] Gestion du toggle de la page de login /* [7] Gestion du toggle de la page de login
=========================================================*/ =========================================================*/
var LOGIN = { var LOGIN = {
show: document.getElementById('user-data'), show: document.getElementById('user-data'),
hide: document.getElementById('login-close'), hide: document.getElementById('login-close'),
page: document.getElementById('LOGIN') page: document.getElementById('LOGIN')
}; };
/* (1) Gestion de l'affichage de la page de login */ /* (1) Gestion de l'affichage de la page de login */
LOGIN.show.addEventListener('click', function(e){ LOGIN.page.className = 'active'; }, false); LOGIN.show.addEventListener('click', function(e){ LOGIN.page.className = 'active'; }, false);
/* (2) Gestion de la fermeture de la page de login */ /* (2) Gestion de la fermeture de la page de login */
LOGIN.hide.addEventListener('click', function(e){ LOGIN.page.className = ''; }, false); LOGIN.hide.addEventListener('click', function(e){ LOGIN.page.className = ''; }, false);
/* [7] On recupere la liste des pages et on lance pageManager /* [7] On recupere la liste des pages et on lance pageManager
=========================================================*/ =========================================================*/
api.send({path:'download/menu'}, function(response){ api.send({path:'download/menu'}, function(response){
// si erreur // si erreur
if( response.ModuleError != 0 ) if( response.ModuleError != 0 )
return; return;
// On initialise la liste des pages // On initialise la liste des pages
pagelist = []; pagelist = [];
// On recupere chaque page // On recupere chaque page
for( var i = 0 ; i < response.menu.length; i++ ) for( var i = 0 ; i < response.menu.length; i++ )
pagelist.push( response.menu[i].attributes['data-link'] ); pagelist.push( response.menu[i].attributes['data-link'] );
/* (1) On initialisa pageManager */ /* (1) On initialisa pageManager */
pageManager = new pageManagerClass(); pageManager = new pageManagerClass();
pageManager.setPage(null, '/view', DOM.CONTAINER, pagelist, null ); pageManager.setPage(null, '/view', DOM.CONTAINER, pagelist, null );
/* (2) On charge la premiere page */ /* (2) On charge la premiere page */
navMenu(pageManager.page); navMenu(pageManager.page);
}); });

View File

@ -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<a.username.length};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),c=0;c<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate();if(this.check(b)){var d={uid:parseInt(b.uid),username:b.username,existing:isNaN(b.existing)?".":parseInt(b.existing)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(b.uid),d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.username=null!=a.username?a.username:"";a.existing=null!=a.existing?a.existing:".";var c=lsi["export"]("p_friends");a.contacts="";for(var b in c)a.contacts+="\t\t<option value='"+b+"'>"+c[b].name+"</option>\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;b++)a[b].removeEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1),a[b].addEventListener("click",function(a){d.nav(a.target);d.handler(a.target)},!1)};
inputPhoneContact.prototype.storageToFields=function(){console.log("CONTACTS: STORAGE TO FIELDS");var a=lsi.keys("p_contacts");this.container.innerHTML="";for(var c=this.selected+10,b=this.selected;b<c&&b<a.length;b++)this.add(lsi.get("p_contacts",a[b]));c>=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<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneContact.prototype.updateNavBar=function(){var a=lsi.keys("p_contacts").length;if(this.nav_container.children.length!=a){this.nav_container.innerHTML="";for(var c=0;c<a;c+=10)this.nav_container.innerHTML+='<span data-n="'+c+'">'+(1+c/10)+"</span>"}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)};

View File

@ -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<a.length;c++){var b=(new FormDeflater(a[c],["input","select"],["data-name"])).deflate(),d=crc32(JSON.stringify(b)),e=lsi.get("p_fiches",b.uid);if(!1!==e){if(null!=e.hash&&e.hash==d)break;b={contact:parseInt(b.contact),uid:parseInt(b.uid),sexe:b.sexe,age:b.age,job:b.job,famsit:b.famsit,studies:b.studies,reltype:b.reltype,reltypeSpecial:b.reltypeSpecial,
city:b.city,quartier:b.quartier,cp:b.cp,loc:b.loc,duration:b.duration,context:b.context,contextSpecial:b.contextSpecial,freq:b.freq,connect:b.connect,connectSpecial:b.connectSpecial,hash:d};b.valid=this.check(b);0<diff(e,b,["hash","valid","timestamp"]).length&&(console.log(diff(e,b,["hash","valid","timestamp"])),console.warn("> 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;c<b.length;c++)b[c].value==a.sexe?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");
b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(c=0;c<b.length;c++)b[c].value==a.famsit?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(c=0;c<b.length;c++)b[c].value==a.reltype?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");
b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(c=0;c<b.length;c++)b[c].value==a.loc?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(c=0;c<b.length;c++)b[c].value==a.context?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");
b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1<a.freq.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked");b=$$('[data-sublink="phone"] article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(c=0;c<b.length;c++)-1<a.connect.indexOf(b[c].value)?b[c].setAttribute("checked","checked"):b[c].removeAttribute("checked")};
inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("p_fiches");this.container.innerHTML="";for(var c in a)a[c].uid==this.selected&&this.add(a[c]);this.updateNavBar()};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("p_contacts"),c=[],b,d=40>lsi.keys("p_contacts").length?lsi.keys("p_contacts").length:40,e;for(e in a){for(ficheUid=0;-1<c.indexOf(ficheUid)&&ficheUid<d;)ficheUid++;c.push(ficheUid);a=lsi.get("p_fiches",ficheUid);!a&&(a=this.defaultData);a.uid=ficheUid;a.contact=parseInt(e);lsi.set("p_fiches",ficheUid,a);if(c.length>=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=0<b.username.length&&d.username===b.username;b=!isNaN(b.existing)&&d.existing===b.existing;(h||b)&&(c=a[g]);if(null!==c)break}null===c||c.timestamp>a[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;b<c.length;b++)c[b].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("p_fiches");this.nav_container.innerHTML="";for(var c=Object.keys(a),b=0;b<c.length;b++){var d=parseInt(c[b]);0==d&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>d&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+d+'" class="lc">'+(d%20+1)+"</span>&nbsp;&nbsp;":(20==d&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
d+'">'+(d%20+1)+"</span>")}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]))&&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||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var c=0;c<a.freq.length;c++)if(""==a.freq[c])return!1;for(c=0;c<a.connect.length;c++)if(""==a.connect[c])return!1;return"10"==a.reltype&&2>a.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)};

View File

@ -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="<table class='line'>";for(d=0;d<e.length;d++){var g=b[d],a=a+"<tr>";0<d?(a+='<td style="text-align: right;">',a+=g.username,a+="</td>"):a+="<td></td>";for(var f=0;f<e.length;f++)if(f<e.length-1){var h=b[f];0==d?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',
a+=h.username,a+="</span>"):f<d?(a+="<td>",a+="<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='p_matrice_"+g.uid+"_"+h.uid+"'",null!=c[d]&&-1<c[d].indexOf(f)&&(a+=" checked"),a+=" >",a+="<label for='p_matrice_"+g.uid+"_"+h.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
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]}};

View File

@ -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<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("p_mini-fiches",c.uid);if(!1!==d){if(null!=d&&null!=d.hash&&d.hash==e)break;console.warn("> 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<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> 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;b<c.length;b++)c[b].value==
a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] 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++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('[data-sublink="phone"] 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++)c[b].value==
a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");b=$('[data-sublink="phone"] article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[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.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("p_mini-fiches");this.nav_container.innerHTML="";var b=0,c;for(c in a)isNaN(c)||(this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>");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)};

View File

@ -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 0<this.subject_id.value.length&&!isNaN(this.subject_id.value)};inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("p_subject",0,{tmp_id:this.tmp_id.value,subject_id:this.subject_id.value})};
inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("p_subject",0),a=a||{tmp_id:"",subject_id:""};this.tmp_id.value=a.tmp_id;this.subject_id.value=a.subject_id};inputPhoneSubject.prototype.attach=function(a){console.log("SUBJECT: ATTACH");lsi.createDataset("p_subject");lsi.createDataset("p_friends");this.handler=a;var b=this;this.store_button.addEventListener("click",function(a){b.fieldsToStorage();b.handler(!0);b.storageToFields()},!1);this.storageToFields()};

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

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

View File

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

View File

@ -1 +0,0 @@

View File

@ -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;f<RegExp.length&&10>f;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<FormBuilder.spread_attr.indexOf(c))if(a[c]instanceof Array)for(var k in a[c])FormBuilder.debug("**"+c+"["+k+"]",2),FormBuilder.replaceStatements(a[c][k],b,d,e,f);else a[c]instanceof Object&&(FormBuilder.debug("**"+c,2),FormBuilder.replaceStatements(a[c],b,d,e,
f));FormBuilder.debugStop(g);return a};FormBuilder.replaceStatementsFunction=function(a,b,d){var e=null,e=FormBuilder.regex.fun_out_val.exec(a);if(null===e)return!1;b.hasOwnProperty(e[1])||(b[e[1]]=ref(d,function(){}));return b[e[1]]};FormBuilder.replaceStatementsArray=function(a,b,d){var e=null,e=FormBuilder.regex.arr_out_set.exec(a);if(null===e)return!1;b.hasOwnProperty(e[1])||(b[e[1]]=ref(d,[]));return b[e[1]]};
FormBuilder.replaceStatementsRegex=function(a,b){var d=FormBuilder.regex.reg_out_val,e=null,f=[],g,c,h,k;for(h=0;h<a.length;h++){m=null;f=[];g=-1;for(c=[];null!==(e=d.exec(a[h]))&&!(g>=d.lastIndex);)g=d.lastIndex,f.push(e);for(e=g=0;e<f.length;e++)k=f[e][1],(0<g||0<f[e].index)&&c.push(a[h].substr(g,f[e].index-g)),b.hasOwnProperty(k)||(b[k]=""),c.push(b[k]),g=f[e].index+f[e][0].length;g<a[h].length&&c.push(a[h].substr(g,a[h].length));a=a.slice(0,h).concat(c).concat(a.slice(h+1))}return a};
FormBuilder.replaceStatementsPrimary=function(a,b){var d=FormBuilder.regex.pri_out_val,e=null,f=[],g,c,h,k;for(h=0;h<a.length;h++){m=null;f=[];g=0;for(c=[];null!==(e=d.exec(a[h]));)f.push(e);for(e=0;e<f.length;e++)k=f[e][1],(0<g||0<f[e].index)&&c.push(a[h].substr(g,f[e].index-g)),b.hasOwnProperty(k)||(b[k]=""),c.push(b[k]),g=f[e].index+f[e][0].length;g<a[h].length&&c.push(a[h].substr(g,a[h].length));a=a.slice(0,h).concat(c).concat(a.slice(h+1))}return a};
FormBuilder.replaceStatementsArrayValue=function(a,b,d,e){b=FormBuilder.regex.arr_out_val;var f=null,g=[],c,h,k,l;for(k=0;k<a.length;k++){m=null;g=[];c=0;for(h=[];null!==(f=b.exec(a[k]));)g.push(f);for(f=0;f<g.length;f++)l=g[f][1]+g[f][2]+g[f][3],(0<c||0<g[f].index)&&h.push(a[k].substr(c,g[f].index-c)),e.hasOwnProperty(l)||(e[l]=ref(d)),h.push(e[l]),c=g[f].index+g[f][0].length;c<a[k].length&&h.push(a[k].substr(c,a[k].length));a=a.slice(0,k).concat(h).concat(a.slice(k+1))}return a};
FormBuilder.readRef=function(a,b){var d,e="";if("string"==typeof b&&FormBuilder.regex.ref_pri.test(b)){for(;"string"==typeof b&&FormBuilder.regex.ref_pri.test(b);)b=a[b],b instanceof Array&&1==b.length&&(b=b[0]);return b}for(d in b)e=FormBuilder.regex.ref_pri.test(b[d])&&a.hasOwnProperty(b[d])?a[b[d]]instanceof Array?e+FormBuilder.readRef(a,a[b[d]]):e+a[b[d]]:e+b[d].toString();return e};FormBuilder.fetchRef=function(a,b){for(var d=FormBuilder.regex.ref_pri,e=b;d.test(b);)e=b,b=a[b][0]||a[b];return e};
FormBuilder.createElements=function(a,b,d){var e=FormBuilder.debugStart("FormBuilder::createElements",2),f=[],g,c,h,k,l,n=["NULL"],p,t;if(a.hasOwnProperty("repeat")&&(l=FormBuilder.readRef(b,a.repeat.n),!isNaN(l)))for(n=[],d.hasOwnProperty(a.repeat.id+":i")||(d[a.repeat.id+":i"]=ref(0)),d.hasOwnProperty(a.repeat.id+":n")||(d[a.repeat.id+":n"]=ref(l)),g=0;g<l;g++)n[g]={},n[g][a.repeat.id+":i"]=g,n[g][a.repeat.id+":n"]=l;if(a.hasOwnProperty("browse")&&(l=FormBuilder.readRef(b,a.browse.array),-1<["object",
"array"].indexOf(typeof l))){n=[];p=[];t={};h=new RegExp(a.browse.id+".(.+)");for(g in d)h.test(g)&&p.push(RegExp.$1);if(a.browse.hasOwnProperty("funcs"))for(g in a.browse.funcs)h.test(g)&&(t[RegExp.$1]=FormBuilder.readRef(b,a.browse.funcs[g]));d.hasOwnProperty(a.browse.id+":i")||(d[a.browse.id+":i"]=ref(0));d.hasOwnProperty(a.browse.id+":n")||(d[a.browse.id+":n"]=ref(0));var q=[];if(l instanceof Array)for(g=0;g<l.length;g++)q.push(g);else for(g in l)q.push(g);for(g in q){h=q[g];n[h]={};for(c in p)t.hasOwnProperty(p[c])?
n[h][a.browse.id+"."+p[c]]=t[p[c]](h,l[h]):l[h].hasOwnProperty(p[c])&&(n[h][a.browse.id+"."+p[c]]=l[h][p[c]]);n[h][a.browse.id+":i"]=h;n[h][a.browse.id+":n"]=q.length}}for(c=0;c<n.length;c++){f[c]={prev:[],node:[],next:[]};if(n[c]instanceof Object)for(g in n[c])b[d[g]]=n[c][g];if(a.hasOwnProperty("prev_nodes"))for(g in a.prev_nodes)f[c].prev=FormBuilder.createElements(a.prev_nodes[g],b,d);if(a.hasOwnProperty("next_nodes"))for(g in a.next_nodes)f[c].next=FormBuilder.createElements(a.next_nodes[g],
b,d);if(a.hasOwnProperty("node_link"))for(g in l=FormBuilder.createElements(a.node_link,b,d),l)f[c].prev=f[c].prev.concat(l[g].prev),f[c].node=f[c].node.concat(l[g].node),f[c].next=l[g].next.concat(f[c].next);else a.hasOwnProperty("node_type")&&("text"===a.node_type&&a.hasOwnProperty("text")?f[c].node.push(document.createTextNode(FormBuilder.readRef(b,a.text)))-1:f[c].node.push(document.createElement(FormBuilder.readRef(b,a.node_type)))-1);if(a.hasOwnProperty("attributes"))for(g in a.attributes)for(k in f[c].node)f[c].node[k].setAttribute(g,
FormBuilder.readRef(b,a.attributes[g]));if(a.hasOwnProperty("css"))for(k in f[c].node)FormBuilder.applyCSS(f[c].node[k],a.css);if(a.hasOwnProperty("text"))for(k in f[c].node)f[c].node[k].innerHTML=FormBuilder.readRef(b,a.text);if(a.hasOwnProperty("listeners"))for(g in a.listeners)for(k in f[c].node)f[c].node[k].addEventListener(g,FormBuilder.readRef(b,a.listeners[g]),!1);if(a.hasOwnProperty("children"))for(g in a.children)for(k in l=FormBuilder.createElements(a.children[g],b,d),f[c].node)FormBuilder.attachElements(f[c].node[k],
l);for(k in f[c].node)if(l="input"==FormBuilder.fetchNodeType(a)&&a.hasOwnProperty("_value"),"select"==FormBuilder.fetchNodeType(a)&&a.hasOwnProperty("_selected")){for(g=0;g<f[c].node[k].children.length;g++)f[c].node[k].children[g].value==FormBuilder.readRef(b,a._selected)?f[c].node[k].children[g].setAttribute("selected",!0):f[c].node[k].children[g].removeAttribute("selected");f[c].node[k].addEventListener("change",function(c){a._selected instanceof Array&&!(1<a._selected.length)&&FormBuilder.regex.ref_pri.test(a._selected[0])&&
(c=a._selected[0],c=FormBuilder.fetchRef(b,c),b[c]=this.value)},!1)}else l?f[c].node[k].addEventListener("input",function(c){a._value instanceof Array&&!(1<a._value.length)&&FormBuilder.regex.ref_pri.test(a._value[0])&&(c=a._value[0],c=FormBuilder.fetchRef(b,c),b[c]=this.value)},!1):(a.hasOwnProperty("observers")||(a.observers=[]),l=new MutationObserver(function(a,b){return function(c){return FormBuilder.DOMUpdates(a,c,b)}}(a,b)),l.observe(f[c].node[k],FormBuilder.observe.attributes),a.observers.push(l))}d=
a.hasOwnProperty("node")?a.node:a.node_type;FormBuilder.debug("<"+d+">",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)};

View File

@ -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<this.xhr.length;a++)if(null!==this.xhr[a]){b=!1;break}b&&(this.xhr=[])}}.bind(this,e),!1);d="string"==typeof d&&/^POST|GET$/i.test(d)?d.toUpperCase():"POST";a="POST"==d&&"object"==typeof a&&a instanceof FormData?a:null;this.xhr[e].open(d,b,!0);this.xhr[e].send(a);return this},explodeURL:function(b){b=1<=arguments.length?b:document.URL;if(null!=this.pagelist&&/^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?$/i.test(b)){for(var c=RegExp.$2.split("/");""==
c[c.length-1];)c.pop();return-1<this.pagelist.indexOf(RegExp.$1)?{page:RegExp.$1,"var":c}:null}return null},loadDependencies:function(){"object"==typeof this.depCSS&&this.depCSS instanceof Element&&this.depCSS.parentNode==document.head&&document.head.removeChild(this.depCSS);"object"==typeof this.depJS&&this.depJS instanceof Element&&this.depJS.parentNode==document.head&&document.head.removeChild(this.depJS);ptrPageManagerClass=this;this.ajax(this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",
function(b){null!=b?(ptrPageManagerClass.depCSS=document.createElement("link"),ptrPageManagerClass.depCSS.rel="stylesheet",ptrPageManagerClass.depCSS.type="text/css",ptrPageManagerClass.depCSS.href=ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+ptrPageManagerClass.page+".css",document.head.appendChild(ptrPageManagerClass.depCSS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+
ptrPageManagerClass.page+".css)")});this.ajax(this.root+this.path+"/"+this.jsPath+"/"+this.page+".js",function(b){null!=b?(ptrPageManagerClass.depJS=document.createElement("script"),ptrPageManagerClass.depJS.type="text/javascript",ptrPageManagerClass.depJS.src=ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js",document.head.appendChild(ptrPageManagerClass.depJS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.root+ptrPageManagerClass.path+
"/"+ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js)")})},updateURL:function(){0<this.vars.length?window.history.pushState(this.page,this.page,this.root+"/"+this.page+"/"+this.vars.join("/")+"/"):window.history.pushState(this.page,this.page,this.root+"/"+this.page+"/")},setPage:function(b,c,d,a,e){var f="object"==typeof a&&a instanceof Array?a:null;if(null!=f)for(a=0;a<f.length&&(f="string"==typeof f[a]&&/^[a-z0-9_]+$/i.test(f[a])?f:null,null!=f);a++);this.pagelist=null!=f?f:this.pagelist;
this.page=this.pagelist[0];this.root="string"==typeof e?e:this.root;this.path="string"==typeof c?c:this.path;this.container="object"==typeof d&&d instanceof Element?d:this.container;if(null!=this.pagelist&&null!=this.container)if("string"==typeof b&&-1<this.pagelist.indexOf(b)){this.page=b;b=new FormData;for(a=0;a<this.vars.length;a++)b.append(this.vars[a],null);this.ajax(this.root+this.path+"/"+this.page+".php",function(a){this.container.innerHTML=a;this.loadDependencies()}.bind(this),"POST",b);
this.updateURL()}else if(c=this.explodeURL(),null!=c){b=new FormData;for(a=this.vars.length=0;a<c["var"].length;a++)this.vars[a]=c["var"][a],b.append(this.vars[a],null);if(c.page==this.page)return this;this.page=c.page;this.ajax(this.root+this.path+"/"+this.page+".php",function(a){this.container.innerHTML=a;this.loadDependencies()}.bind(this),"POST",b);this.updateURL()}else this.setPage(this.pagelist[0]);else console.warn("pagelist et container manquant");return this},refresh:function(){this.setPage(this.page);
return this}};

View File

@ -1,9 +0,0 @@
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,d,f,a){var e;e=window.XMLHttpRequest?this.xhr.push(new XMLHttpRequest)-1:this.xhr.push(new ActiveXObject("Microsoft.XMLHttpRequest"))-1;this.activeXHR=this.xhr[e];var c=this;this.xhr[e].addEventListener("readystatechange",function(){if(void 0!=c.xhr[e]&&4==c.xhr[e].readyState){-1<[0,200].indexOf(c.xhr[e].status)?d(c.xhr[e].responseText):
d();c.xhr[e]=null;for(var a=!0,b=0;b<c.xhr.length;b++)if(null!==c.xhr[b]){a=!1;break}a&&(c.xhr=[])}},!1);f="string"==typeof f&&/^POST|GET$/i.test(f)?f.toUpperCase():"POST";a="POST"==f&&"object"==typeof a&&a instanceof FormData?a:null;this.xhr[e].open(f,b,!0);this.xhr[e].send(a);return this},explodeURL:function(b){b=1<=arguments.length?b:document.URL;if(null!=this.pagelist&&/^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?$/i.test(b)){for(var d=RegExp.$2.split("/");""==d[d.length-
1];)d.pop();return-1<this.pagelist.indexOf(RegExp.$1)?{page:RegExp.$1,"var":d}:null}return null},loadDependencies:function(){"object"==typeof this.depCSS&&this.depCSS instanceof Element&&this.depCSS.parentNode==document.head&&document.head.removeChild(this.depCSS);"object"==typeof this.depJS&&this.depJS instanceof Element&&this.depJS.parentNode==document.head&&document.head.removeChild(this.depJS);ptrPageManagerClass=this;this.ajax(this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",function(b){null!=
b?(ptrPageManagerClass.depCSS=document.createElement("link"),ptrPageManagerClass.depCSS.rel="stylesheet",ptrPageManagerClass.depCSS.type="text/css",ptrPageManagerClass.depCSS.href=ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+ptrPageManagerClass.page+".css",document.head.appendChild(ptrPageManagerClass.depCSS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+ptrPageManagerClass.page+
".css)")});this.ajax(this.root+this.path+"/"+this.jsPath+"/"+this.page+".js",function(b){null!=b?(ptrPageManagerClass.depJS=document.createElement("script"),ptrPageManagerClass.depJS.type="text/javascript",ptrPageManagerClass.depJS.src=ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js",document.head.appendChild(ptrPageManagerClass.depJS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.root+ptrPageManagerClass.path+"/"+
ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js)")})},updateURL:function(){0<this.vars.length?window.history.pushState(this.page,this.page,this.root+"/"+this.page+"/"+this.vars.join("/")+"/"):window.history.pushState(this.page,this.page,this.root+"/"+this.page+"/")},setPage:function(b,d,f,a,e){var c="object"==typeof a&&a instanceof Array?a:null;if(null!=c)for(a=0;a<c.length&&(c="string"==typeof c[a]&&/^[a-z0-9_]+$/i.test(c[a])?c:null,null!=c);a++);this.pagelist=null!=c?c:this.pagelist;
this.page=this.pagelist[0];this.root="string"==typeof e?e:this.root;this.path="string"==typeof d?d:this.path;this.container="object"==typeof f&&f instanceof Element?f:this.container;if(null!=this.pagelist&&null!=this.container)if("string"==typeof b&&-1<this.pagelist.indexOf(b)){this.page=b;var g=this;b=new FormData;for(a=0;a<this.vars.length;a++)b.append(this.vars[a],null);this.ajax(this.root+this.path+"/"+this.page+".php",function(a){g.container.innerHTML=a;g.loadDependencies()},"POST",b);this.updateURL()}else if(d=
this.explodeURL(),null!=d){this.page=d.page;var h=this;b=new FormData;for(a=this.vars.length=0;a<d["var"].length;a++)this.vars[a]=d["var"][a],b.append(this.vars[a],null);this.ajax(this.root+this.path+"/"+this.page+".php",function(a){h.container.innerHTML=a;h.loadDependencies()},"POST",b);this.updateURL()}else this.setPage(this.pagelist[0]);else console.warn("pagelist et container manquant");return this},refresh:function(){this.setPage(this.page);return this}};

View File

@ -43,46 +43,44 @@ pageManagerClass.prototype = {
var index; var index;
if(window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari // IE7+, Firefox, Chrome, Opera, Safari
index = this.xhr.push( new XMLHttpRequest() ) -1; // IE5, IE6
else // IE5, IE6 index = this.xhr.push( window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHttpRequest') ) -1;
index = this.xhr.push( new ActiveXObject('Microsoft.XMLHttpRequest') ) -1;
// On definit un pointeur sur l'instance XHR active (ajax) // On definit un pointeur sur l'instance XHR active (ajax)
this.activeXHR = this.xhr[index]; this.activeXHR = this.xhr[index];
var self = this; this.xhr[index].addEventListener('readystatechange', function(i){
this.xhr[index].addEventListener('readystatechange', function(){
// si la requete n'a pas ete supprimee // si la requete a ete supprimee, on quitte
if( self.xhr[index] == undefined ) if( this.xhr[i] == undefined )
return; return;
// Si la requête est terminée // Si la requête est terminée
if( self.xhr[index].readyState == 4 ){ // si la requête est terminée if( this.xhr[i].readyState === 4 ){ // si la requête est terminée
if( [0,200].indexOf(self.xhr[index].status) > -1 ) // si fichier existe et reçu if( [0,200].indexOf(this.xhr[i].status) > -1 ) // si fichier existe et reçu
pHandler(self.xhr[index].responseText); pHandler(this.xhr[i].responseText);
else // si code d'erreur retourne null else // si code d'erreur retourne null
pHandler(); pHandler();
// On supprime la requête // 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 // S'il n'y a plus de requête active, on supprime tout
var empty = true; var empty = true;
for( var i = 0 ; i < self.xhr.length ; i++ ) for( var i = 0 ; i < this.xhr.length ; i++ )
if( self.xhr[i] !== null ){ if( this.xhr[i] !== null ){
empty = false; empty = false;
break; break;
} }
// Si tout est vide, on efface // Si tout est vide, on efface
empty && ( self.xhr = [] ); empty && ( this.xhr = [] );
} }
}, false); }.bind(this, index), false);
// gestion de la méthode // gestion de la méthode
var method = ( typeof pMethod == 'string' && /^POST|GET$/i.test(pMethod) ) ? pMethod.toUpperCase() : 'POST'; 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é */ /* on attribue le paramètre pContainer à l'attribut si il est spécifié */
this.container = ( typeof pContainer == 'object' && pContainer instanceof Element ) ? pContainer : this.container; 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 ){ if( this.pagelist != null && this.container != null ){
// si le pName est renseigné et qu'il est dans pagelist // si le pName est renseigné et qu'il est dans pagelist
if( typeof pName == 'string' && this.pagelist.indexOf(pName) > -1 ){ if( typeof pName == 'string' && this.pagelist.indexOf(pName) > -1 ){
// affecte pName à l'attribut page // affecte pName à l'attribut page
this.page = pName; this.page = pName;
// charge le contenu de la page dans le container
var ptrPageManagerClass = this;
// formulaire POST // formulaire POST
var fd = new FormData(); var fd = new FormData();
for( var i = 0 ; i < this.vars.length ; i++ ) for( var i = 0 ; i < this.vars.length ; i++ )
fd.append(this.vars[i], null); fd.append(this.vars[i], null);
this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){ this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){
ptrPageManagerClass.container.innerHTML = e; this.container.innerHTML = e;
ptrPageManagerClass.loadDependencies(); this.loadDependencies();
}, 'POST', fd); }.bind(this), 'POST', fd);
// change l'URL en conséquences(stateObj, titre, url) // change l'URL en conséquences(stateObj, titre, url)
this.updateURL(); this.updateURL();
}else{ // si la page n'est pas spécifiée ou qu'elle n'est pas dans la liste des pages }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(); 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 // 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 ){ if( urlGet != null ){
this.page = urlGet.page;
// charge le contenu de la page dans le container
var ptrThis = this;
// formulaire POST // formulaire POST
var fd = new FormData(); var fd = new FormData();
@ -272,10 +264,18 @@ pageManagerClass.prototype = {
fd.append(this.vars[i], null); 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){ this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){
ptrThis.container.innerHTML = e; this.container.innerHTML = e;
ptrThis.loadDependencies(); this.loadDependencies();
}, 'POST', fd); }.bind(this), 'POST', fd);
// change l'URL en conséquences(stateObj, titre, url) // change l'URL en conséquences(stateObj, titre, url)
this.updateURL(); this.updateURL();

8
js/min/action-script.js Normal file
View File

@ -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<c.length;a++)c[a].remClass("active");if(null!=b)for(b.addClass("active"),c=$$('#CONTAINER > section[data-sublink="'+b.getData("sublink")+'"]'),a=0;a<c.length;a++)c[a].addClass("active");if(!b.getData("sublink"))return!1;a=pageManager.vars[0]!=b.getData("sublink");pageManager.vars[0]=b.getData("sublink");a&&pageManager.updateURL()},navMenu=function(a){var c=$('#WRAPPER > #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<a.menu.length;c++)pagelist.push(a.menu[c].attributes["data-link"]);pageManager=new pageManagerClass;pageManager.setPage(null,"/view",DOM.CONTAINER,pagelist,null);navMenu(pageManager.page)}});

View File

@ -24,20 +24,20 @@
<!-- Dépendences Javascript --> <!-- Dépendences Javascript -->
<script type='text/javascript' src='/js/lib/crc32-min.js' ></script> <!-- Système de hash unique et rapide --> <script type='text/javascript' src='/js/lib/min/crc32.js' ></script> <!-- Système de hash unique et rapide -->
<script type='text/javascript' src='/js/lib/local-storage-interface-min.js' ></script> <!-- Interface de gestion du 'localStorage' --> <script type='text/javascript' src='/js/lib/min/local-storage-interface.js' ></script> <!-- Interface de gestion du 'localStorage' -->
<script type='text/javascript' src='/js/lib/html-builder-min.js' ></script> <!-- Gestion de construction de HTML --> <script type='text/javascript' src='/js/lib/min/html-builder.js' ></script> <!-- Gestion de construction de HTML -->
<script type='text/javascript' src='/js/lib/input-checker-min.js' ></script> <!-- Gestion dynamique des saisies --> <script type='text/javascript' src='/js/lib/min/input-checker.js' ></script> <!-- Gestion dynamique des saisies -->
<script type='text/javascript' src='/js/lib/form-deflater-min.js' ></script> <!-- Gestion des formulaires js-friendly --> <script type='text/javascript' src='/js/lib/min/form-deflater.js' ></script> <!-- Gestion des formulaires js-friendly -->
<script type='text/javascript' src='/js/lib/reset-min.js' ></script> <!-- Corrections Javascript natif (ajouts) --> <script type='text/javascript' src='/js/lib/min/reset.js' ></script> <!-- Corrections Javascript natif (ajouts) -->
<script type='text/javascript' src='/js/lib/api-min.js' ></script> <!-- Gestion des transactions avec le serveur --> <script type='text/javascript' src='/js/lib/min/api.js' ></script> <!-- Gestion des transactions avec le serveur -->
<script type='text/javascript' src='/js/lib/page-manager-min.js' ></script> <!-- Gestion réseau/chargement/liens/URL --> <script type='text/javascript' src='/js/lib/min/page-manager.js' ></script> <!-- Gestion réseau/chargement/liens/URL -->
<script type='text/javascript' src='/js/lib/notif-min.js' ></script> <!-- Gestion des notifications --> <script type='text/javascript' src='/js/lib/min/notif.js' ></script> <!-- Gestion des notifications -->
<script type='text/javascript' src='/js/lib/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier --> <script type='text/javascript' src='/js/lib/min/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier -->
<!-- Dépendences Spéficiques pré-chargeables --> <!-- Dépendences Spéficiques pré-chargeables -->
<script type='text/javascript' src='/js/includes/input-html-phone-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'phone' --> <script type='text/javascript' src='/js/includes/min/input-html-phone-data.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'phone' -->
<script type='text/javascript' src='/js/includes/input-html-facebook-data-min.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'facebook' --> <script type='text/javascript' src='/js/includes/min/input-html-facebook-data.js' ></script> <!-- Gestion du constructeur HTML pour la page d'acquisition 'facebook' -->
<!-- Librairies Externes Javascript --> <!-- Librairies Externes Javascript -->
@ -117,7 +117,7 @@
<!-- Dépendences Javascript après chargement des éléments --> <!-- Dépendences Javascript après chargement des éléments -->
<script type='text/javascript' src='/js/action-script-min.js'></script> <script type='text/javascript' src='/js/min/action-script.js'></script>
</body> </body>
</html> </html>

View File

@ -90,16 +90,18 @@ sField.addEventListener('keypress', function(e){
/*=========================================================*/ /*=========================================================*/
/*========== Gestion du formulaire téléphonique ===========*/ /*========== Gestion du formulaire téléphonique ===========*/
/*=========================================================*/ /*=========================================================*/
var phoneRoutineExecuted = false; var pAlready = false;
var pLoaded = [ false, false, false, false, false ];
var phoneRoutine = function(){ var phoneRoutine = function(){
if( phoneRoutineExecuted ) if( !(pLoaded[0] && pLoaded[1] && pLoaded[2] && pLoaded[3] && pLoaded[4] && !pAlready) )
return; return;
phoneRoutineExecuted = true; pAlready = true;
// console.log( phoneRoutineExecuted, typeof inputPhoneSubject ); // console.log( phoneRoutineExecuted, typeof inputPhoneSubject );
// console.log( phoneRoutineExecuted, typeof inputPhoneContact ); // console.log( phoneRoutineExecuted, typeof inputPhoneContact );
@ -343,16 +345,11 @@ var phoneRoutine = function(){
}; };
include('/js/includes/input-phone-subject.js', function(){ pLoaded[0] = true; phoneRoutine(); });
include('/js/includes/input-phone-subject.js', function(){ include('/js/includes/input-phone-contact.js', function(){ pLoaded[1] = true; phoneRoutine(); });
include('/js/includes/input-phone-contact.js', function(){ include('/js/includes/input-phone-mini.js', function(){ pLoaded[2] = true; phoneRoutine(); });
include('/js/includes/input-phone-mini.js', function(){ include('/js/includes/input-phone-fiche.js', function(){ pLoaded[3] = true; phoneRoutine(); });
include('/js/includes/input-phone-fiche.js', function(){ include('/js/includes/input-phone-matrice.js', function(){ pLoaded[4] = true; phoneRoutine(); });
include('/js/includes/input-phone-matrice.js', phoneRoutine);
});
});
});
});

View File

@ -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("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+ 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("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+
a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML= a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML=
c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1); 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')), $('[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")}, 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)); !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(); 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 <i>sujet</i>"),!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 <i>fiche rapide</i> <b>"+b+"</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", pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!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 <i>fiche rapide</i> <b>"+b+"</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 <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> 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 <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.", "La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> 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 <strong>"+a.subject_id+"</strong> ! 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); 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); 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(); 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();