From 0da3541ffef698155118915386c9cfb8de4071ca Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 5 Oct 2011 10:05:43 +0000 Subject: [PATCH] Adding timestamps to game hall. --- gemp-lotr/gemp-lotr-web/src/main/webapp/game.html | 2 +- gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html | 6 ++++++ gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js | 11 ++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html index 29b00431b..4c99b343a 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html @@ -20,7 +20,7 @@ } .cardHint { - display: inline-block; + display: inline; color: #6f6fff; cursor: pointer; } diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html index 2eeb74bc8..3a798bd08 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/hall.html @@ -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); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js index 99dc1b728..d0617b92e 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/chat.js @@ -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("" + from + ": " + 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("
[" + dateStr + "]
" + from + ": " + text); + } else { + this.appendMessage("" + from + ": " + text); + } } if (this.chatListDiv != null) {