diff --git a/view/main.js b/view/main.js
index df45fa3..c80abed 100755
--- a/view/main.js
+++ b/view/main.js
@@ -25,7 +25,7 @@ window.wsc = new WSClientBuilder("wss://websocket.xdrm.io");
/* (3) global store init */
require('./vue-config');
window.gstore.add('server', window._SERVER);
-window.infobox = new InfoBox(window.gstore.data.info);
+window.infobox = new InfoBox(gstore.data.info);
/* (4) Init vue router */
Vue.use(VueRouter);
@@ -46,51 +46,51 @@ new Vue({
/* (3) Set WebSocket channels
---------------------------------------------------------*/
/* (1) Connection channel */
-window.wsc_connect = window.wsc.channel('connect').listen(function(msg, err){
+window.wsc_connect = wsc.channel('connect').listen(function(msg, err){
// {1} Manage error //
if( msg == null && err != null )
- return window.infobox.show('Erreur de connexion WebSocket@connect ('+err+')', 'error', 3000);
+ return infobox.show('Erreur de connexion WebSocket@connect ('+err+')', 'error', 3000);
// {2} Manage wsclient error //
if( typeof msg.error != 'boolean' || msg.error !== false )
- return window.infobox.show('Erreur de connexion WebSocket@connect', 'warning', 3000);
+ return infobox.show('Erreur de connexion WebSocket@connect', 'warning', 3000);
// {3} Manage notification //
if( msg.connected != null ){
console.log('Detected '+msg.connected.length+' new user(s)');
- window.gstore.data.notif[0].data = window.gstore.data.notif[0].data.concat( msg.connected );
- window.gstore.data.notif[0].count += msg.connected.length;
+ gstore.data.notif[0].data = gstore.data.notif[0].data.concat( msg.connected );
+ gstore.data.notif[0].count += msg.connected.length;
}
-}).send({name: window._SERVER.session.name});
+}).send({name: _SERVER.session.name});
/* (2) Message channel */
-window.wsc_chat = window.wsc.channel('chat').listen(function(msg, err){
+window.wsc_chat = wsc.channel('chat').listen(function(msg, err){
// {1} Manage error //
if( msg == null && err != null )
- return window.infobox.show('Erreur de connexion WebSocket@chat ('+err+')', 'error', 3000);
+ return infobox.show('Erreur de connexion WebSocket@chat ('+err+')', 'error', 3000);
// {2} Manage wsclient error //
if( typeof msg.error != 'boolean' || msg.error !== false )
- return window.infobox.show('Erreur de connexion WebSocket@chat', 'warning', 3000);
+ return infobox.show('Erreur de connexion WebSocket@chat', 'warning', 3000);
// {3} Manage notification //
if( msg.msg != null ){
console.log('Received '+msg.msg.length+' new message(s)');
- window.gstore.data.notif[1].data = window.gstore.data.notif[1].data.concat( msg.msg );
- window.gstore.data.notif[1].count += msg.msg.length
+ gstore.data.notif[1].data = gstore.data.notif[1].data.concat( msg.msg );
+ gstore.data.notif[1].count += msg.msg.length
}
-}).send({name: window._SERVER.session.name});
+}).send({name: _SERVER.session.name});
/* (4) Clean sockets before page quit
---------------------------------------------------------*/
window.onbeforeunload = function() {
- window.wsc_chat.send('{"close": true}');
- window.wsc_connect.send('{"close": true}');
+ wsc_chat.send('{"close": true}');
+ wsc_connect.send('{"close": true}');
};
\ No newline at end of file
diff --git a/view/vue-config.js b/view/vue-config.js
index aeab430..8984fca 100644
--- a/view/vue-config.js
+++ b/view/vue-config.js
@@ -3,13 +3,13 @@ import {GlobalStore} from './lib/gstore-es6'
window.gstore = new GlobalStore();
// Header
-window.gstore.add('header_title', 'ndli1718');
-window.gstore.add('info', {
+gstore.add('header_title', 'ndli1718');
+gstore.add('info', {
active: false,
type: 'warning',
message: 'Warning! blabla'
});
-window.gstore.add('notif', [
+gstore.add('notif', [
{ class: 'bell', link: 'notifications', data: [], count: 0 },
{ class: 'message', link: 'inbox', data: [], count: 0 },
{ class: 'search', link: 'search', data: [], count: 0 },
@@ -17,7 +17,7 @@ window.gstore.add('notif', [
])
// Menu
-window.gstore.add('menu_item', {
+gstore.add('menu_item', {
dashboard: {
label: 'Dashboard',
icon: 'dashboard'
@@ -33,46 +33,46 @@ window.gstore.add('menu_item', {
}
});
-window.gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, ''));
-window.gstore.add('min_menu', false);
+gstore.add('URI', document.URL.replace(/^(?:\/\/|[^\/]+)*/, ''));
+gstore.add('min_menu', false);
// Proccess current page from url
-if( /^\/(\w+)(?:\/?.*)$/.test(window.gstore.data.URI) ){
- var mi_keys = Object.keys( window.gstore.data.menu_item );
+if( /^\/(\w+)(?:\/?.*)$/.test(gstore.data.URI) ){
+ var mi_keys = Object.keys( gstore.data.menu_item );
// if current page exists
- if( !!~mi_keys.indexOf(RegExp.$1) ) window.gstore.add('menu_item_active', RegExp.$1);
- else window.gstore.add('menu_item_active', 'dashboard');
+ if( !!~mi_keys.indexOf(RegExp.$1) ) gstore.add('menu_item_active', RegExp.$1);
+ else gstore.add('menu_item_active', 'dashboard');
}else
- window.gstore.add('menu_item_active', 'dashboard');
+ gstore.add('menu_item_active', 'dashboard');
// Functions
-window.gstore.add('func', {
+gstore.add('func', {
nav: function(router, uri){
// {1} Update view (vue-router) //
router.push('/'+uri);
// {2} Activate current menu_item //
- window.gstore.data.menu_item_active = uri;
+ gstore.data.menu_item_active = uri;
// {3} Manage notifications //
- for( var notif of window.gstore.data.notif )
+ for( var notif of gstore.data.notif )
if( notif.link == uri ) // if notif links to current page
notif.count = 0;
},
- toggleMenuSize: function(){ window.gstore.data.min_menu=!window.gstore.data.min_menu; },
+ toggleMenuSize: function(){ gstore.data.min_menu=!gstore.data.min_menu; },
sendMessage: function(msg){
/* (1) Send message to WebSocket */
- window.wsc_chat.send(JSON.stringify({message: msg}));
+ wsc_chat.send(JSON.stringify({message: msg}));
/* (2) Add locally */
- window.gstore.data.notif[1].data.push([ window.gstore.data.server.session.name, msg ]);
+ gstore.data.notif[1].data.push([ gstore.data.server.session.name, msg ]);
}
});
// new-message container
-window.gstore.add('new_msg', '');
\ No newline at end of file
+gstore.add('new_msg', '');
\ No newline at end of file
diff --git a/view/vue/container/dashboard.vue b/view/vue/container/dashboard.vue
index 38aaa1c..54108ce 100644
--- a/view/vue/container/dashboard.vue
+++ b/view/vue/container/dashboard.vue
@@ -12,6 +12,6 @@
\ No newline at end of file
diff --git a/view/vue/container/inbox.vue b/view/vue/container/inbox.vue
index e01864f..864975d 100644
--- a/view/vue/container/inbox.vue
+++ b/view/vue/container/inbox.vue
@@ -20,7 +20,7 @@
\ No newline at end of file
diff --git a/view/vue/container/profile.vue b/view/vue/container/profile.vue
index 998cef4..460dba0 100644
--- a/view/vue/container/profile.vue
+++ b/view/vue/container/profile.vue
@@ -12,6 +12,6 @@
\ No newline at end of file
diff --git a/view/vue/header.vue b/view/vue/header.vue
index b3ea3a9..ddf6399 100644
--- a/view/vue/header.vue
+++ b/view/vue/header.vue
@@ -23,10 +23,10 @@