diff options
author | Marius Halden <marius.h@lden.org> | 2016-01-11 21:13:57 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-01-11 21:13:57 +0100 |
commit | 52111f6d6b369346eb998338e485aa7bfc991536 (patch) | |
tree | 91d4ef9a786384e314490d51fe2c12ee93fe4465 /irc-sse.js | |
parent | 82f748855794d15ef84e836e80077be9233d68d4 (diff) | |
download | irc-sse-52111f6d6b369346eb998338e485aa7bfc991536.tar.gz irc-sse-52111f6d6b369346eb998338e485aa7bfc991536.tar.bz2 irc-sse-52111f6d6b369346eb998338e485aa7bfc991536.tar.xz |
Track users in channels
Diffstat (limited to 'irc-sse.js')
-rw-r--r-- | irc-sse.js | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -39,8 +39,13 @@ function printMessage(msg) { } function setTopic(newTopic) { - $("#topic").children("h3").html(newTopic); - document.title = newTopic + " - IRC-SSE"; + if (newTopic === "") { + $("#topic").children("h3").html(" "); + document.title = "IRC-SSE"; + } else { + $("#topic").children("h3").html(newTopic); + document.title = newTopic + " - IRC-SSE"; + } } function getUser(user) { @@ -63,12 +68,17 @@ function leave(msg) { printMessage(msg.time + " -!- " + msg.user + " left"); } +function quit(msg) { + var output = msg.time + " -!- " + msg.user + " quit (" + msg.quitMsg + ")"; + printMessage(output); +} + function kick(msg) { - printMessage(msg.time + " -!- " + getUser(msg.kickee) + " was kicked by " + getUser(msg.kicker) + " reason: " + msg.message); + printMessage(msg.time + " -!- " + msg.kickee + " was kicked by " + msg.kicker + " reason: " + msg.message); } function rename(msg) { - printMessage(msg.time + " -!- " + getUser(msg.oldname) + " is now known as " + getUser(msg.newname)); + printMessage(msg.time + " -!- " + msg.oldname + " is now known as " + msg.newname); } function mode(msg) { @@ -127,6 +137,9 @@ function parseMsg(msg) { case 'refresh': location.reload(); break; + case 'quit': + quit(msg); + break; default: break; } @@ -179,5 +192,6 @@ $(document).ready(function() { var evtSrc = new EventSource("/subscribe?" + channel); evtSrc.onmessage = function(e) { + console.log(e.data) parseMsg($.parseJSON(e.data)) } |