upd: css.container|vue.container.emergency (added timestamp + date display)
This commit is contained in:
parent
ad575c3697
commit
cf08a98b9e
|
@ -58,6 +58,16 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
#CONTAINER.message div span.date{ /* Message date */
|
||||
display: block;
|
||||
position: relative;
|
||||
|
||||
margin-top: 1em;
|
||||
|
||||
color: #888;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
#CONTAINER.message div span span.code{ /* Code block */
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
<div id='CONTAINER' class='message'>
|
||||
|
||||
<div v-for='(msg, id) in gstore.notif.emergency.data' :class="msg[0] == gstore.server.session.name ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.emergency.data[id-1][0] != gstore.notif.emergency.data[id][0] ? "1" : "0"'>
|
||||
<span class='author' v-text='msg[0]' v-if='id == 0 || gstore.notif.emergency.data[id-1][0] != msg[0]'></span>
|
||||
<span class='content' v-html='bbcode(msg[1])'></span>
|
||||
<div v-for='(msg, id) in gstore.notif.emergency.data' :class="msg.user == gstore.server.session.user ? 'me' : ''" :data-noauthor='id == 0 || gstore.notif.emergency.data[id-1].user != msg.user ? "1" : "0"'>
|
||||
<span class='author' v-text='msg.user' v-if='id == 0 || gstore.notif.emergency.data[id-1].user != msg.user'></span>
|
||||
<span class='content' v-html='bbcode(msg.message)'></span>
|
||||
<span class='date' v-text='local_date(id)'></span>
|
||||
</div>
|
||||
|
||||
<div class='end-pad'></div> <!-- End Spacing -->
|
||||
|
@ -25,6 +26,24 @@ export default {
|
|||
name: 'CONTAINER_EMERGENCY',
|
||||
data(){ return { gstore: gstore.data }; },
|
||||
methods: {
|
||||
local_date: function(id){
|
||||
/* (1) Get current date */
|
||||
var cur = new Date( gstore.data.notif.emergency.data[id].timestamp );
|
||||
console.log(cur);
|
||||
|
||||
/* (2) First line -> show whole date */
|
||||
if( id < 1 )
|
||||
return cur.toLocaleString();
|
||||
|
||||
/* (3) Get previous date */
|
||||
var pre = new Date( gstore.data.notif.emergency.data[id-1].timestamp );
|
||||
|
||||
/* (2) If same day -> show time only */
|
||||
if( cur.toLocaleDateString() == pre.toLocaleDateString() )
|
||||
return cur.toLocaleTimeString();
|
||||
|
||||
return cur.toLocaleString();
|
||||
},
|
||||
new_message(msg){
|
||||
|
||||
// {1} Send message //
|
||||
|
|
Loading…
Reference in New Issue