This commit is contained in:
SeekDaSky 2017-12-06 16:40:41 +01:00
commit 3ba539e9de
23 changed files with 624 additions and 160 deletions

View File

@ -43,9 +43,9 @@ Toujours dans le dossier parent (celui qui contient `ndli1718-web`)
### 3-1. Configuration Apache
> Si vous n'avez pas apache
> ```bash
```bash
> sudo apt-get install apache2 libapache2-mod-php mysql-server php-mysql php;
> ```
```
##### 1. Créer l'hôte virtuel

View File

@ -0,0 +1,54 @@
<?php
namespace \kwebsocket\core;
class wsinterop{
private $socket;
private $host;
private $port;
private $isOpened;
public function __construct(String $host, int $port){
$this->socket = socket_create(AF_INET, SOCK_STREAM, 0);
$this->isOpened = socket_connect($this->socket,$host,$port);
$this->host = $host;
$this->port = $port;
socket_set_block($this->socket);
}
public function send(array $data) : bool{
if( !$this->isOpened ) return false;
$toSend = json_encode($data);
$size = strlen($toSend);
socket_write($this->socket,pack('N',$size));
$success = socket_write($this->socket,$toSend);
return $success == $size;
}
public function receive() : array{
$size = unpack("N",socket_read($this->socket,4))[1];
$read = 0;
$data = "";
$tmp = "";
while($read != $size){
$remaining = ($size - $read);
$read += socket_recv($this->socket,$tmp,$remaining,MSG_DONTWAIT);
$data .= $tmp;
}
return json_decode($data,true);
}
}

View File

@ -23,6 +23,61 @@
"output": {
"connected": { "description": "Vrai si connecté.", "type": "boolean" }
}
},
"POST signup": {
"description": "Formulaire d'inscription",
"permissions": [],
"parameters": {
"username": { "description": "Identifiant de l'utilisateur", "type": "varchar(3,20,alphanumeric)" },
"mail": { "description": "Adresse mail de l'utilisateur", "type": "text" },
"password": { "description": "Mot de passe de l'utilisateur", "type": "text" }
},
"output": {
"sent": { "description": "Etat de l'inscription, VRAI si le mail de confirmation a été envoyé", "type": "boolean" }
}
},
"GET signup_token": {
"description": "Validation de l'inscription par lien envoyé par mail",
"permissions": [],
"parameters": {
"URL_0": { "description": "Token de confirmation URL", "type": "hash" }
},
"output": {
"confirmed": { "description": "Etat de la validité du token", "type": "boolean" }
}
},
"POST pass": {
"description": "Demande de nouveau mot de passe",
"permissions": ["user"],
"parameters": {},
"output": {
"sent": { "description": "Etat de la demande de nouveau mot de passe, VRAI si le mail de confirmation a été envoyé", "type": "boolean" }
}
},
"POST pass_token": {
"description": "Changement de mot de passe",
"permissions": [],
"parameters": {
"URL_0": { "description": "Token de confirmation URL", "type": "hash" }
},
"output": {
"confirmed": { "description": "Etat de la validité du token", "type": "boolean" }
}
},
"POST pass_update": {
"description": "Changement de mot de passe",
"permissions": [],
"parameters": {
"password": { "description": "Nouveau mot de passe", "type": "text" }
},
"output": {
"updated": { "description": "Vrai si mot de passe mis à jour", "type": "boolean" }
}
}
},

View File

@ -30,6 +30,7 @@
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.5.9",
"vue-router": "^2.5.3",
"webpack": "^3.8.1",
"webpack-dev-server": "^2.9.5"
}

View File

@ -1,22 +1,24 @@
/* Card container */
#CONTAINER.message{
height: calc( 100% - 6.3em );
flex-direction: column;
justify-content: flex-start;
flex-wrap: nowrap;
}
#CONTAINER.message div{ /* Message item */
#CONTAINER.message div,
#CONTAINER.message div[data-noauthor='1']{ /* Message item */
display: inline-block;
position: relative;
top: 0;
left: 0;
height: auto;
margin: 1em;
margin: 0 1.5em;
margin-top: 2.5em;
padding: 1em;
flex: 1 1 1;
align-self: flex-start;
border-radius: 3px;
@ -26,33 +28,119 @@
color: #222;
}
#CONTAINER.message div[data-noauthor='0']{
margin-top: .5em;
}
#CONTAINER.message div.me{ /* Message Item (self) */
background: #13d89d;
/* background: #13d89d; */
align-self: flex-end;
margin: .5em 1.5em;
}
#CONTAINER.message div.end-pad{
padding: 0;
opacity: 0;
}
#CONTAINER.message div span.author{ /* Message author */
display: inline-block;
position: relative;
padding: .2em .4em;
margin-right: 1em;
border: 1px solid #ddd;
border-radius: 3px;
display: block;
position: absolute;
top: -1.8em;
left: .5em;
background: #eee;
color: #666;
}
#CONTAINER.message div span.author:after{ /* Add 'dit' */
content: ' dit';
color: #333;
color: #888;
}
#CONTAINER.message div.me span.author{ /* Hide message author if self */
display: none;
}
#CONTAINER.message div span span.code{ /* Code block */
display: inline-block;
position: relative;
padding: .2em .3em;
border-radius: 3px;
background: #f0f0f0;
font-family: 'Liberation Mono';
font-size: .9em;
}
#CONTAINER.message div span span.utf8{ /* Smileys */
font-family: 'Liberation Mono';
font-size: 1.3em;
color: #ea921f;
}
#CONTAINER.message div span span.utf8.bl{ color: #338be0; }
#CONTAINER.message div span span.utf8.br{ color: #773c22; }
#CONTAINER.message form.msg-input{ /* Message Input */
display: block;
position: fixed;
top: calc( 100% - 3em );
left: 15em;
width: calc( 100% - 15em - 2*1px );
height: 3em;
border-top: 1px solid #ddd;
background: #fff;
overflow: hidden;
transition: left .2s ease-in-out,
width .2s ease-in-out;
}
#WRAPPER.min #CONTAINER.message form.msg-input{
left: 3.5em;
width: calc( 100% - 3.5em - 2*1px );
}
#CONTAINER.message form.msg-input input{ /* form Input */
display: inline-block;
position: absolute;
top: 0;
left: 0;
width: calc( 100% - 2em - 3em );
height: calc( 100% - 2*.5em );
padding: .5em 1em;
border: none;
font-size: inherit;
font-family: inherit;
}
#CONTAINER.message form.msg-input button{ /* form send button */
display: inline-block;
position: absolute;
top: 0;
left: calc( 100% - 3em );
width: 3em;
height: 3em;
background: url('/image/container/send-msg.svg@777777') center center no-repeat;
background-size: 50%;
border: none;
font-size: inherit;
cursor: pointer;
}
#CONTAINER.message form.msg-input button:hover{
background-image: url('/image/container/send-msg.svg@000000');
}

View File

@ -44,3 +44,16 @@
font-weight: lighter;
font-style: italic;
}
/* LIBERATION MONO */
/* regular */
@font-face {
font-family: 'Liberation Mono';
src: url('/font/LiberationMono_Rg.ttf');
font-weight: normal;
font-style: normal;
}

View File

@ -140,7 +140,7 @@
padding: .1em .35em;
border-radius: 50% / 50%;
background: #ed4222;
background: #474dff;
font-size: .8em;

Binary file not shown.

View File

@ -0,0 +1,46 @@
Digitized data copyright (c) 2010 Google Corporation
with Reserved Font Arimo, Tinos and Cousine.
Copyright (c) 2012 Red Hat, Inc.
with Reserved Font Name Liberation.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the copyright statement(s).
"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
viewBox="0 0 20.015684 19.959942"
xml:space="preserve"
id="svg4190"
inkscape:version="0.91 r13725"
sodipodi:docname="send-msg.svg"
width="20.015684"
height="19.959942"><metadata
id="metadata4199"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs4197" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1056"
id="namedview4195"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:zoom="39.666667"
inkscape:cx="9.9906835"
inkscape:cy="9.9541575"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:window-maximized="1"
inkscape:current-layer="svg4190" /><path
inkscape:connector-curvature="0"
id="fill-edit"
d="M 19.490683,9.1057851 1.5906835,0.10578512 c -0.90000002,-0.4 -1.90000002,0.4 -1.50000002,1.29999998 l 2.50000002,6.7 11.3999995,1.8999999 -11.3999995,1.9 -2.50000002,6.7 c -0.3,0.9 0.6,1.7 1.50000002,1.2 l 17.8999995,-9 c 0.7,-0.3 0.7,-1.2999999 0,-1.6999999 z" /></svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -5,15 +5,46 @@
use \api\core\Request;
use \api\core\AuthSystemDefault;
use \database\core\DatabaseDriver;
use \kwebsocket\core\wsinterop;
/* (1) Start session */
session_start();
if( count($_SESSION['USER']) > 0 )
$_SESSION['NAME'] = $_SESSION['USER']['username'];
elseif( count($_SESSION['ADMIN']) > 0 )
$_SESSION['NAME'] = $_SESSION['ADMIN']['username'];
elseif( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 )
$_SESSION['NAME'] = 'guest'.uniqid();
if( !isset($_SESSION['NAME']) || strlen($_SESSION['NAME']) == 0 ){
// ask with websocketInterop
$wsi = new wsinterop('localhost', 9998);
if( count($_SESSION['USER']) > 0 ){
// get/send name to web socket
$wsi->send(['type' => 'user', 'name' => $_SESSION['USER']['username']]);
$check = $wsi->receive();
if( $check['error'] == false )
$_SESSION['NAME'] = $check['name'];
}elseif( count($_SESSION['ADMIN']) > 0 ){
// get/send name to web socket
$wsi->send(['type' => 'admin', 'name' => $_SESSION['ADMIN']['username']]);
$check = $wsi->receive();
if( $check['error'] == false )
$_SESSION['NAME'] = $check['name'];
}else{
// get/send name to web socket
$wsi->send(['type' => 'guest', 'name' => null]);
$check = $wsi->receive();
if( $check['error'] == false )
$_SESSION['NAME'] = $check['name'];
}
$wsi = null;
}
/* (2) Set default Driver for Repos */
Repo::setDriver(DatabaseDriver::get());

View File

@ -16,8 +16,6 @@ export class InfoBox{
show(msg, type, timeout=2000){
console.log(this.stack, this.pending);
/* (1) If pending -> add to stack */
if( this.pending )

View File

@ -2,11 +2,13 @@
---------------------------------------------------------*/
/* (1) NPM libs */
import Vue from 'vue'
import VueRouter from 'vue-router'
/* (2) Internal libs */
import {API} from './lib/api-es6'
import {InfoBox} from './lib/infobox-es6'
import {WSClient,WSClientBuilder} from './lib/ws-client-es6'
import routes from './routes'
/* (3) Vues */
import wrapper_vue from './vue/wrapper.vue'
@ -23,66 +25,110 @@ 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) Render view */
/* (4) Init vue router */
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
routes: routes[0]
});
/* (5) Render view */
new Vue({
el: '#main-vue',
render: h => h(wrapper_vue),
data: {
gstore: window.gstore.data
}
})
router,
render: h => h(wrapper_vue)
});
/* (6) Navigate at page load (to update notifications count) */
gstore.data.func.nav(router, null);
/* (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} If no data -> exit //
if( msg.connected == null && msg.disconnected == null )
return;
// {4} Add connected users to stack //
if( msg.connected instanceof Array ){
// -1- add connected users
console.log('Detected '+msg.connected.length+' connected user(s)');
var lastLen = gstore.data.notif[0].data.length;
gstore.data.notif[0].data = gstore.data.notif[0].data.concat( msg.connected );
// -2- make each user unique
gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item, i, arr){ return arr.indexOf(item) === i; });
// -3- Update count if not already on page
if( router.app.$route.path != 'notifications' )
gstore.data.notif[0].count += gstore.data.notif[0].data.length - lastLen;
// {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;
}
}).send({name: window._SERVER.session.name});
// {5} Add disconnected users to stack //
if( msg.disconnected instanceof Array ){
// -1- Remove each disconnected user
console.log('Detected '+msg.disconnected.length+' disconnected user(s)');
var lastLen = gstore.data.notif[0].data.length;
gstore.data.notif[0].data = gstore.data.notif[0].data.filter(function(item){ return msg.disconnected.indexOf(item) === -1; });
// -2- Update count if not already on page
if( router.app.$route.path != 'notifications' )
gstore.data.notif[0].count += lastLen - gstore.data.notif[0].data.length;
}
}).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
}
// {3} If no message -> exit //
if( msg.msg == null )
return;
}).send({name: window._SERVER.session.name});
// {4} Play sound if 1msg received + not already on page //
if( msg.msg.length == 1 && router.app.$route.path != 'inbox' )
( new Audio('/sound/notification.mp3') ).play();
// {5} Add messages to stack //
gstore.data.notif[1].data = gstore.data.notif[1].data.concat( msg.msg );
// {6} Add notification count if not already on page //
if( router.app.$route.path != 'inbox' )
gstore.data.notif[1].count += msg.msg.length
}).send({name: _SERVER.session.name});
/* (4) Clean sockets before page quit
---------------------------------------------------------*/
window.onbeforeunload = function() {
window.wsc_chat.ws.close();
window.wsc_connect.ws.close();
wsc_chat.send('{"close": true}');
wsc_connect.send('{"close": true}');
};

19
view/routes.js Normal file
View File

@ -0,0 +1,19 @@
export default { 0: [
{
path: '/dashboard/',
component: require('./vue/container/dashboard.vue').default
}, {
path: '/profile/',
component: require('./vue/container/profile.vue').default
}, {
path: '/inbox/',
component: require('./vue/container/inbox.vue').default
}, {
path: '/notifications/',
component: require('./vue/container/notifications.vue').default
}, {
path: '*',
redirect: '/dashboard/'
}
]}

View File

@ -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,28 +33,60 @@ 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', {
toggleMenuSize: function(){ window.gstore.data.min_menu=!window.gstore.data.min_menu; },
sendMessage: function(msg){
/* (1) Send message to WebSocket */
window.wsc_chat.send(JSON.stringify({message: msg}));
gstore.add('func', {
nav: function(router, uri){
/* (2) Add locally */
window.gstore.data.notif[1].data.push([ window.gstore.data.server.session.name, msg ]);
// {1} Update view (vue-router) //
if( typeof uri == 'string' )
router.push('/'+uri);
// {2} if no @uri -> Extract route from @router //
else if( /^\/([^\/]+).*$/.test( router.app.$route.path ) )
uri = RegExp.$1;
// {3} If no @uri -> exit //
else
return;
// {4} Activate current menu_item //
gstore.data.menu_item_active = uri;
// {5} Manage notifications //
for( var notif of gstore.data.notif )
if( notif.link == uri ) // if notif links to current page
notif.count = 0;
},
toggleMenuSize: function(){ gstore.data.min_menu=!gstore.data.min_menu; },
sendMessage: function(msg){
/* (1) If empty message -> abort */
if( msg.trim().length == 0 )
return;
/* (2) Send message to WebSocket */
wsc_chat.send(JSON.stringify({message: msg}));
/* (3) Add locally */
gstore.data.notif[1].data.push([ gstore.data.server.session.name, msg ]);
}
});
// new-message container
gstore.add('new_msg', '');

View File

@ -12,6 +12,6 @@
<script>
export default {
name: 'CONTAINER_DASHBOARD',
data(){ return { gstore: window.gstore.data }; },
data(){ return { gstore: gstore.data }; }
}
</script>

View File

@ -0,0 +1,85 @@
<template>
<div id='CONTAINER' class='message'>
<div v-for='(msg, id) in gstore.notif[1].data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif[1].data[id-1][0] != gstore.notif[1].data[id][0] ? "1" : "0"'>
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif[1].data[id-1][0] != msg[0]'></span>
<span class='content' v-html='bbcode(msg[1])'></span>
</div>
<div class='end-pad'></div> <!-- End Spacing -->
<form class='msg-input' @submit.prevent='new_message'>
<input type='text' placeholder='Nouveau message..' id='msg-new-content' v-model='gstore.new_msg'>
<button></button>
</form>
</div>
</template>
<script>
export default {
name: 'CONTAINER_INBOX',
data(){ return { gstore: gstore.data }; },
methods: {
new_message(msg){
// {1} Send message //
this.gstore.func.sendMessage(this.gstore.new_msg);
// {2} Empty input //
this.gstore.new_msg = '';
},
bbcode: function(msg){
/* (1) Escape HTML
---------------------------------------------------------*/
msg = msg.replace(/&/g, '&amp;');
msg = msg.replace(/</g, '&lt;');
msg = msg.replace(/>/g, '&gt;');
/* (2) Manage text format
---------------------------------------------------------*/
/* (1) Manage bold */
msg = msg.replace(/\*([^\*]+)\*/g, "<b>$1</b>");
/* (2) italic */
msg = msg.replace(/_([^_]+)_/g, "<i>$1</i>");
/* (3) underline */
msg = msg.replace(/\[([^\]]+)\]/g, "<ins>$1</ins>");
/* (4) Code */
msg = msg.replace(/`([^`]+)`/g, "<span class='code'>$1</span>");
/* (3) Manage emojis
---------------------------------------------------------*/
/* (1) Smileys */
msg = msg.replace(/:D/g, "<span class='utf8'>😃</span>");
msg = msg.replace(/:\)/g, "<span class='utf8'>🙂</span>");
msg = msg.replace(/:B/g, "<span class='utf8'>😎</span>");
msg = msg.replace(/:3/g, "<span class='utf8'>😗</span>");
msg = msg.replace(/;\)/g, "<span class='utf8'>😉</span>");
msg = msg.replace(/:P/g, "<span class='utf8'>😋</span>");
msg = msg.replace(/;P/g, "<span class='utf8'>😜</span>");
msg = msg.replace(/xD/g, "<span class='utf8'>😆</span>");
msg = msg.replace(/:O/ig, "<span class='utf8'>😲</span>");
msg = msg.replace(/:S/g, "<span class='utf8'>😖</span>");
msg = msg.replace(/\^\^/g, "<span class='utf8'>😊</span>");
/* (2) Emojis */
msg = msg.replace(/:poop:/g, "<span class='utf8 br'>💩</span>");
msg = msg.replace(/:fuck:/g, "<span class='utf8'>🖕</span>");
msg = msg.replace(/\+1/g, "<span class='utf8 bl'>👍</span>");
msg = msg.replace(/-1/g, "<span class='utf8 bl'>👎</span>");
return msg;
}
}
}
</script>

View File

@ -1,20 +0,0 @@
<template>
<div id='CONTAINER' class='message'>
<div v-for='msg in gstore.notif[1].data' :class="msg[0] == gstore.server.session.name ? 'me' : ''">
<span class='author'>{{ msg[0] }}</span>
<span class='content'>{{ msg[1] }}</span>
</div>
</div>
</template>
<script>
export default {
name: 'CONTAINER_MSG',
data(){ return { gstore: window.gstore.data }; },
}
</script>

View File

@ -12,6 +12,6 @@
<script>
export default {
name: 'CONTAINER_NOTIFICATIONS',
data(){ return { gstore: window.gstore.data }; },
data(){ return { gstore: gstore.data }; }
}
</script>

View File

@ -12,6 +12,6 @@
<script>
export default {
name: 'CONTAINER_PROFILE',
data(){ return { gstore: window.gstore.data }; },
data(){ return { gstore: gstore.data }; }
}
</script>

View File

@ -12,7 +12,7 @@
<!-- Header Notif -->
<div id='header-notif'>
<div v-for='(notif, index) in gstore.notif' @click='show_notif(index, notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
<div v-for='notif in gstore.notif' @click='show_notif(notif.link)' :class='"hnotif " + notif.class' :data-count='notif.count'></div>
</div>
</div>
@ -23,17 +23,10 @@
<script>
export default {
name: 'HEADER',
data(){ return { gstore: window.gstore.data }; },
data(){ return { gstore: gstore.data }; },
methods: {
show_notif(index, link){
// {1} Load link //
window.gstore.data.menu_item_active = link;
// {2} Reset notification count to 0 //
window.gstore.data.notif[index].count = 0;
show_notif(uri){
this.gstore.func.nav(this.$router, uri);
}
}
}

View File

@ -4,7 +4,7 @@
<div v-for='(item, index) in gstore.menu_item' class='menu-item-wrapper'>
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate_menu(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
<div :class="(index == gstore.menu_item_active) ? 'menu-item active' : 'menu-item'" @click='navigate(index)' :style='"background-image: url(/image/menu/" + item.icon + ".svg@333333"'>
<span>{{ item.label }}</span>
</div>
@ -18,17 +18,10 @@
<script>
export default {
name: 'MENU',
data(){ return { gstore: window.gstore.data }; },
data(){ return { gstore: gstore.data }; },
methods: {
navigate_menu(page){
// (1) Update URL
console.log('Loading page \''+page+'\'');
window.history.pushState(page, page, '/'+page+'/');
// (2) Activate current element
this.gstore.menu_item_active = page;
navigate(uri){
this.gstore.func.nav(this.$router, uri);
}
}
}

View File

@ -8,41 +8,24 @@
<menu-comp></menu-comp>
<!-- Container -->
<dashboard-container v-show="gstore.menu_item_active == 'dashboard'" ></dashboard-container>
<profile-container v-show="gstore.menu_item_active == 'profile'" ></profile-container>
<message-container v-show="gstore.menu_item_active == 'inbox'" ></message-container>
<notifications-container v-show="gstore.menu_item_active == 'notifications'" ></notifications-container>
<router-view></router-view>
</div>
</template>
<script>
import header_vue from './header.vue';
import menu_vue from './menu.vue';
import dashboardContainer_vue from './container/dashboard.vue';
import profileContainer_vue from './container/profile.vue';
import messageContainer_vue from './container/message.vue';
import notificationsContainer_vue from './container/notifications.vue';
import header_vue from './header.vue'
import menu_vue from './menu.vue'
export default {
name: 'wrapper',
data(){ return {
gstore: window.gstore.data
}; },
data(){ return { gstore: gstore.data }; },
components: {
'HeaderComp': header_vue,
'MenuComp': menu_vue,
'DashboardContainer': dashboardContainer_vue,
'ProfileContainer': profileContainer_vue,
'MessageContainer': messageContainer_vue,
'NotificationsContainer': notificationsContainer_vue
'MenuComp': menu_vue
}
}
</script>