summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webchat/hello_web.js6
-rw-r--r--webchat/public/client.js29
-rw-r--r--webchat/public/reset.css3
3 files changed, 34 insertions, 4 deletions
diff --git a/webchat/hello_web.js b/webchat/hello_web.js
index dd2f26e3..8e2a0bb8 100644
--- a/webchat/hello_web.js
+++ b/webchat/hello_web.js
@@ -47,7 +47,7 @@ irc_client.on('message#krebs', function(from, message) {
var echo = sockjs.createServer();
echo.on('connection', function(conn) {
- var origin = '['+conn.remoteAddress+':'+conn.remotePort+']';
+ var origin = conn.remoteAddress;
Clients.push(conn);
Clients.broadcast({from: 'system', message: origin + ' has joined'})
irc_client.say("#krebs", origin + ' has joined');
@@ -94,8 +94,8 @@ var app = connect()
res.write('<script src="jquery-2.0.3.min.js"></script>');
res.write('<script src="client.js"></script>');
res.write('<div id=bg><div id=chatter>');
- res.write('hello, this is #krebs:<br>');
- res.write('<table id="chatbox"><tr id="foot"><td></td><td></td><td><input type="text" id="input"></td></tr></table>');
+ res.write('hello, this is the official krebs support:<br>');
+ res.write('<table id="chatbox"><tr id="foot"><td id="time"></td><td id="nick" class="chat_from"></td><td><input type="text" id="input"></td></tr></table>');
res.end('</div></div>');
})
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);
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