forked from CringeStudios/gamja
Add support for /me
This commit is contained in:
parent
b612c48fb2
commit
14ac3617ce
@ -42,14 +42,13 @@ function createMessageElement(msg) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
line.appendChild(timestamp);
|
line.appendChild(timestamp);
|
||||||
|
line.appendChild(document.createTextNode(" "));
|
||||||
|
|
||||||
switch (msg.command) {
|
switch (msg.command) {
|
||||||
case "NOTICE":
|
case "NOTICE":
|
||||||
case "PRIVMSG":
|
case "PRIVMSG":
|
||||||
var text = msg.params[1];
|
var text = msg.params[1];
|
||||||
|
|
||||||
line.className += " talk";
|
|
||||||
|
|
||||||
var nick = document.createElement("a");
|
var nick = document.createElement("a");
|
||||||
nick.href = "#";
|
nick.href = "#";
|
||||||
nick.className = "nick nick-" + (djb2(msg.prefix.name) % 16 + 1);
|
nick.className = "nick nick-" + (djb2(msg.prefix.name) % 16 + 1);
|
||||||
@ -59,10 +58,23 @@ function createMessageElement(msg) {
|
|||||||
switchBuffer(createBuffer(msg.prefix.name));
|
switchBuffer(createBuffer(msg.prefix.name));
|
||||||
};
|
};
|
||||||
|
|
||||||
line.appendChild(document.createTextNode(" <"));
|
var actionPrefix = "\001ACTION ";
|
||||||
line.appendChild(nick);
|
if (text.startsWith(actionPrefix) && text.endsWith("\001")) {
|
||||||
line.appendChild(document.createTextNode("> "));
|
var action = text.slice(actionPrefix.length, -1);
|
||||||
line.appendChild(document.createTextNode(text));
|
|
||||||
|
line.className += " me-tell";
|
||||||
|
|
||||||
|
line.appendChild(document.createTextNode("* "));
|
||||||
|
line.appendChild(nick);
|
||||||
|
line.appendChild(document.createTextNode(" " + action));
|
||||||
|
} else {
|
||||||
|
line.className += " talk";
|
||||||
|
|
||||||
|
line.appendChild(document.createTextNode("<"));
|
||||||
|
line.appendChild(nick);
|
||||||
|
line.appendChild(document.createTextNode("> "));
|
||||||
|
line.appendChild(document.createTextNode(text));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
line.appendChild(document.createTextNode(" " + msg.command + " " + msg.params.join(" ")));
|
line.appendChild(document.createTextNode(" " + msg.command + " " + msg.params.join(" ")));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user