ptut-vhost/webpack/data/common.js

49 lines
1.3 KiB
JavaScript

import {GlobalStore} from '../lib/gstore'
window.gstore = new GlobalStore();
/* (1) Global data
---------------------------------------------------------*/
/* (1) Get Full URI */
gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, '').split('/').filter(function(i){ return i.length; }));
/* (2) Get if local version or prod */
gstore.add('is_local', document.URL.replace(/^https?:\/\/([^\/:]+).*$/, '$1') == 'ptut.com');
/* (2) Main components
---------------------------------------------------------*/
/* (1) Header */
gstore.add('header_title', 'ndli1718');
/* (2) Menu */
gstore.add('menu_item', {
home: {
label: 'Accueil',
url: 'home',
icon: 'home'
}, manage: {
label: 'Administration',
url: 'manage',
icon: 'manage'
}, fiche: {
label: 'Fiches',
url: 'fiche',
icon: 'fiche'
}
});
/* (3) Gestion du login/logout */
if( _SERVER.connected ) gstore.get.menu_item.login = { label: 'Connexion', url: 'login', icon: 'login' };
else gstore.get.menu_item.logout = { label: 'Déconnexion', url: 'logout', icon: 'logout' };
/* (4) Set current page active in menu */
if( gstore.get.URI.length > 0 && gstore.get.menu_item.hasOwnProperty(gstore.get.URI[0]) )
gstore.add('menu_item_active', gstore.get.menu_item[gstore.get.URI[0]].url);
else
gstore.add('menu_item_active', 'home');