Added timestamps to messages
This commit is contained in:
parent
c63a625a0a
commit
39d8540498
|
@ -400,12 +400,13 @@ function connect(profile, connection_id)
|
|||
if(data.mode == "new_message")
|
||||
{
|
||||
console.log("Recieved new message from "+data.from
|
||||
+" in channel "+data.channel.toString());
|
||||
+" in channel "+data.channel.toString(), data.date);
|
||||
|
||||
// Push the new messages to the chat
|
||||
g.chats[data.channel].messages.push({
|
||||
message: data.message,
|
||||
from: data.from
|
||||
from: data.from,
|
||||
date: data.date
|
||||
});
|
||||
|
||||
// Is the chat and server active
|
||||
|
|
|
@ -205,8 +205,6 @@ function text_to_html(text)
|
|||
if(strikethrough_check) out += "</del>";
|
||||
if(code_check) out += "</code>";
|
||||
|
||||
console.log(out)
|
||||
|
||||
// Send out back
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ function chat_switch_to(id)
|
|||
|
||||
// Setup some memory varibles
|
||||
var last_chat_user = "";
|
||||
var last_chat_date = "";
|
||||
|
||||
// Loop over the messages
|
||||
for(var i=0;i<connections[active_profile].chats[id].messages.length;i++)
|
||||
|
@ -179,16 +180,23 @@ function chat_switch_to(id)
|
|||
// Setup the message header varible
|
||||
var message_header = "";
|
||||
|
||||
// Get the date
|
||||
var date = new Date(connections[active_profile].chats[id].messages[i].date);
|
||||
date = date.toString();
|
||||
|
||||
// Should the chat header be included
|
||||
if(last_chat_user != connections[active_profile].chats[id].messages[i].from)
|
||||
{
|
||||
// Set the last user
|
||||
if(
|
||||
last_chat_user != connections[active_profile].chats[id].messages[i].from ||
|
||||
last_chat_date != date
|
||||
){
|
||||
// Set the memory varibles
|
||||
last_chat_user = connections[active_profile].chats[id].messages[i].from;
|
||||
last_chat_date = date;
|
||||
|
||||
// Include the message header
|
||||
message_header = "<p class='message-header'><b>"+
|
||||
connections[active_profile].chats[id].messages[i].from+
|
||||
"</b></p>";
|
||||
"</b> "+date+"</p>";
|
||||
}
|
||||
|
||||
// Add some html data to the chat
|
||||
|
@ -249,6 +257,13 @@ function chat_send()
|
|||
// Get the message
|
||||
var message = document.getElementById("chat-content-send-textarea").value;
|
||||
|
||||
// Get the date
|
||||
var date = new Date();
|
||||
|
||||
// Remove some data from the date
|
||||
date.setMilliseconds(0);
|
||||
date.setSeconds(0);
|
||||
|
||||
// Is the message not empty and isnt a newline
|
||||
if(message.length > 0 && message != "\n")
|
||||
{
|
||||
|
@ -259,7 +274,8 @@ function chat_send()
|
|||
{
|
||||
mode: "send_message",
|
||||
channel: active_chat,
|
||||
message: message
|
||||
message: message,
|
||||
date: Date.parse(date)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue