Correction 'pseudo-complète' du chargement de 'page-manager.js'

This commit is contained in:
xdrm-brackets 2016-10-11 12:44:53 +02:00
parent edf94ab9ac
commit d5d1bead3f
10 changed files with 317 additions and 67 deletions

View File

@ -85,7 +85,7 @@ var navMenu = function(section){
target = (typeof section == 'string') ? $('#WRAPPER > #MENU-SIDE > span[data-link="'+section+'"]') : target; target = (typeof section == 'string') ? $('#WRAPPER > #MENU-SIDE > span[data-link="'+section+'"]') : target;
// Si rien trouve, on prend le premier element correspondant a la premiere page // Si rien trouve, on prend le premier element correspondant a la premiere page
target = (target == null) ? $('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]') : target; target = target || $('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]');
// Si le param n'est toujours pas bon, on retourne une erreur // Si le param n'est toujours pas bon, on retourne une erreur
if( target == null ) return false; if( target == null ) return false;
@ -93,11 +93,9 @@ var navMenu = function(section){
/* [2] Gestion de l'affichage de l'element /* [2] Gestion de l'affichage de l'element
------------------------------------------------*/ ------------------------------------------------*/
// On desactive l'element courant // On desactive l'element courant
if( current != null ) current && current.remClass('active');
current.remClass('active');
// On active le nouveau // On active le nouveau
if( target != null ) target && target.addClass('active');
target.addClass('active');
/* [3] Gestion de pageManager /* [3] Gestion de pageManager
------------------------------------------------*/ ------------------------------------------------*/
@ -109,7 +107,7 @@ var navMenu = function(section){
DOM.HEADER.addClass('loading'); // Animation de chargement DOM.HEADER.addClass('loading'); // Animation de chargement
var handlerX = function(){ var handlerX = function(){
console.log(pageManager.vars[0], $$('#CONTAINER > section[data-sublink]'));
// 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;
@ -134,13 +132,14 @@ var navMenu = function(section){
// On retire l'icone de chargement // On retire l'icone de chargement
DOM.HEADER.remClass('loading'); DOM.HEADER.remClass('loading');
}; };
/* (x) Si on change de page, on charge la nouvelle charge */ /* (x) Si on change de page, on charge la nouvelle charge */
if( target.getData('link') != pageManager.page ) ( DOM.CONTAINER.innerHTML.length === 0 || target.getData('link') != pageManager.page ) && pageManager.setPage( target.getData('link') );
pageManager.setPage( target.getData('link') );
pageManager.activeXHR.addEventListener('loadend', handlerX, false); // Si on a `pageManager.activeXHR`, on met le handler, sinon on lance
pageManager.activeXHR ? pageManager.activeXHR.addEventListener('loadend', handlerX, false) : handlerX.call();
} }
@ -243,8 +242,10 @@ LOGIN.hide.addEventListener('click', function(e){ LOGIN.page.className = '';
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 ){
console.warn('menu load error: '+response.ModuleError);
return; return;
}
// On initialise la liste des pages // On initialise la liste des pages
pagelist = []; pagelist = [];
@ -253,6 +254,7 @@ api.send({path:'download/menu'}, function(response){
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'] );
console.log('menu loaded', pagelist);
/* (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 );

View File

@ -96,16 +96,12 @@ APIClass.prototype = {
this.xhr[i].open('POST', this.target, true); this.xhr[i].open('POST', this.target, true);
// Gestion du token optionnel // Gestion du token optionnel
if( pToken != null ) this.xhr[i].setRequestHeader('Authorization', 'Digest '+pToken); pToken && this.xhr[i].setRequestHeader('Authorization', 'Digest '+pToken);
// Header pour dire que c'est AJAX // Header pour dire que c'est AJAX
this.xhr[i].setRequestHeader('X-Requested-With', 'XMLHttpRequest'); this.xhr[i].setRequestHeader('X-Requested-With', 'XMLHttpRequest');
this.xhr[i].send( form ); this.xhr[i].send( form );
} }

View File

@ -9,7 +9,7 @@ var makeCRCTable = function(){
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());

View File

@ -1,4 +1,4 @@
function APIClass(c){this.target=c} function APIClass(c){this.target=c}
APIClass.prototype={xhr:[],buffer:null,optionalParams:[],send:function(c,f,g){c.hasOwnProperty("path")||f({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&this.xhr.splice(a,1);this.xhr.push(null);a=this.xhr.length-1;this.optionalParams[a]=[];if(3<arguments.length)for(var d=3;d<arguments.length;d++)this.optionalParams[a].push(arguments[d]);this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");var e=this;this.xhr[a].onreadystatechange= APIClass.prototype={xhr:[],buffer:null,optionalParams:[],send:function(c,f,g){c.hasOwnProperty("path")||f({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&this.xhr.splice(a,1);this.xhr.push(null);a=this.xhr.length-1;this.optionalParams[a]=[];if(3<arguments.length)for(var d=3;d<arguments.length;d++)this.optionalParams[a].push(arguments[d]);this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");var e=this;this.xhr[a].onreadystatechange=
function(){if(4==e.xhr[a].readyState)if(e.buffer=e.xhr[a].responseText,console.log("api request",c),-1<[0,200].indexOf(e.xhr[a].status))try{f(JSON.parse(e.xhr[a].responseText),e.optionalParams[a])}catch(b){f({ModuleError:-1,ErrorDescription:"Erreur au niveau de api.js"},e.optionalParams[a]),console.warn(b)}else f({ModuleError:3})};var d=new FormData,b;for(b in c)"path"==b?d.append(b,c[b]):c[b]instanceof File?d.append(b,c[b]):d.append(b,JSON.stringify(c[b]));this.xhr[a].open("POST",this.target,!0); function(){if(4==e.xhr[a].readyState)if(e.buffer=e.xhr[a].responseText,console.log("api request",c),-1<[0,200].indexOf(e.xhr[a].status))try{f(JSON.parse(e.xhr[a].responseText),e.optionalParams[a])}catch(b){f({ModuleError:-1,ErrorDescription:"Erreur au niveau de api.js"},e.optionalParams[a]),console.warn(b)}else f({ModuleError:3})};var d=new FormData,b;for(b in c)"path"==b?d.append(b,c[b]):c[b]instanceof File?d.append(b,c[b]):d.append(b,JSON.stringify(c[b]));this.xhr[a].open("POST",this.target,!0);
null!=g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}}; g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}};

1
js/lib/min/crc32.js Normal file
View File

@ -0,0 +1 @@
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,8 +1,9 @@
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"); 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="'+ 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=(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="'+ a+'"]'):b)||$('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]');if(null==b)return!1;c&&c.remClass("active");b&&b.addClass("active");b.getData("link")&&(DOM.HEADER.addClass("loading"),a=function(){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!=
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")}; document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1);DOM.HEADER.remClass("loading")},0!==DOM.CONTAINER.innerHTML.length&&b.getData("link")==pageManager.page||pageManager.setPage(b.getData("link")),pageManager.activeXHR?pageManager.activeXHR.addEventListener("loadend",a,!1):a.call())};DOM={WRAPPER:$("body > #WRAPPER"),HEADER:$("body > #WRAPPER > #HEADER"),MENUSIDE:$("body > #WRAPPER > #MENU-SIDE"),CONTAINER:$("body > #WRAPPER > #CONTAINER")};api=new APIClass("/api/");
api=new APIClass("/api/");Notification=new NotificationClass($("#notification-container"));Notification.defaultTimeout=4E3; 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", 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")}; 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)}}); 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)console.warn("menu load error: "+a.ModuleError);else{pagelist=[];for(var c=0;c<a.menu.length;c++)pagelist.push(a.menu[c].attributes["data-link"]);console.log("menu loaded",pagelist);pageManager=new pageManagerClass;pageManager.setPage(null,"/view",DOM.CONTAINER,pagelist,null);navMenu(pageManager.page)}});

View File

@ -283,7 +283,6 @@
return new ModuleRequest(); return new ModuleRequest();
/* [2] On verifie que @data est renseigne /* [2] On verifie que @data est renseigne
=========================================================*/ =========================================================*/
// Si variable n'existe pas, on cree un tableau vide // Si variable n'existe pas, on cree un tableau vide

View File

@ -1,6 +1,5 @@
<?php use \manager\MenuManager; ?> <?php use \manager\MenuManager; ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
@ -30,7 +29,7 @@
<script type='text/javascript' src='/js/lib/min/input-checker.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/min/form-deflater.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/min/reset.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/min/api.js' ></script> <!-- Gestion des transactions avec le serveur --> <script type='text/javascript' src='/js/lib/api.js' ></script> <!-- Gestion des transactions avec le serveur -->
<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/min/page-manager.js' ></script> <!-- Gestion réseau/chargement/liens/URL -->
<script type='text/javascript' src='/js/lib/min/notif.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/min/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier --> <script type='text/javascript' src='/js/lib/min/shortcut-manager.js' ></script> <!-- Gestion des raccourcis clavier -->
@ -117,7 +116,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/min/action-script.js'></script> <script type='text/javascript' src='/js/action-script.js'></script>
</body> </body>
</html> </html>

View File

@ -103,13 +103,6 @@ var phoneRoutine = function(){
pAlready = true; pAlready = true;
// console.log( phoneRoutineExecuted, typeof inputPhoneSubject );
// console.log( phoneRoutineExecuted, typeof inputPhoneContact );
// console.log( phoneRoutineExecuted, typeof inputPhoneMini );
// console.log( phoneRoutineExecuted, typeof inputPhoneFiche );
// console.log( phoneRoutineExecuted, typeof inputPhoneMatrice );
// console.log( phoneRoutineExecuted, typeof inputPhoneMatrice );
console.group('[phone] Initialization'); console.group('[phone] Initialization');
/* (1) Gestion du formulaire du sujet /* (1) Gestion du formulaire du sujet
@ -213,7 +206,7 @@ var phoneRoutine = function(){
/* (2) On lance le téléchargement */ /* (2) On lance le téléchargement */
var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement var downloadTarget = $('[data-sublink="phone"] #p_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
downloadTarget.download = 'local-phone-data.json'; // Nom du fichier qui sera téléchargé downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé
downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
downloadTarget.click(); // On lance le téléchargement downloadTarget.click(); // On lance le téléchargement
@ -312,7 +305,7 @@ var phoneRoutine = function(){
/* (3) On prépare la requête avec toutes les données */ /* (3) On prépare la requête avec toutes les données */
var request = { var request = {
path: 'input/phone', path: 'input/facebook',
subject: lsi.export('p_subject')[0], subject: lsi.export('p_subject')[0],
contacts: lsi.export('p_contacts'), contacts: lsi.export('p_contacts'),
@ -358,20 +351,29 @@ include('/js/includes/input-phone-matrice.js', function(){ pLoaded[4] = true; ph
/*=========================================================*/ /*=========================================================*/
/*=========== Gestion du formulaire facebook ==============*/ /*=========== Gestion du formulaire facebook ==============*/
/*=========================================================*/ /*=========================================================*/
include('/js/includes/input-facebook-subject.js', function(){ var fAlready = false;
//TODO: Remettre version min var fLoaded = [ false, false, false, false, false ];
include('/js/includes/input-facebook-contact.js', function(){
//TODO: Remettre version min
include('/js/includes/input-facebook-mini.js', function(){
//TODO: Remettre version min
include('/js/includes/input-facebook-fiche.js', function(){
include('/js/includes/input-facebook-matrice.js', function(){
var facebookRoutine = function(){
if( !(fLoaded[0] && fLoaded[1] && fLoaded[2] && fLoaded[3] && fLoaded[4] && !fAlready) )
return;
fAlready = true;
// console.log( facebookRoutineExecuted, typeof inputFacebookSubject );
// console.log( facebookRoutineExecuted, typeof inputFacebookContact );
// console.log( facebookRoutineExecuted, typeof inputFacebookMini );
// console.log( facebookRoutineExecuted, typeof inputFacebookFiche );
// console.log( facebookRoutineExecuted, typeof inputFacebookMatrice );
// console.log( facebookRoutineExecuted, typeof inputFacebookMatrice );
console.group('[facebook] Initialization');
/* (1) Gestion du formulaire du sujet /* (1) Gestion du formulaire du sujet
---------------------------------------------------------*/ ---------------------------------------------------------*/
/* (1) On crée une instance du manager du sujet */ /* (1) On crée une instance du manager du sujet */
fSubjectManager = new inputFacebookSubject( fSubjectManager = new inputFacebookSubject(
$('[data-sublink="facebook"] article.subject-panel [data-name="tmp_id"]'),
$('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'), $('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),
$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]') $('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')
); );
@ -450,7 +452,6 @@ include('/js/includes/input-facebook-matrice.js', function(){
}, false); }, false);
/* (8) Gestion de l'export des données locales /* (8) Gestion de l'export des données locales
---------------------------------------------------------*/ ---------------------------------------------------------*/
$('[data-sublink="facebook"] #f_export-all').addEventListener('click', function(e){ $('[data-sublink="facebook"] #f_export-all').addEventListener('click', function(e){
@ -469,7 +470,7 @@ include('/js/includes/input-facebook-matrice.js', function(){
/* (2) On lance le téléchargement */ /* (2) On lance le téléchargement */
var downloadTarget = $('[data-sublink="facebook"] #f_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement var downloadTarget = $('[data-sublink="facebook"] #f_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé downloadTarget.download = 'local-phone-data.json'; // Nom du fichier qui sera téléchargé
downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
downloadTarget.click(); // On lance le téléchargement downloadTarget.click(); // On lance le téléchargement
@ -516,10 +517,10 @@ include('/js/includes/input-facebook-matrice.js', function(){
lsi.set('f_matrice', 0, response.local_data.matrice); lsi.set('f_matrice', 0, response.local_data.matrice);
/* (3) On met à jour l'affichage */ /* (3) On met à jour l'affichage */
fSubjectManager.storageToFields(); pSubjectManager.storageToFields();
fContactManager.storageToFields(); pContactManager.storageToFields();
fMatriceManager.storageToFields(); pMatriceManager.storageToFields();
fDynamicUpdate(true); pDynamicUpdate(true);
}); });
@ -532,14 +533,14 @@ include('/js/includes/input-facebook-matrice.js', function(){
console.log('> GATHERING ALL DATA'); console.log('> GATHERING ALL DATA');
/* (1) On met dans la mémoire tout les champs non enregistrés */ /* (1) On met dans la mémoire tout les champs non enregistrés */
fSubjectManager.fieldsToStorage(); pSubjectManager.fieldsToStorage();
fContactManager.fieldsToStorage(); pContactManager.fieldsToStorage();
fMiniManager.fieldsToStorage(); pMiniManager.fieldsToStorage();
fFicheManager.fieldsToStorage(); pFicheManager.fieldsToStorage();
/* (2) Vérification de la validité de toutes les données */ /* (2) Vérification de la validité de toutes les données */
// {1} Vérification du sujet // // {1} Vérification du sujet //
if( !fSubjectManager.check() ){ if( !pSubjectManager.check() ){
Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>'); Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>');
return false; return false;
} }
@ -568,7 +569,7 @@ include('/js/includes/input-facebook-matrice.js', function(){
/* (3) On prépare la requête avec toutes les données */ /* (3) On prépare la requête avec toutes les données */
var request = { var request = {
path: 'input/facebook', path: 'input/phone',
subject: lsi.export('f_subject')[0], subject: lsi.export('f_subject')[0],
contacts: lsi.export('f_contacts'), contacts: lsi.export('f_contacts'),
@ -587,6 +588,8 @@ include('/js/includes/input-facebook-matrice.js', function(){
return false; return false;
} }
Notification.success('OK', "L'identifiant du sujet est <strong>"+response.subject_id+"</strong> ! Tout s'est bien déroulé.", 10000);
console.log(response); console.log(response);
}, false); }, false);
@ -595,9 +598,257 @@ include('/js/includes/input-facebook-matrice.js', function(){
}, false); }, false);
}); }); }); }); }); console.groupEnd('[facebook] Initialization');
};
include('/js/includes/input-facebook-subject.js', function(){ fLoaded[0] = true; facebookRoutine(); });
include('/js/includes/input-facebook-contact.js', function(){ fLoaded[1] = true; facebookRoutine(); });
include('/js/includes/input-facebook-mini.js', function(){ fLoaded[2] = true; facebookRoutine(); });
include('/js/includes/input-facebook-fiche.js', function(){ fLoaded[3] = true; facebookRoutine(); });
include('/js/includes/input-facebook-matrice.js', function(){ fLoaded[4] = true; facebookRoutine(); });
//
// include('/js/includes/input-facebook-subject.js', function(){
// //TODO: Remettre version min
// include('/js/includes/input-facebook-contact.js', function(){
// //TODO: Remettre version min
// include('/js/includes/input-facebook-mini.js', function(){
// //TODO: Remettre version min
// include('/js/includes/input-facebook-fiche.js', function(){
// include('/js/includes/input-facebook-matrice.js', function(){
//
//
// /* (1) Gestion du formulaire du sujet
// ---------------------------------------------------------*/
// /* (1) On crée une instance du manager du sujet */
// fSubjectManager = new inputFacebookSubject(
// $('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),
// $('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')
// );
//
// /* (2) On le démarre */
// fSubjectManager.attach(fDynamicUpdate);
//
//
// /* (2) Gestion des formulaires de contact
// ---------------------------------------------------------*/
// /* (1) On crée une instance du gestionnaire des CONTACTS */
// fContactManager = new inputFacebookContact(
// $('[data-sublink="facebook"] article.contact-panel'),
// $('[data-sublink="facebook"] #f_nav-contact')
// );
//
// /* (2) On le démarre */
// fContactManager.attach(fDynamicUpdate);
//
//
// /* (3) Gestion des mini fiches relation
// ---------------------------------------------------------*/
// /* (1) On crée une instance du gestionnaire des mini fiches relation */
// fMiniManager = new inputFacebookMini(
// $('[data-sublink="facebook"] article.mini-relation-panel'),
// $('[data-sublink="facebook"] #f_nav-mini')
// );
//
// /* (2) On le démarre */
// fMiniManager.attach(fDynamicUpdate);
//
//
// /* (4) Gestion des fiches relation
// ---------------------------------------------------------*/
// /* (1) On crée une instance du gestionnaire des fiches relation */
// fFicheManager = new inputFacebookFiche(
// $('[data-sublink="facebook"] article.relation-panel'),
// $('[data-sublink="facebook"] #f_nav-fiche')
// );
//
// /* (2) On le démarre */
// fFicheManager.attach(fDynamicUpdate);
//
//
// /* (5) Gestion de la matrice de relations
// ---------------------------------------------------------*/
// /* (1) On crée une instance du gestionnaire de la matrice */
// fMatriceManager = new inputFacebookMatrice(
// $('[data-sublink="facebook"] article.matrice-panel')
// );
//
// /* (2) On le démarre */
// fMatriceManager.attach(fDynamicUpdate);
//
//
// /* (7) Gestion de l'effacement des données locales
// ---------------------------------------------------------*/
// $('[data-sublink="facebook"] #f_clear-all').addEventListener('click', function(e){
// /* (1) On vide tous les dataset de données */
// 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');
//
//
// /* (2) On met à jour l'affichage */
// fSubjectManager.storageToFields();
// fContactManager.storageToFields();
// fMiniManager.storageToFields();
// fFicheManager.storageToFields();
// fMatriceManager.storageToFields();
//
// Notification.success('OK', 'Les données ont été supprimées');
// }, false);
//
//
//
// /* (8) Gestion de l'export des données locales
// ---------------------------------------------------------*/
// $('[data-sublink="facebook"] #f_export-all').addEventListener('click', function(e){
//
// Notification.info('INFORMATION', 'Lancement du téléchargement de la sauvegarde');
//
// /* (1) On construit les données */
// var data = {
// subject: lsi.export('f_subject')[0],
// contacts: lsi.export('f_contacts'),
// mini: lsi.export('f_mini-fiches'),
// fiches: lsi.export('f_fiches'),
// matrice: lsi.export('f_matrice')[0]
// };
//
//
// /* (2) On lance le téléchargement */
// var downloadTarget = $('[data-sublink="facebook"] #f_download-target'); // On récupère le lien (<a>) caché qui fera le téléchargement
// downloadTarget.download = 'local-facebook-data.json'; // Nom du fichier qui sera téléchargé
// downloadTarget.href = 'data:application/octet-stream,' + encodeURIComponent(JSON.stringify(data)); // Contenu
// downloadTarget.click(); // On lance le téléchargement
//
// }, false);
//
//
// /* (9) Gestion de l'import des données locales
// ---------------------------------------------------------*/
// // Le bouton lance l'<input> file
// $('[data-sublink="facebook"] #f_import-all').addEventListener('click', function(e){
// $('[data-sublink="facebook"] #f_local-upload').click();
// }, false);
//
//
// // On vide l'input de type 'file' quand on clique
// $('[data-sublink="facebook"] #f_local-upload').addEventListener('click', function(e){
// e.target.value = null;
// }, false);
//
//
// // Gestion de l'upload d'une sauvegarde de formulaire local
// $('[data-sublink="facebook"] #f_local-upload').addEventListener('change', function(e){
// /* (1) Rédaction de la requête d'upload */
// var request = {
// path: 'upload/local_data',
// file: $('[data-sublink="facebook"] #f_local-upload').files[0]
// };
//
// /* (2) Upload et réponse */
// api.send(request, function(response){
// console.log(response);
//
// // Si erreur, on quitte
// if( response.ModuleError != 0 ){
// Notification.error('Erreur', response.ModuleError);
// return false;
// }
//
// /* (3) On enregistre les données dans le 'localStorage' */
// lsi.set('f_subject', 0, response.local_data.subject);
// lsi.import('f_contacts', response.local_data.contacts);
// lsi.import('f_mini-fiches', response.local_data.mini);
// lsi.import('f_fiches', response.local_data.fiches);
// lsi.set('f_matrice', 0, response.local_data.matrice);
//
// /* (3) On met à jour l'affichage */
// fSubjectManager.storageToFields();
// fContactManager.storageToFields();
// fMatriceManager.storageToFields();
// fDynamicUpdate(true);
//
// });
//
// }, false);
//
//
// /* (10) Gestion de la validation et de l'envoi des données
// ---------------------------------------------------------*/
// $('[data-sublink="facebook"] #f_submit-all').addEventListener('click', function(e){
// console.log('> GATHERING ALL DATA');
//
// /* (1) On met dans la mémoire tout les champs non enregistrés */
// fSubjectManager.fieldsToStorage();
// fContactManager.fieldsToStorage();
// fMiniManager.fieldsToStorage();
// fFicheManager.fieldsToStorage();
//
// /* (2) Vérification de la validité de toutes les données */
// // {1} Vérification du sujet //
// if( !fSubjectManager.check() ){
// Notification.warning('Attention', 'Vous devez saisir les informations du <i>sujet</i>');
// return false;
// }
// // {2} Vérification des mini-fiches //
// var mini = lsi.export('f_mini-fiches');
// var i = 0;
// for( var id in mini ){ if( !isNaN(id) ){
//
// i++
//
// if( !mini[id].valid ){
// Notification.warning('Attention', 'La <i>fiche rapide</i> <b>'+i+'</b> est incomplète et/ou incorrecte');
// return false;
// }
//
// }}
// // {3} Vérification des fiches //
// var fiches = lsi.export('f_fiches');
// for( var id in fiches )
// if( !fiches[id].valid ){
// Notification.warning('Attention', 'La <i>fiche complète</i> <b>'+(parseInt(id)+1)+'</b> est incomplète et/ou incorrecte');
// return false;
// }
//
//
//
// /* (3) On prépare la requête avec toutes les données */
// var request = {
// path: 'input/facebook',
//
// subject: lsi.export('f_subject')[0],
// contacts: lsi.export('f_contacts'),
// mini: lsi.export('f_mini-fiches'),
// fiches: lsi.export('f_fiches'),
// matrice: lsi.export('f_matrice')[0]
// };
//
// /* (4) On envoie la requête et traite la réponse */
// api.send(request, function(response){
// console.log(response);
//
// // Si erreur, on la notifie
// if( response.ModuleError != 0 ){
// Notification.error('ERREUR', response.ModuleError);
// return false;
// }
//
// console.log(response);
//
// }, false);
//
//
// }, false);
//
//
// }); }); }); }); });
//
//

View File

@ -5,21 +5,22 @@ c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sFie
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'), 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-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));
b.click()},!1),$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur", b.click()},!1),$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",
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/facebook",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(){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()}); 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); var fAlready=!1,fLoaded=[!1,!1,!1,!1,!1],facebookRoutine=function(){fLoaded[0]&&fLoaded[1]&&fLoaded[2]&&fLoaded[3]&&fLoaded[4]&&!fAlready&&(fAlready=!0,console.group("[facebook] Initialization"),fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="tmp_id"]'),$('[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();
Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download= Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1),$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var b=$('[data-sublink="facebook"] #f_download-target');b.download=
"local-facebook-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]}; "local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1),$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1),$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1),$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_local-upload').files[0]};
api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click", api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1),$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_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"), 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"]("f_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"]("f_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/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError), !1;a=lsi["export"]("f_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"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
!1;console.log(a)},!1)},!1)})})})})}); !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("[facebook] Initialization"))};include("/js/includes/input-facebook-subject.js",function(){fLoaded[0]=!0;facebookRoutine()});include("/js/includes/input-facebook-contact.js",function(){fLoaded[1]=!0;facebookRoutine()});include("/js/includes/input-facebook-mini.js",function(){fLoaded[2]=!0;facebookRoutine()});
include("/js/includes/input-facebook-fiche.js",function(){fLoaded[3]=!0;facebookRoutine()});include("/js/includes/input-facebook-matrice.js",function(){fLoaded[4]=!0;facebookRoutine()});
var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.group("[phone] Dynamic Update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends", var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.group("[phone] Dynamic Update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",
subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields());console.groupEnd("[phone] Dynamic Update")},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&& subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),(c||b)&&pContactManager.storageToFields());console.groupEnd("[phone] Dynamic Update")},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&&
"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.group("[facebook] Dynamic Update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value}, "INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.group("[facebook] Dynamic Update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},