From 2f0f23ec0e54aaa0dc7a9c28217f7daca72ea455 Mon Sep 17 00:00:00 2001 From: lassulus Date: Wed, 6 Nov 2013 21:53:51 +0100 Subject: webchat: nick and time display --- webchat/hello_web.js | 4 ++-- webchat/public/client.js | 29 ++++++++++++++++++++++++++++- webchat/public/reset.css | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) (limited to 'webchat') diff --git a/webchat/hello_web.js b/webchat/hello_web.js index 86e12957..8e2a0bb8 100644 --- a/webchat/hello_web.js +++ b/webchat/hello_web.js @@ -94,8 +94,8 @@ var app = connect() res.write(''); res.write(''); res.write('
'); - res.write('hello, this is #krebs:
'); - res.write('
'); + res.write('hello, this is the official krebs support:
'); + res.write('
'); res.end('
'); }) 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 = $('
').text(object.message).html(); safe_message = replaceURLWithHTMLLinks(safe_message); var safe_from = $('
').text(object.from).html(); - $(''+(new Date).getHours() + ':' + (new Date).getMinutes() + ':' + (new Date).getSeconds()+''+safe_from+''+safe_message+'').insertBefore('#foot'); + $(''+getCurTime()+''+safe_from+''+safe_message+'').insertBefore('#foot'); } catch (error) { console.log(error); diff --git a/webchat/public/reset.css b/webchat/public/reset.css index 2b67f153..931ab453 100644 --- a/webchat/public/reset.css +++ b/webchat/public/reset.css @@ -96,4 +96,7 @@ a { .chat_date:after { content: ""; padding-right: 4px; +} +#time { + color: #00FF00; } \ No newline at end of file -- cgit v1.2.3