2017-12-04 22:29:02 +00:00
|
|
|
<template>
|
|
|
|
|
2017-12-07 18:12:32 +00:00
|
|
|
<div id='CONTAINER' class='message'>
|
2017-12-04 22:29:02 +00:00
|
|
|
|
2017-12-07 18:12:32 +00:00
|
|
|
<div v-for='(msg, id) in gstore.notif.event.data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.event.data[id-1][0] != gstore.notif.event.data[id][0] ? "1" : "0"'>
|
|
|
|
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif.event.data[id-1][0] != msg[0]'></span>
|
|
|
|
<span class='content' v-html='bbcode(msg[1])'></span>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class='end-pad'></div> <!-- End Spacing -->
|
|
|
|
|
2017-12-07 19:10:38 +00:00
|
|
|
<form class='msg-input' @submit.prevent='new_message(gstore.new_msg.event)'>
|
2017-12-07 18:12:32 +00:00
|
|
|
<input type='text' placeholder='Nouveau message..' id='msg-new-content' v-model='gstore.new_msg.event' :class='gstore.msg_pending.event ? "loading" : ""'>
|
|
|
|
<button></button>
|
|
|
|
</form>
|
2017-12-04 22:29:02 +00:00
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2017-12-07 18:12:32 +00:00
|
|
|
|
2017-12-04 22:29:02 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2017-12-07 17:17:32 +00:00
|
|
|
name: 'CONTAINER_EVENT',
|
2017-12-07 18:12:32 +00:00
|
|
|
data(){ return { gstore: gstore.data }; },
|
|
|
|
methods: {
|
|
|
|
new_message(msg){
|
|
|
|
|
2017-12-07 19:04:55 +00:00
|
|
|
/* (1) If empty message -> abort */
|
|
|
|
if( msg.trim().length == 0 )
|
|
|
|
return;
|
2017-12-07 18:12:32 +00:00
|
|
|
|
2017-12-07 19:04:55 +00:00
|
|
|
/* (2) Send message to WebSocket */
|
|
|
|
wsc_event.send(JSON.stringify({message: msg, location: [1.1, 2.2]}));
|
|
|
|
|
|
|
|
/* (3) Add loader */
|
|
|
|
gstore.data.msg_pending.event = true;
|
|
|
|
|
|
|
|
/* (4) Empty input */
|
2017-12-07 18:12:32 +00:00
|
|
|
this.gstore.new_msg.event = '';
|
2017-12-07 19:04:55 +00:00
|
|
|
|
2017-12-07 18:12:32 +00:00
|
|
|
},
|
|
|
|
bbcode: function(msg){
|
|
|
|
|
|
|
|
/* (1) Escape HTML
|
|
|
|
---------------------------------------------------------*/
|
|
|
|
msg = msg.replace(/&/g, '&');
|
|
|
|
msg = msg.replace(/</g, '<');
|
|
|
|
msg = msg.replace(/>/g, '>');
|
|
|
|
|
|
|
|
|
|
|
|
/* (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;
|
|
|
|
}
|
|
|
|
}
|
2017-12-04 22:29:02 +00:00
|
|
|
}
|
|
|
|
</script>
|