summaryrefslogtreecommitdiffstats
path: root/webchat/public/client.js
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-06 21:57:27 +0100
committertv <tv@nomic.retiolum>2013-11-06 21:57:27 +0100
commitfda7a9cce373e0864c5c13c96dcf37733a357806 (patch)
tree36a47df59f42488f320a1792acdadc773f8d1b58 /webchat/public/client.js
parenta0507027720aee72f1f10cbc2f7504a9960ed465 (diff)
parentbfef0d684e958e363641a0cedbd1a4c55cb70471 (diff)
Merge branch 'master' of https://github.com/krebscode/painload
Diffstat (limited to 'webchat/public/client.js')
-rw-r--r--webchat/public/client.js29
1 files changed, 28 insertions, 1 deletions
diff --git a/webchat/public/client.js b/webchat/public/client.js
index e13ab1f7..e7179449 100644
--- a/webchat/public/client.js
+++ b/webchat/public/client.js
@@ -6,9 +6,36 @@ function setMaybeNick (input) {
var match = /^\/nick\s+(.+)$/.exec(input);
if (match) {
nick = match[1];
+ $('#nick').html(nick);
}
}
+function getCurTime () {
+ date = new Date;
+ h = date.getHours();
+ if(h<10)
+ {
+ h = "0"+h;
+ }
+ m = date.getMinutes();
+ if(m<10)
+ {
+ m = "0"+m;
+ }
+ s = date.getSeconds();
+ if(s<10)
+ {
+ s = "0"+s;
+ }
+ return ''+h+':'+m+':'+s;
+};
+
+$(function updateTime () {
+ $('#time').html(getCurTime());
+ setTimeout(updateTime,'1000');
+ return true;
+});
+
var nick;
$(function connect() {
@@ -26,7 +53,7 @@ $(function connect() {
var safe_message = $('<div/>').text(object.message).html();
safe_message = replaceURLWithHTMLLinks(safe_message);
var safe_from = $('<div/>').text(object.from).html();
- $('<tr><td class="chat_date">'+(new Date).getHours() + ':' + (new Date).getMinutes() + ':' + (new Date).getSeconds()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg">'+safe_message+'</td></tr>').insertBefore('#foot');
+ $('<tr><td class="chat_date">'+getCurTime()+'</td><td class="chat_from">'+safe_from+'</td><td class="chat_msg">'+safe_message+'</td></tr>').insertBefore('#foot');
} catch (error) {
console.log(error);