Fixes to clientside chat stuff

This commit is contained in:
calzoneman 2013-03-05 14:07:21 -06:00
parent 789471f395
commit fc27736017
3 changed files with 24 additions and 10 deletions

View File

@ -75,8 +75,8 @@
}
.action {
text-decoration: italic;
color: #bbbbbb;
font-style: italic;
color: #aaaaaa;
}
.spoiler {
@ -89,5 +89,5 @@
}
.greentext {
color: #99ff99;
color: #789922; /* Color value directly from 4chan */
}

View File

@ -42,13 +42,7 @@ function initCallbacks() {
});
socket.on('chatMsg', function(data) {
var div = document.createElement('div');
var span = document.createElement('span');
$(span).addClass(data.msgclass);
if(data.msgclass != "action")
data.msg = "<strong>&lt;" + data.username + "&gt;</strong> " + data.msg;
span.innerHTML = data.msg;
div.appendChild(span);
var div = formatChatMessage(data);
$('#messagebuffer')[0].appendChild(div);
// Cap chatbox at most recent 100 messages
if($('#messagebuffer').children().length > 100) {

View File

@ -96,6 +96,26 @@ function addUserDropdown(entry, name) {
return ul;
}
function formatChatMessage(data) {
var div = document.createElement('div');
if(data.msgclass == "action") {
var message = document.createElement('span');
$(message).addClass('action');
message.innerHTML = data.username + " " + data.msg;
div.appendChild(message);
}
else {
var name = document.createElement('span');
var message = document.createElement('span');
name.innerHTML = "<strong>&lt;" + data.username + "&gt;</strong> ";
$(message).addClass(data.msgclass);
message.innerHTML = data.msg;
div.appendChild(name);
div.appendChild(message);
}
return div;
}
// Creates and formats a queue entry
function makeQueueEntry(video) {
var li = $('<li />');