2017-12-04 18:13:49 +00:00
|
|
|
<template>
|
|
|
|
|
|
|
|
<div id='CONTAINER' class='message'>
|
|
|
|
|
2017-12-07 17:17:32 +00:00
|
|
|
<div v-for='(msg, id) in gstore.notif.inbox.data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.inbox.data[id-1][0] != gstore.notif.inbox.data[id][0] ? "1" : "0"'>
|
|
|
|
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif.inbox.data[id-1][0] != msg[0]'></span>
|
2017-12-05 21:30:03 +00:00
|
|
|
<span class='content' v-html='bbcode(msg[1])'></span>
|
2017-12-04 18:13:49 +00:00
|
|
|
</div>
|
|
|
|
|
2017-12-05 21:30:03 +00:00
|
|
|
<div class='end-pad'></div> <!-- End Spacing -->
|
|
|
|
|
2017-12-05 17:12:26 +00:00
|
|
|
<form class='msg-input' @submit.prevent='new_message'>
|
2017-12-07 17:38:27 +00:00
|
|
|
<input type='text' placeholder='Nouveau message..' id='msg-new-content' v-model='gstore.new_msg.inbox' :class='gstore.msg_pending.inbox ? "loading" : ""'>
|
2017-12-05 12:32:42 +00:00
|
|
|
<button></button>
|
|
|
|
</form>
|
2017-12-06 08:42:32 +00:00
|
|
|
|
2017-12-04 18:13:49 +00:00
|
|
|
</div>
|
|
|
|
|
2017-12-05 12:32:42 +00:00
|
|
|
|
2017-12-04 18:13:49 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
2017-12-05 07:39:24 +00:00
|
|
|
name: 'CONTAINER_INBOX',
|
2017-12-05 17:41:39 +00:00
|
|
|
data(){ return { gstore: gstore.data }; },
|
2017-12-05 17:12:26 +00:00
|
|
|
methods: {
|
|
|
|
new_message(msg){
|
|
|
|
|
|
|
|
// {1} Send message //
|
2017-12-07 18:12:32 +00:00
|
|
|
this.gstore.func.sendMessage(this.gstore.new_msg.inbox, wsc_chat);
|
2017-12-05 17:12:26 +00:00
|
|
|
|
|
|
|
// {2} Empty input //
|
2017-12-07 17:38:27 +00:00
|
|
|
this.gstore.new_msg.inbox = '';
|
2017-12-05 21:30:03 +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 */
|
2017-12-05 21:53:37 +00:00
|
|
|
msg = msg.replace(/`([^`]+)`/g, "<span class='code'>$1</span>");
|
2017-12-05 21:30:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* (3) Manage emojis
|
|
|
|
---------------------------------------------------------*/
|
2017-12-05 21:45:55 +00:00
|
|
|
/* (1) Smileys */
|
2017-12-05 21:53:37 +00:00
|
|
|
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>");
|
2017-12-05 21:45:55 +00:00
|
|
|
|
|
|
|
/* (2) Emojis */
|
2017-12-05 21:53:37 +00:00
|
|
|
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>");
|
2017-12-05 21:30:03 +00:00
|
|
|
|
|
|
|
return msg;
|
2017-12-05 17:12:26 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-04 18:13:49 +00:00
|
|
|
}
|
|
|
|
</script>
|