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 { .action {
text-decoration: italic; font-style: italic;
color: #bbbbbb; color: #aaaaaa;
} }
.spoiler { .spoiler {
@ -89,5 +89,5 @@
} }
.greentext { .greentext {
color: #99ff99; color: #789922; /* Color value directly from 4chan */
} }

View File

@ -42,13 +42,7 @@ function initCallbacks() {
}); });
socket.on('chatMsg', function(data) { socket.on('chatMsg', function(data) {
var div = document.createElement('div'); var div = formatChatMessage(data);
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);
$('#messagebuffer')[0].appendChild(div); $('#messagebuffer')[0].appendChild(div);
// Cap chatbox at most recent 100 messages // Cap chatbox at most recent 100 messages
if($('#messagebuffer').children().length > 100) { if($('#messagebuffer').children().length > 100) {

View File

@ -96,6 +96,26 @@ function addUserDropdown(entry, name) {
return ul; 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 // Creates and formats a queue entry
function makeQueueEntry(video) { function makeQueueEntry(video) {
var li = $('<li />'); var li = $('<li />');