This commit is contained in:
Neale Pickett 2014-07-24 16:34:02 +00:00
parent 8e9ce19272
commit a21005323e
2 changed files with 26 additions and 9 deletions

View File

@ -5,15 +5,18 @@
<script type="application/javascript" src="irc.js">
</script>
<style type="text/css">
#a {
#a, #kiboze {
max-height: 20em;
overflow-y: scroll;
overflow-x: hidden;
overflow: scroll;
}
#a p {
#a p, #kiboze p {
margin: 0em 0em 0em 4em;
text-indent: -4em;
}
#kiboze {
max-height: 7em;
background-color: #eee;
}
.timestamp {
color: silver;
}
@ -27,7 +30,10 @@
color: purple;
}
#command {
input[name~=target] {
width: 7em;
}
input[name~=text] {
width: 75%;
}
</style>
@ -37,8 +43,10 @@
<form id="command">
<input type="hidden" name="auth" value="" id="authtok">
<input type="hidden" name="type" value="command">
<input name="target" value="#tron">
<input name="text" autofocus>
<input type="Submit" value="Send">
</form>
<div id="kiboze"></div>
</body>
</html>

17
irc.js
View File

@ -1,5 +1,9 @@
var msgRe = /([^ ]+) (<[^>]+>) (.*)/;
var authtok;
var kibozeRe = "neal";
function isinView(oObject) {
return (oObject.offsetParent.clientHeight <= oObject.offsetTop);
}
function addMessagePart(p, className, text) {
var e = document.createElement("span");
@ -32,13 +36,18 @@ function addMessage(txt) {
return;
break;
case "PRIVMSG":
addMessagePart(p, "sender", sender);
addMessagePart(p, "forum", forum);
addMessagePart(p, "sender", sender);
addMessagePart(p, "text", msg);
if (-1 != msg.search(kibozeRe)) {
var k = document.getElementById("kiboze");
var p2 = p.cloneNode(true);
k.insertBefore(p2, k.firstChild);
}
break;
default:
addMessagePart(p, "sender", sender);
addMessagePart(p, "forum", forum);
addMessagePart(p, "sender", sender);
addMessagePart(p, "raw", command + " " + args + " " + msg);
break;
}
@ -71,7 +80,7 @@ function handleCommand(event) {
function init() {
var authtok = prompt("Auth token", "");
document.getElementById("authtok").value = authtok;
var source = new EventSource("irc.cgi?auth=" + authtok);
source.onmessage = newmsg;