Adding timestamps to game hall.

This commit is contained in:
marcins78@gmail.com
2011-10-05 10:05:43 +00:00
parent 107c186f1e
commit 0da3541ffe
3 changed files with 17 additions and 2 deletions

View File

@@ -20,7 +20,7 @@
}
.cardHint {
display: inline-block;
display: inline;
color: #6f6fff;
cursor: pointer;
}

View File

@@ -34,6 +34,11 @@
color: #ffffff;
}
.timestamp {
display: inline;
color: #cfcfcf;
}
#disclaimer {
color: #ffffff;
font-size: 80%;
@@ -93,6 +98,7 @@
var chat = new ChatBoxUI("Game Hall", $("#chat"), "/gemp-lotr/server", true);
chat.setBounds(2, 2, 780 - 4, 200 - 4);
chat.showTimestamps = true;
var hall = new GempLotrHallUI($("#hall"), "/gemp-lotr/server", chat);

View File

@@ -5,6 +5,7 @@ var ChatBoxUI = Class.extend({
chatMessagesDiv: null,
chatTalkDiv: null,
chatListDiv: null,
showTimestamps: false,
talkBoxHeight: 25,
init: function(name, div, url, showList) {
@@ -70,6 +71,8 @@ var ChatBoxUI = Class.extend({
this.chatMessagesDiv.prop({ scrollTop: this.chatMessagesDiv.prop("scrollHeight") });
},
monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
processMessages: function(xml, processAgain) {
var root = xml.documentElement;
if (root.tagName == 'chat') {
@@ -78,7 +81,13 @@ var ChatBoxUI = Class.extend({
var message = messages[i];
var from = message.getAttribute("from");
var text = message.childNodes[0].nodeValue;
this.appendMessage("<b>" + from + ":</b> " + text);
if (this.showTimestamps) {
var date = new Date(message.getAttribute("date"));
var dateStr = this.monthNames[date.getMonth()] + " " + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
this.appendMessage("<div class='timestamp'>[" + dateStr + "]</div> <b>" + from + ":</b> " + text);
} else {
this.appendMessage("<b>" + from + ":</b> " + text);
}
}
if (this.chatListDiv != null) {