make elements more like circ

This commit is contained in:
Neale Pickett 2014-10-26 22:25:59 -06:00
parent 6bf90a1e17
commit d48dd8325a
1 changed files with 16 additions and 20 deletions

View File

@ -26,13 +26,13 @@ function selectForum(room) {
if (current) { if (current) {
current.classList.remove("selected"); current.classList.remove("selected");
// XXX: do this with a class, too // XXX: do this with a class, too
current.messages.display = "none"; current.messages.style.display = "none";
} }
current = room; current = room;
room.classList.add("selected"); room.classList.add("selected");
room.messages.display = "block"; room.messages.style.display = "block";
if (room.messages.lastChild) { if (room.messages.lastChild) {
room.messages.lastChild.scrollIntoView(false); room.messages.lastChild.scrollIntoView(false);
@ -45,7 +45,7 @@ function getForumElement(forum) {
if (! fe) { if (! fe) {
var room = getTemplate("channel room"); var room = getTemplate("channel room");
var content = room.getElementsByClassName("content-item"); var content = room.getElementsByClassName("content-item")[0];
content.textContent = forum; content.textContent = forum;
rooms.appendChild(room); rooms.appendChild(room);
@ -131,38 +131,34 @@ function focus(e) {
function addMessage(timestamp, fullSender, command, sender, forum, args, msg) { function addMessage(timestamp, fullSender, command, sender, forum, args, msg) {
var forumElement = getForumElement(forum); var forumElement = getForumElement(forum);
var p = getTemplate("message"); var msge = getTemplate("message");
console.log(timestamp, msg); console.log(timestamp, msg);
addMessagePart(p, "timestamp", timestamp.toLocaleTimeString()); msge.getElementsByClassName("timestamp")[0].textContent = timestamp.toLocaleTimeString();
var sourcee = msge.getElementsByClassName("source")[0];
var contente = msge.getElementsByClassName("content")[0];
sourcee.textContent = sender;
contente.textContent = msg;
switch (command) { switch (command) {
case "PING": case "PING":
case "PONG": case "PONG":
return; return;
break;
case "PRIVMSG": case "PRIVMSG":
addMessagePart(p, "forum", forum); case "NOTICE":
addMessagePart(p, "sender", sender);
addText(p, msg, (sender == forum));
break;
case "NOTICE":
addMessagePart(p, "forum", forum);
addMessagePart(p, "sender notice", sender);
addText(p, msg, (sender == forum));
break; break;
default: default:
addMessagePart(p, "forum", forum); contente.textContent = command + " " + args + " " + msg;
addMessagePart(p, "sender", sender);
addMessagePart(p, "raw", command + " " + args + " " + msg);
break; break;
} }
while (forumElement.childNodes.length > scrollbackLength) { while (forumElement.childNodes.length > scrollbackLength) {
forumElement.removeChild(forumElement.firstChild) forumElement.removeChild(forumElement.firstChild)
} }
forumElement.appendChild(p);
p.scrollIntoView(false); forumElement.appendChild(msge);
msge.scrollIntoView(false);
} }
function handleInput(oEvent) { function handleInput(oEvent) {