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>
|
2017-12-07 19:17:04 +00:00
|
|
|
<span class='date' v-text='local_date(id)'></span>
|
2017-12-07 18:12:32 +00:00
|
|
|
</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: {
|
2017-12-07 19:17:04 +00:00
|
|
|
local_date: function(id){
|
|
|
|
/* (1) Get current date */
|
2017-12-08 01:45:23 +00:00
|
|
|
var cur = new Date( gstore.data.notif.event.data[id].timestamp * 1000 );
|
2017-12-07 19:17:04 +00:00
|
|
|
|
|
|
|
/* (2) First line -> show whole date */
|
|
|
|
if( id < 1 )
|
|
|
|
return cur.toLocaleString();
|
|
|
|
|
|
|
|
/* (3) Get previous date */
|
|
|
|
var pre = new Date( gstore.data.notif.event.data[id-1].timestamp );
|
|
|
|
|
|
|
|
/* (2) If same day -> show time only */
|
|
|
|
if( cur.toLocaleDateString() == pre.toLocaleDateString() )
|
|
|
|
return cur.toLocaleTimeString();
|
|
|
|
|
|
|
|
return cur.toLocaleString();
|
|
|
|
},
|
2017-12-07 18:12:32 +00:00
|
|
|
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 23:59:01 +00:00
|
|
|
/* (2) Prepare request */
|
|
|
|
var rq = {
|
|
|
|
message: this.gstore.new_msg.event,
|
|
|
|
location: this.gstore.loc,
|
|
|
|
username: this.gstore.server.session.name
|
|
|
|
};
|
2017-12-07 19:04:55 +00:00
|
|
|
|
|
|
|
/* (3) Add loader */
|
|
|
|
gstore.data.msg_pending.event = true;
|
|
|
|
|
2017-12-07 23:59:01 +00:00
|
|
|
/* (4) Send request */
|
|
|
|
api.call("POST message/event/"+this.dep, rq, function(rs){
|
|
|
|
|
|
|
|
// {1} If error -> exit //
|
|
|
|
if( rs.error != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// {2} Empty input //
|
|
|
|
gstore.data.new_msg.event = '';
|
|
|
|
|
|
|
|
});
|
2017-12-07 19:04:55 +00:00
|
|
|
|
2017-12-07 18:12:32 +00:00
|
|
|
},
|
|
|
|
bbcode: function(msg){
|
2017-12-07 19:47:03 +00:00
|
|
|
return this.gstore.func.bbcode(msg);
|
2017-12-07 18:12:32 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-04 22:29:02 +00:00
|
|
|
}
|
|
|
|
</script>
|