Move chat callback to addChatMessage

This commit is contained in:
calzoneman 2013-04-15 20:28:01 -05:00
parent 4e2e349196
commit 6807d0b686
2 changed files with 22 additions and 11 deletions

View File

@ -132,17 +132,7 @@ function initCallbacks() {
});
socket.on("chatMsg", function(data) {
if(IGNORED.indexOf(data.username) != -1) {
return;
}
var div = formatChatMessage(data);
div.appendTo($("#messagebuffer"));
// Cap chatbox at most recent 100 messages
if($("#messagebuffer").children().length > 100) {
$($("#messagebuffer").children()[0]).remove();
}
if(SCROLLCHAT)
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
addChatMessage(data);
});
socket.on("userlist", function(data) {

View File

@ -155,6 +155,20 @@ function addUserDropdown(entry, name) {
return ul;
}
function addChatMessage(data) {
if(IGNORED.indexOf(data.username) != -1) {
return;
}
var div = formatChatMessage(data);
div.appendTo($("#messagebuffer"));
// Cap chatbox at most recent 100 messages
if($("#messagebuffer").children().length > 100) {
$($("#messagebuffer").children()[0]).remove();
}
if(SCROLLCHAT)
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
}
function formatChatMessage(data) {
var div = $("<div/>");
if(uname) {
@ -683,3 +697,10 @@ function onWindowFocus() {
clearInterval(TITLE_BLINK);
document.title = PAGETITLE;
}
function enableBerrymotes() {
$.getScript("./assets/js/berrymotes.js", function() {
berryEmoteDataRefresh();
monkeyPatchChat();
});
}