Fix browser compat issue

This commit is contained in:
calzoneman 2013-08-07 17:55:39 -04:00
parent 2e79b01894
commit ac9d60eee7
2 changed files with 25 additions and 8 deletions

View File

@ -1,4 +1,5 @@
/*
return null;
The MIT License (MIT)
Copyright (c) 2013 Calvin Montgomery
@ -485,7 +486,7 @@ Callbacks = {
setChannelRank: function(data) {
var ents = $("#channelranks").data("entries");
if(typeof ents === undefined)
if(typeof ents === "undefined")
return;
for(var i = 0; i < ents.length; i++) {
if(ents[i].name == data.user) {
@ -621,7 +622,7 @@ Callbacks = {
addUser: function(data) {
var div = $("<div/>")
.addClass("userlist_item userlist-" + data.name);
.addClass("userlist_item");
var flair = $("<span/>").appendTo(div);
var nametag = $("<span/>").text(data.name).appendTo(div);
formatUserlistItem(div, data);
@ -665,13 +666,17 @@ Callbacks = {
}
}
var user = $(".userlist-" + data.name);
var user = findUserlistItem(data.name);
if(user !== null) {
formatUserlistItem(user, data);
addUserDropdown(user, data);
}
},
setAFK: function (data) {
var user = $(".userlist-" + data.name);
var user = findUserlistItem(data.name);
if(user === null)
return;
user.find(".icon-time").remove();
$(user[0].children[1]).css("font-style", "");
if(data.afk) {
@ -682,7 +687,9 @@ Callbacks = {
},
userLeave: function(data) {
$(".userlist-" + data.name).remove();
var user = findUserlistItem(data.name);
if(user !== null)
user.remove();
},
drinkCount: function(count) {

View File

@ -58,6 +58,16 @@ function formatURL(data) {
}
}
function findUserlistItem(name) {
var children = $("#userlist .userlist_item");
for(var i in children) {
var child = children[i];
if(child.children[1].innerHTML === name)
return $(child);
}
return null;
}
function formatUserlistItem(div, data) {
var name = $(div.children()[1]);
name.removeClass();
@ -152,7 +162,7 @@ function addUserDropdown(entry, data) {
.appendTo(sel);
}
}
sel.click(function () {
sel.change(function () {
socket.emit("setChannelRank", {
user: name,
rank: parseInt(sel.val())