Restore autoloader

This commit is contained in:
xdrm-brackets 2016-10-19 08:03:36 +02:00
parent 45240bfd17
commit 42d19e7a87
14 changed files with 61 additions and 65 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
/* [0] On definit la racine __BUILD__ si c'est pas deja fait /* [1] On definit les chemins absolus si c'est pas deja fait
=========================================================*/ =========================================================*/
if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) ); if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) );
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' ); if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
@ -8,34 +8,6 @@
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' ); if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
/* [1] On définit __SERVER_HOST__ et __SERVER_ROOT__ si c'est pas déja fait
=========================================================*/
if( !defined('__SERVER_HOST__') || !defined('__SERVER_ROOT') ){
/* (1) On charge le fichier de configuration */
$json = json_decode( file_get_contents(__CONFIG__.'/server.json'), true );
// Si pas d'erreur, on définit
if( !is_null($json) ){
/* (2) Gestion de la config si server local ou remote */
if( !isset($_SERVER['SERVER_NAME']) || !checkdnsrr($_SERVER['SERVER_NAME'], 'NS') )
$config = $json['local'];
else
$config = $json['remote'];
/* (3) Création des constantes */
define('__SERVER_HOST__', $config['host']);
define('__SERVER_ROOT__', $config['root']);
}
}
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION) /* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
* *
*/ */
@ -47,7 +19,6 @@
/* AUTOLOADER /* AUTOLOADER
* *
* @className<String> Nom de la classe appelee * @className<String> Nom de la classe appelee
@ -72,8 +43,6 @@
spl_autoload_register('autoloader', false, true); spl_autoload_register('autoloader', false, true);
/* On demarre la session securisee PHP /* On demarre la session securisee PHP
=========================================================*/ =========================================================*/
\manager\sessionManager::session_start(); \manager\sessionManager::session_start();
@ -88,4 +57,5 @@
/* (2) Retourne si l'utilisateur a le status en question */ /* (2) Retourne si l'utilisateur a le status en question */
function permission($type){ return connected() && in_array($type, $_SESSION['permission']); } function permission($type){ return connected() && in_array($type, $_SESSION['permission']); }
?> ?>

View File

@ -6,7 +6,7 @@
class lightdb{ class lightdb{
// REPERTOIRE RACINE DE TOUTES LES BDD // REPERTOIRE RACINE DE TOUTES LES BDD
public static $default_root = __BUILD__.'/lightdb/storage'; public static function default_root(){ return __BUILD__.'/lightdb/storage'; }
// ATTRIBUTS // ATTRIBUTS
private $root; private $root;
@ -26,7 +26,7 @@
public function __construct($dbname, $root=null){ public function __construct($dbname, $root=null){
/* [0] On récupère les attributs /* [0] On récupère les attributs
=========================================================*/ =========================================================*/
$this->root = is_null($root) ? self::$default_root.'/' : $root; $this->root = is_null($root) ? self::default_root().'/' : $root;
$this->dbname = $dbname; $this->dbname = $dbname;
$this->dir = $this->root.$dbname.'/'; $this->dir = $this->root.$dbname.'/';

View File

@ -4,6 +4,7 @@
class MenuManager{ class MenuManager{
// Constantes // Constantes

View File

@ -148,7 +148,9 @@ var navMenu = function(section){
}; };
var refresher = function(){
navSubMenu();
};
@ -220,7 +222,7 @@ DOM.MENUSIDE.addEventListener('click', function(e){
/* [6] Gestion du rechargement de page /* [6] Gestion du rechargement de page
=========================================================*/ =========================================================*/
function reload(){ navMenu( pageManager.page ); } function reload(){ pageManager.refresh(); }
/* [7] Gestion du toggle de la page de login /* [7] Gestion du toggle de la page de login
=========================================================*/ =========================================================*/
@ -257,6 +259,7 @@ api.send({path:'download/menu'}, function(response){
/* (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 );
pageManager.refresh(refresher);
/* (2) On charge la premiere page */ /* (2) On charge la premiere page */
navMenu(pageManager.page); navMenu(pageManager.page);

View File

@ -462,7 +462,6 @@ inputPhoneFiche.prototype.sync = function(){
copied.reltype = miniData[key].reltype; copied.reltype = miniData[key].reltype;
copied.reltypeSpecial = miniData[key].reltypeSpecial; copied.reltypeSpecial = miniData[key].reltypeSpecial;
// copied.timestamp = Date.now(); // copied.timestamp = Date.now();
console.warn(copied);
lsi.set('p_fiches', copied.uid, copied); lsi.set('p_fiches', copied.uid, copied);
} }

View File

@ -14,8 +14,8 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(c=0;c<b.length;c++)-1
inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.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();console.groupEnd()}; inputPhoneFiche.prototype.storageToFields=function(){console.group("[phone.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();console.groupEnd()};
inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,e,d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,k;for(k 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(k);lsi.set("p_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("p_fiches"),c=lsi["export"]("p_mini-fiches"), inputPhoneFiche.prototype.sync=function(){console.group("[phone.fiche] synchronisation");var a=lsi["export"]("p_contacts"),c=[],b,e,d=lsi.keys("p_contacts").length<2*this.top_size?lsi.keys("p_contacts").length:2*this.top_size,k;for(k 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(k);lsi.set("p_fiches",ficheUid,a);if(c.length>=d)break}var a=lsi["export"]("p_fiches"),c=lsi["export"]("p_mini-fiches"),
g;for(g in c){var h=lsi.get("p_contacts",c[g].contact);if(h){d=[];for(e in a)b=lsi.get("p_contacts",a[e].contact),e!=g&&b&&(k=0<b.username.length&&h.username===b.username,b=!isNaN(b.existing)&&h.existing===b.existing,(k||b)&&d.push(a[e]));if(0!==d.length){k=c[g].hasOwnProperty("timestamp")?c[g].timestamp:0;var h=[],f=!0;for(e in d)h[e]=d[e].hasOwnProperty("timestamp")?d[e].timestamp:0,f=f&&k>h[e];b=h.indexOf(Math.max.apply(Math,h));if(f)for(e in d)console.warn("copying mini#"+c[g].uid+" to fiche#"+ g;for(g in c){var h=lsi.get("p_contacts",c[g].contact);if(h){d=[];for(e in a)b=lsi.get("p_contacts",a[e].contact),e!=g&&b&&(k=0<b.username.length&&h.username===b.username,b=!isNaN(b.existing)&&h.existing===b.existing,(k||b)&&d.push(a[e]));if(0!==d.length){k=c[g].hasOwnProperty("timestamp")?c[g].timestamp:0;var h=[],f=!0;for(e in d)h[e]=d[e].hasOwnProperty("timestamp")?d[e].timestamp:0,f=f&&k>h[e];b=h.indexOf(Math.max.apply(Math,h));if(f)for(e in d)console.warn("copying mini#"+c[g].uid+" to fiche#"+
d[e].uid,k-global_start_timestamp,h[e]-global_start_timestamp),f=d[e],f.age=c[g].age,f.sexe=c[g].sexe,f.loc=c[g].loc,f.reltype=c[g].reltype,f.reltypeSpecial=c[g].reltypeSpecial,console.warn(f),lsi.set("p_fiches",f.uid,f);else if(-1<b)for(e in console.warn("copying fiche#"+d[b].uid+" to mini#"+c[g].uid,h[b]-global_start_timestamp,k-global_start_timestamp),f=c[g],f.age=d[b].age,f.sexe=d[b].sexe,f.loc=d[b].loc,f.reltype=d[b].reltype,f.reltypeSpecial=d[b].reltypeSpecial,lsi.set("p_mini-fiches",f.uid, d[e].uid,k-global_start_timestamp,h[e]-global_start_timestamp),f=d[e],f.age=c[g].age,f.sexe=c[g].sexe,f.loc=c[g].loc,f.reltype=c[g].reltype,f.reltypeSpecial=c[g].reltypeSpecial,lsi.set("p_fiches",f.uid,f);else if(-1<b)for(e in console.warn("copying fiche#"+d[b].uid+" to mini#"+c[g].uid,h[b]-global_start_timestamp,k-global_start_timestamp),f=c[g],f.age=d[b].age,f.sexe=d[b].sexe,f.loc=d[b].loc,f.reltype=d[b].reltype,f.reltypeSpecial=d[b].reltypeSpecial,lsi.set("p_mini-fiches",f.uid,f),d)e!=b&&(console.warn("copying fiche#"+
f),d)e!=b&&(console.warn("copying fiche#"+d[b].uid+" to fiche#"+d[e].uid,h[b]-global_start_timestamp,h[e]-global_start_timestamp),f=d[b],f.uid=d[e].uid,lsi.set("p_fiches",f.uid,f))}}}console.groupEnd()};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"))}; d[b].uid+" to fiche#"+d[e].uid,h[b]-global_start_timestamp,h[e]-global_start_timestamp),f=d[b],f.uid=d[e].uid,lsi.set("p_fiches",f.uid,f))}}}console.groupEnd()};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 e=parseInt(c[b]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>e&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%20+1)+"</span>&nbsp;&nbsp;":(20==e&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-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 e=parseInt(c[b]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");20>e&&b<c.length-1&&20<=c[b+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%20+1)+"</span>&nbsp;&nbsp;":(20==e&&(this.nav_container.innerHTML+='<br><span class="fc">&nbsp;&nbsp; SMS &nbsp;&nbsp;</span>'),this.nav_container.innerHTML+='<span data-n="'+
e+'">'+(e%20+1)+"</span>")}for(var d in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=c&&(!0===a[d].valid?c.addClass("done"):c.remClass("done"));this.nav($('[data-sublink="phone"] #p_nav-fiche [data-n="'+this.selected+'"]'))}; e+'">'+(e%20+1)+"</span>")}for(var d in a)c=$('[data-sublink="phone"] #p_nav-fiche [data-n="'+a[d].uid+'"]'),null!=c&&(!0===a[d].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|| 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||

View File

@ -59,15 +59,15 @@ APIClass.prototype = {
this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest'); this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest');
var ptrAPI = this; var ptrAPI = this;
console.log('api request', pRequest);
this.xhr[i].onreadystatechange = function(){ this.xhr[i].onreadystatechange = function(){
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
ptrAPI.buffer = ptrAPI.xhr[i].responseText; ptrAPI.buffer = ptrAPI.xhr[i].responseText;
/* DEBUG : affiche la réponse BRUTE de http://host/api/ */ /* DEBUG : affiche la réponse BRUTE de http://host/api/ */
// console.log('http://host/api/ => '+ptrAPI.xhr[i].responseText); // console.log('http://host/api/ => '+ptrAPI.xhr[i].responseText);
// console.log( JSON.parse(ptrAPI.xhr[i].responseText) ); console.log('api response', JSON.parse(ptrAPI.xhr[i].responseText) );
console.log('api request', pRequest);
/* si success de requête */ /* si success de requête */
if( [0,200].indexOf(ptrAPI.xhr[i].status) > -1 ){ // si fichier existe et reçu if( [0,200].indexOf(ptrAPI.xhr[i].status) > -1 ){ // si fichier existe et reçu

View File

@ -1,4 +1,4 @@
function APIClass(c){this.target=c} function APIClass(b){this.target=b}
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(b,f,g){b.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;console.log("api request",
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); b);this.xhr[a].onreadystatechange=function(){if(4==e.xhr[a].readyState)if(e.buffer=e.xhr[a].responseText,console.log("api response",JSON.parse(e.xhr[a].responseText)),-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,c;for(c in b)"path"==c?d.append(c,b[c]):b[c]instanceof File?d.append(c,b[c]):d.append(c,
g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}}; JSON.stringify(b[c]));this.xhr[a].open("POST",this.target,!0);g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}};

View File

@ -1,9 +1,9 @@
function pageManagerClass(){}var ptrPageManagerClass; function pageManagerClass(){}var ptrPageManagerClass;
pageManagerClass.prototype={loaded:null,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): pageManagerClass.prototype={loaded:null,depJS:null,depCSS:null,xhr:[],activeXHR:null,page:null,vars:[],root:"",path:"",jsPath:"js",cssPath:"css",pagelist:null,container:null,refresher:function(){},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]=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(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=
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);this.ajax(this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",function(b){null!=b?(this.depCSS= 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);this.ajax(this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",
document.createElement("link"),this.depCSS.rel="stylesheet",this.depCSS.type="text/css",this.depCSS.href=this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",document.head.appendChild(this.depCSS)):console.warn("[loadDependencies_Error] - ("+this.root+this.path+"/"+this.cssPath+"/"+this.page+".css)")}.bind(this));this.ajax(this.root+this.path+"/"+this.jsPath+"/"+this.page+".js",function(b){null!=b?(this.depJS=document.createElement("script"),this.depJS.type="text/javascript",this.depJS.src=this.root+ function(b){null!=b?(this.depCSS=document.createElement("link"),this.depCSS.rel="stylesheet",this.depCSS.type="text/css",this.depCSS.href=this.root+this.path+"/"+this.cssPath+"/"+this.page+".css",document.head.appendChild(this.depCSS)):console.warn("[loadDependencies_Error] - ("+this.root+this.path+"/"+this.cssPath+"/"+this.page+".css)")}.bind(this));this.ajax(this.root+this.path+"/"+this.jsPath+"/"+this.page+".js",function(b){null!=b?(this.depJS=document.createElement("script"),this.depJS.type="text/javascript",
this.path+"/"+this.jsPath+"/"+this.page+".js",document.head.appendChild(this.depJS)):console.warn("[loadDependencies_Error] - ("+this.root+this.path+"/"+this.jsPath+"/"+this.page+".js)")}.bind(this))},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!= this.depJS.src=this.root+this.path+"/"+this.jsPath+"/"+this.page+".js",document.head.appendChild(this.depJS)):console.warn("[loadDependencies_Error] - ("+this.root+this.path+"/"+this.jsPath+"/"+this.page+".js)")}.bind(this))},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
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.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+ 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.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(this.pagelist&&this.container)if(!0===b)this.ajax(this.root+this.path+"/"+this.page+".php",function(a){this.container.innerHTML=a;this.loadDependencies();this.refresher.apply(this)}.bind(this),
"/"+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]); "POST",g);else if("string"==typeof b&&-1<this.pagelist.indexOf(b)){this.page=b;var g=new FormData;for(a=0;a<this.vars.length;a++)g.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",g);this.updateURL()}else if(b=this.explodeURL(),null!=b){g=new FormData;for(a=this.vars.length=0;a<b["var"].length;a++)this.vars[a]=b["var"][a],g.append(this.vars[a],null);if(b.page==this.page)return this;this.page=
else console.warn("pagelist et container manquant");return this},refresh:function(){this.setPage(this.page);return this}}; b.page;this.ajax(this.root+this.path+"/"+this.page+".php",function(a){this.container.innerHTML=a;this.loadDependencies()}.bind(this),"POST",g);this.updateURL()}else this.setPage(this.pagelist[0]);else console.warn("pagelist et container manquant");return this},refresh:function(b){if(b instanceof Function)this.refresher=b;else return this.setPage(!0)}};

View File

@ -28,6 +28,7 @@ pageManagerClass.prototype = {
cssPath: 'css', // le chemin du dossier contenant les feuilles de style (.css) cssPath: 'css', // le chemin du dossier contenant les feuilles de style (.css)
pagelist: null, // la liste des pages pouvant être chargées pagelist: null, // la liste des pages pouvant être chargées
container: null, // élément DOM qui contiendra le contenu des pages à charger container: null, // élément DOM qui contiendra le contenu des pages à charger
refresher: function(){}, // function appelée après refresh
/* ======================================================================= /* =======================================================================
Cette fonction effectue une requête Ajax (compatible à partir de IE5) Cette fonction effectue une requête Ajax (compatible à partir de IE5)
PARAMETRES: PARAMETRES:
@ -230,10 +231,21 @@ pageManagerClass.prototype = {
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 && this.container ){
// Si on veut just `refresh` la page
if( pName === true ){
this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){
this.container.innerHTML = e;
this.loadDependencies();
this.refresher.apply(this);
}.bind(this), 'POST', fd);
return this;
// 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 ){ }else 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;
@ -296,10 +308,18 @@ pageManagerClass.prototype = {
* @action Recharge la page en cours en conservant les variables * @action Recharge la page en cours en conservant les variables
* *
*/ */
refresh: function(){ refresh: function(refresher){
this.setPage(this.page); if( refresher instanceof Function ){
this.refresher = refresher;
return;
}else{
return this.setPage(true);
}
return this;
} }
}; };

View File

@ -2,8 +2,8 @@ var DOM,pageManager,api,Notification,global_start_timestamp;global_start_timesta
var 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= var 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=(b="string"==typeof a?$('#WRAPPER > #MENU-SIDE > span[data-link="'+ 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)||$('#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!= 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!=
document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1);DOM.HEADER.remClass("loading")},pageManager.page!=b.getData("link")&&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/");Notification=new NotificationClass($("#notification-container")); document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1);DOM.HEADER.remClass("loading")},pageManager.page!=b.getData("link")&&pageManager.setPage(b.getData("link")),pageManager.activeXHR?pageManager.activeXHR.addEventListener("loadend",a,!1):a.call())},refresher=function(){navSubMenu()};DOM={WRAPPER:$("body > #WRAPPER"),HEADER:$("body > #WRAPPER > #HEADER"),MENUSIDE:$("body > #WRAPPER > #MENU-SIDE"),CONTAINER:$("body > #WRAPPER > #CONTAINER")};api=new APIClass("/api/");
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",17:"Le t\u00e9l\u00e9chargement a \u00e9chou\u00e9", 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",
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(){pageManager.refresh()}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){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);pageManager.refresh(refresher);navMenu(pageManager.page)}});

View File

@ -1,6 +1,5 @@
<?php use \manager\MenuManager; ?> <?php use \manager\MenuManager; ?>
<!DOCTYPE html>
<html> <html>
<head> <head>
<title>SOCIOVIEW - Tableau de bord</title> <title>SOCIOVIEW - Tableau de bord</title>

View File

@ -0,0 +1,5 @@
var TOKEN={add:{toggle:document.getElementById("add-token"),panel:$("[data-sublink='tokens'] div[data-add]"),state:!0,submit:$("[data-sublink='tokens'] div[data-add] #add-token-submit")},remove:{buttons:$$(".remove-token")}},tokenDeflater=new FormDeflater(TOKEN.add.panel,["input"],["id"]);TOKEN.add.toggle.addEventListener("click",function(a){TOKEN.add.state?TOKEN.add.panel.addClass("active"):TOKEN.add.panel.remClass("active");TOKEN.add.state=!TOKEN.add.state},!1);
TOKEN.add.submit.addEventListener("click",function(a){a=tokenDeflater.deflate();api.send({path:"token/generate",name:a["add-name"],duration:a["add-duration"]},function(a){0==a.ModuleError&&reload()})},!1);for(var i=0;i<TOKEN.remove.buttons.length;i++)TOKEN.remove.buttons[i].addEventListener("click",function(a){a=a.target.parentNode.getData("id");0==a?console.warn("id du token non trouvee"):api.send({path:"token/remove",token_id:a},function(a){0==a.ModuleError&&reload()})},!1);
var USERS={add:{toggle:document.getElementById("add-user"),panel:$("[data-sublink='users'] div[data-add]"),state:!0,submit:$("[data-sublink='users'] div[data-add] #add-user-submit")},remove:{buttons:$$(".remove-user")}},userDefalter=new FormDeflater(USERS.add.panel,["input"],["id"]);USERS.add.toggle.addEventListener("click",function(a){USERS.add.state?USERS.add.panel.addClass("active"):USERS.add.panel.remClass("active");USERS.add.state=!USERS.add.state},!1);
USERS.add.submit.addEventListener("click",function(a){a=userDefalter.deflate();a["add-password"]==a["add-password2"]&&api.send({path:"user/create",login:a["add-login"],password:a["add-password"],mail:a["add-mail"],reference:a["add-reference"],permission:a["add-admin"]},function(a){console.log(a);0==a.ModuleError&&reload()})},!1);
for(i=0;i<USERS.remove.buttons.length;i++)USERS.remove.buttons[i].addEventListener("click",function(a){a=a.target.parentNode.getData("id");0==a?console.warn("id de l'utilisateur non trouvee"):api.send({path:"user/remove",id_user:a},function(a){0==a.ModuleError&&reload()})},!1);

View File

@ -70,7 +70,6 @@ for( var i = 0 ; i < TOKEN.remove.buttons.length ; i++ ){
// On lance la requete // On lance la requete
api.send(request, function(answer){ api.send(request, function(answer){
console.log(answer);
// Si la suppression effectuee, on recharge la page // Si la suppression effectuee, on recharge la page
if( answer.ModuleError == 0 ) if( answer.ModuleError == 0 )
reload(); reload();