1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 16:06:15 +00:00

Added proper date support

This commit is contained in:
Loic Blot 2014-09-16 21:59:28 +00:00
parent 2ecaef769a
commit 6b80e30ca0
2 changed files with 18 additions and 1 deletions

View File

@ -72,6 +72,12 @@
float: left;
}
.msg-date {
font-style: italic;
font-size: 90%;
float: right;
}
.msg-spacer {
clear: both;
}

View File

@ -16,6 +16,10 @@ function fetchConversation(phoneNumber) {
var conversationBuf = "";
// Improve JS performance
var msgClass = '';
var unixDate = '';
var formatedDate = '';
var months = ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'Jun.', 'Jul.', 'Aug.', 'Sep.',
'Oct.', 'Nov.', 'Dec.'];
$.each(jsondata["conversation"], function(id, vals) {
if (vals["type"] == 1) {
@ -28,7 +32,14 @@ function fetchConversation(phoneNumber) {
msgClass = '';
}
conversationBuf += '<div><div class="' + msgClass + '">' + vals["msg"] + '</div><div class="msg-spacer"></div></div>';
// Multiplicate ID to permit date to use it properly
msgDate = new Date(id*1);
formatedDate = msgDate.getDate() + " " + months[msgDate.getMonth()-1] + " " +
msgDate.getHours() + ":" + msgDate.getMinutes();
conversationBuf += '<div><div class="' + msgClass + '"><div>' +
vals["msg"] + '</div><div class="msg-date">' +
formatedDate + '</div></div><div class="msg-spacer"></div></div>';
});
$('#app-content').html(conversationBuf);