2013-05-09 16:05:39 +00:00
|
|
|
|
Callbacks = {
|
|
|
|
|
|
|
|
|
|
connect: function() {
|
|
|
|
|
socket.emit("joinChannel", {
|
|
|
|
|
name: CHANNEL
|
|
|
|
|
});
|
|
|
|
|
if(uname && session) {
|
|
|
|
|
socket.emit("login", {
|
|
|
|
|
name: uname,
|
|
|
|
|
session: session
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
$("<div/>").addClass("server-msg-reconnect")
|
|
|
|
|
.text("Connected")
|
|
|
|
|
.appendTo($("#messagebuffer"));
|
|
|
|
|
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
|
|
|
|
},
|
2013-03-20 18:35:06 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
disconnect: function() {
|
|
|
|
|
if(KICKED)
|
|
|
|
|
return;
|
2013-04-14 17:38:00 +00:00
|
|
|
|
$("<div/>")
|
|
|
|
|
.addClass("server-msg-disconnect")
|
2013-05-09 16:05:39 +00:00
|
|
|
|
.text("Disconnected from server. Attempting reconnection...")
|
2013-04-14 17:38:00 +00:00
|
|
|
|
.appendTo($("#messagebuffer"));
|
2013-04-23 19:17:42 +00:00
|
|
|
|
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
announcement: function(data) {
|
|
|
|
|
var div = $("<div/>").addClass("alert")
|
|
|
|
|
.insertAfter($(".row")[0]);
|
2013-05-13 01:37:03 +00:00
|
|
|
|
$("<button/>").addClass("close pull-right").text("×")
|
2013-05-09 16:05:39 +00:00
|
|
|
|
.appendTo(div)
|
|
|
|
|
.click(function() { div.remove(); });
|
|
|
|
|
$("<h3/>").data.text(data.title).appendTo(div);
|
|
|
|
|
$("<p/>").html(data.text).appendTo(div);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
kick: function(data) {
|
|
|
|
|
KICKED = true;
|
|
|
|
|
$("<div/>").addClass("server-msg-disconnect")
|
|
|
|
|
.text("Kicked: " + data.msg)
|
|
|
|
|
.appendTo($("#messagebuffer"));
|
|
|
|
|
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollheight"));
|
|
|
|
|
},
|
2013-04-23 19:17:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
noflood: function(data) {
|
2013-04-23 19:17:42 +00:00
|
|
|
|
$("<div/>")
|
|
|
|
|
.addClass("server-msg-disconnect")
|
|
|
|
|
.text(data.action + ": " + data.msg)
|
|
|
|
|
.appendTo($("#messagebuffer"));
|
|
|
|
|
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
channelNotRegistered: function() {
|
|
|
|
|
var div = $("<div/>").addClass("alert alert-info").attr("id", "chregnotice")
|
|
|
|
|
.insertAfter($(".row")[0]);
|
|
|
|
|
$("<button/>").addClass("close pull-right").text("×")
|
|
|
|
|
.appendTo(div)
|
|
|
|
|
.click(function() { div.remove(); });
|
|
|
|
|
$("<h3/>").text("This channel isn't registered").appendTo(div);
|
|
|
|
|
$("<button/>").addClass("btn btn-primary").text("Register it")
|
|
|
|
|
.appendTo(div)
|
|
|
|
|
.click(function() {
|
|
|
|
|
socket.emit("registerChannel");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
registerChannel: function(data) {
|
2013-03-17 17:14:34 +00:00
|
|
|
|
if(data.success) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#chregnotice").remove();
|
2013-03-17 17:14:34 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.error);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-03-17 17:14:34 +00:00
|
|
|
|
|
2013-05-13 19:41:29 +00:00
|
|
|
|
unregisterChannel: function(data) {
|
|
|
|
|
if(data.success) {
|
|
|
|
|
alert("Channel unregistered");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert(data.error);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
updateMotd: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
$("#motdtext").val(data.motd);
|
|
|
|
|
if(data.motd != "")
|
|
|
|
|
$("#motd").parent().css("display", "");
|
|
|
|
|
else
|
|
|
|
|
$("#motd").parent().css("display", "none");
|
|
|
|
|
$("#motd")[0].innerHTML = data.html;
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
chatFilters: function(data) {
|
|
|
|
|
var entries = data.filters;
|
|
|
|
|
var tbl = $("#filtereditor table");
|
|
|
|
|
if(tbl.children().length > 1) {
|
|
|
|
|
$(tbl.children()[1]).remove();
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i < entries.length; i++) {
|
|
|
|
|
var f = entries[i];
|
|
|
|
|
var tr = $("<tr/>").appendTo(tbl);
|
|
|
|
|
var remove = $("<button/>").addClass("btn btn-mini btn-danger")
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
|
|
|
|
|
var name = $("<code/>").text(f.name)
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
var regex = $("<code/>").text(f.source)
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
var flags = $("<code/>").text(f.flags)
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
var replace = $("<code/>").text(f.replace)
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
var activetd = $("<td/>").appendTo(tr);
|
|
|
|
|
var active = $("<input/>").attr("type", "checkbox")
|
|
|
|
|
.prop("checked", f.active).appendTo(activetd);
|
|
|
|
|
|
|
|
|
|
var remcallback = (function(filter) { return function() {
|
|
|
|
|
socket.emit("chatFilter", {
|
|
|
|
|
cmd: "remove",
|
|
|
|
|
filter: filter
|
|
|
|
|
});
|
|
|
|
|
} })(f);
|
|
|
|
|
remove.click(remcallback);
|
|
|
|
|
|
|
|
|
|
var actcallback = (function(filter) { return function() {
|
|
|
|
|
// Apparently when you check a checkbox, its value is changed
|
|
|
|
|
// before this callback. When you uncheck it, its value is not
|
|
|
|
|
// changed before this callback
|
|
|
|
|
// [](/amgic)
|
|
|
|
|
var enabled = active.prop("checked");
|
|
|
|
|
filter.active = (filter.active == enabled) ? !enabled : enabled;
|
|
|
|
|
socket.emit("chatFilter", {
|
|
|
|
|
cmd: "update",
|
|
|
|
|
filter: filter
|
|
|
|
|
});
|
|
|
|
|
} })(f);
|
|
|
|
|
active.click(actcallback);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newfilt = $("<tr/>").appendTo(tbl);
|
|
|
|
|
$("<td/>").appendTo(newfilt);
|
|
|
|
|
var name = $("<input/>").attr("type", "text")
|
|
|
|
|
.appendTo($("<td/>").appendTo(newfilt));
|
|
|
|
|
var regex = $("<input/>").attr("type", "text")
|
|
|
|
|
.appendTo($("<td/>").appendTo(newfilt));
|
|
|
|
|
var flags = $("<input/>").attr("type", "text")
|
|
|
|
|
.val("g")
|
|
|
|
|
.appendTo($("<td/>").appendTo(newfilt));
|
|
|
|
|
var replace = $("<input/>").attr("type", "text")
|
|
|
|
|
.appendTo($("<td/>").appendTo(newfilt));
|
|
|
|
|
var add = $("<button/>").addClass("btn btn-primary")
|
|
|
|
|
.text("Add Filter")
|
|
|
|
|
.appendTo($("<td/>").appendTo(newfilt));
|
|
|
|
|
var cback = (function(name, regex, fg, replace) { return function() {
|
|
|
|
|
if(regex.val() && replace.val()) {
|
|
|
|
|
var re = regex.val();
|
|
|
|
|
var flags = fg.val();
|
|
|
|
|
try {
|
|
|
|
|
var dummy = new RegExp(re, flags);
|
|
|
|
|
}
|
|
|
|
|
catch(e) {
|
|
|
|
|
alert("Invalid regex: " + e);
|
|
|
|
|
}
|
|
|
|
|
socket.emit("chatFilter", {
|
|
|
|
|
cmd: "update",
|
|
|
|
|
filter: {
|
|
|
|
|
name: name.val(),
|
|
|
|
|
source: re,
|
|
|
|
|
flags: flags,
|
|
|
|
|
replace: replace.val(),
|
|
|
|
|
active: true
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} })(name, regex, flags, replace);
|
|
|
|
|
add.click(cback);
|
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
channelOpts: function(opts) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#opt_qopen_allow_qnext").prop("checked", opts.qopen_allow_qnext);
|
|
|
|
|
$("#opt_qopen_allow_move").prop("checked", opts.qopen_allow_move);
|
|
|
|
|
$("#opt_qopen_allow_delete").prop("checked", opts.qopen_allow_delete);
|
|
|
|
|
$("#opt_qopen_allow_playnext").prop("checked", opts.qopen_allow_playnext);
|
2013-05-04 22:54:28 +00:00
|
|
|
|
$("#opt_qopen_temp").prop("checked", opts.qopen_temp);
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#opt_pagetitle").attr("placeholder", opts.pagetitle);
|
2013-03-22 20:04:04 +00:00
|
|
|
|
document.title = opts.pagetitle;
|
2013-03-30 05:49:41 +00:00
|
|
|
|
PAGETITLE = opts.pagetitle;
|
2013-04-06 21:08:26 +00:00
|
|
|
|
$("#opt_customcss").val(opts.customcss);
|
2013-04-16 16:11:10 +00:00
|
|
|
|
$("#opt_customjs").val(opts.customjs);
|
2013-04-23 19:17:42 +00:00
|
|
|
|
$("#opt_chat_antiflood").prop("checked", opts.chat_antiflood);
|
2013-05-01 22:49:34 +00:00
|
|
|
|
$("#opt_show_public").prop("checked", opts.show_public);
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#customCss").remove();
|
2013-04-06 21:08:26 +00:00
|
|
|
|
if(opts.customcss.trim() != "") {
|
2013-05-03 02:56:31 +00:00
|
|
|
|
$("#usertheme").remove();
|
|
|
|
|
$("<link/>")
|
|
|
|
|
.attr("rel", "stylesheet")
|
|
|
|
|
.attr("href", opts.customcss)
|
|
|
|
|
.attr("id", "customCss")
|
|
|
|
|
.appendTo($("head"));
|
2013-03-23 22:15:19 +00:00
|
|
|
|
}
|
2013-04-02 19:07:22 +00:00
|
|
|
|
$("#opt_allow_voteskip").prop("checked", opts.allow_voteskip);
|
2013-04-21 01:17:38 +00:00
|
|
|
|
$("#opt_voteskip_ratio").val(opts.voteskip_ratio);
|
2013-04-16 16:11:10 +00:00
|
|
|
|
if(opts.customjs.trim() != "") {
|
2013-05-06 16:24:55 +00:00
|
|
|
|
if(opts.customjs != CUSTOMJS) {
|
|
|
|
|
$.getScript(opts.customjs);
|
|
|
|
|
CUSTOMJS = opts.customjs;
|
|
|
|
|
}
|
2013-04-16 16:11:10 +00:00
|
|
|
|
}
|
2013-03-23 22:15:19 +00:00
|
|
|
|
|
2013-03-22 20:04:04 +00:00
|
|
|
|
CHANNELOPTS = opts;
|
|
|
|
|
if(opts.qopen_allow_qnext)
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#queue_next").attr("disabled", false);
|
2013-04-03 22:56:03 +00:00
|
|
|
|
else if(RANK < Rank.Moderator && !LEADER)
|
|
|
|
|
$("#queue_next").attr("disabled", true);
|
2013-03-22 20:04:04 +00:00
|
|
|
|
if(opts.qopen_allow_playnext)
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#play_next").attr("disabled", false);
|
2013-03-28 23:51:08 +00:00
|
|
|
|
else if(RANK < Rank.Moderator && !LEADER)
|
|
|
|
|
$("#play_next").attr("disabled", true);
|
2013-04-02 19:07:22 +00:00
|
|
|
|
|
|
|
|
|
if(opts.allow_voteskip)
|
|
|
|
|
$("#voteskip").attr("disabled", false);
|
|
|
|
|
else
|
|
|
|
|
$("#voteskip").attr("disabled", true);
|
2013-03-22 20:04:04 +00:00
|
|
|
|
rebuildPlaylist();
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
banlist: function(data) {
|
|
|
|
|
var entries = data.entries;
|
|
|
|
|
var tbl = $("#banlist table");
|
|
|
|
|
if(tbl.children().length > 1) {
|
|
|
|
|
$(tbl.children()[1]).remove();
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i < entries.length; i++) {
|
|
|
|
|
var tr = $("<tr/>").appendTo(tbl);
|
|
|
|
|
var remove = $("<button/>").addClass("btn btn-mini btn-danger")
|
|
|
|
|
.appendTo($("<td/>").appendTo(tr));
|
|
|
|
|
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
|
|
|
|
|
var ip = $("<td/>").text(entries[i].ip).appendTo(tr);
|
|
|
|
|
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
|
|
|
|
var banner = $("<td/>").text(entries[i].banner).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
var callback = (function(ip) { return function() {
|
|
|
|
|
socket.emit("chatMsg", {
|
|
|
|
|
msg: "/unban " + ip
|
|
|
|
|
});
|
|
|
|
|
} })(entries[i].ip);
|
|
|
|
|
remove.click(callback);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
seenlogins: function(data) {
|
|
|
|
|
var entries = data.entries;
|
|
|
|
|
var tbl = $("#loginlog table");
|
|
|
|
|
if(tbl.children().length > 1) {
|
|
|
|
|
$(tbl.children()[1]).remove();
|
|
|
|
|
}
|
|
|
|
|
entries.sort(function(a, b) {
|
|
|
|
|
var x = a.name.toLowerCase();
|
|
|
|
|
var y = b.name.toLowerCase();
|
|
|
|
|
// Force blanknames to the bottom
|
|
|
|
|
if(x == "") {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if(y == "") {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return x == y ? 0 : (x < y ? -1 : 1);
|
|
|
|
|
});
|
|
|
|
|
for(var i = 0; i < entries.length; i++) {
|
|
|
|
|
var tr = $("<tr/>").appendTo(tbl);
|
|
|
|
|
var bantd = $("<td/>").appendTo(tr);
|
|
|
|
|
var ban = $("<button/>").addClass("btn btn-mini btn-danger")
|
|
|
|
|
.text("Ban")
|
|
|
|
|
.appendTo(bantd);
|
|
|
|
|
var banrange = $("<button/>").addClass("btn btn-mini btn-danger")
|
|
|
|
|
.text("Ban Range")
|
|
|
|
|
.appendTo(bantd);
|
|
|
|
|
var ip = $("<td/>").text(entries[i].ip).appendTo(tr);
|
|
|
|
|
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
|
|
|
|
|
|
|
|
|
var callback = (function(name) { return function() {
|
|
|
|
|
socket.emit("chatMsg", {
|
|
|
|
|
msg: "/ban " + name
|
|
|
|
|
});
|
|
|
|
|
} })(entries[i].name.split(",")[0]);
|
|
|
|
|
ban.click(callback);
|
|
|
|
|
var callback2 = (function(name) { return function() {
|
|
|
|
|
socket.emit("chatMsg", {
|
|
|
|
|
msg: "/ban " + name + " range"
|
|
|
|
|
});
|
|
|
|
|
} })(entries[i].name.split(",")[0]);
|
|
|
|
|
banrange.click(callback2);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
acl: function(entries) {
|
|
|
|
|
entries.sort(function(a, b) {
|
|
|
|
|
var x = a.name.toLowerCase();
|
|
|
|
|
var y = b.name.toLowerCase();
|
|
|
|
|
return y == x ? 0 : (x < y ? -1 : 1);
|
|
|
|
|
});
|
|
|
|
|
var tbl = $("#channelranks table");
|
|
|
|
|
if(tbl.children().length > 1) {
|
|
|
|
|
$(tbl.children()[1]).remove();
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i < entries.length; i++) {
|
|
|
|
|
var tr = $("<tr/>").appendTo(tbl);
|
|
|
|
|
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
|
|
|
|
name.addClass(getNameColor(entries[i].rank));
|
|
|
|
|
var rank = $("<td/>").text(entries[i].rank).appendTo(tr);
|
|
|
|
|
var control = $("<td/>").appendTo(tr);
|
|
|
|
|
var up = $("<button/>").addClass("btn btn-mini btn-success")
|
|
|
|
|
.appendTo(control);
|
|
|
|
|
$("<i/>").addClass("icon-plus").appendTo(up);
|
|
|
|
|
var down = $("<button/>").addClass("btn btn-mini btn-danger")
|
|
|
|
|
.appendTo(control);
|
|
|
|
|
$("<i/>").addClass("icon-minus").appendTo(down);
|
|
|
|
|
if(entries[i].rank + 1 >= RANK) {
|
|
|
|
|
up.attr("disabled", true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
up.click(function(name) { return function() {
|
|
|
|
|
socket.emit("promote", {
|
|
|
|
|
name: name
|
|
|
|
|
});
|
|
|
|
|
}}(entries[i].name));
|
|
|
|
|
}
|
|
|
|
|
if(entries[i].rank >= RANK) {
|
|
|
|
|
down.attr("disabled", true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
down.click(function(name) { return function() {
|
|
|
|
|
socket.emit("demote", {
|
|
|
|
|
name: name
|
|
|
|
|
});
|
|
|
|
|
}}(entries[i].name));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2013-04-22 18:28:40 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
voteskip: function(data) {
|
2013-04-21 01:17:38 +00:00
|
|
|
|
if(data.count > 0) {
|
|
|
|
|
$("#voteskip").text("Voteskip ("+data.count+"/"+data.need+")");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$("#voteskip").text("Voteskip");
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-21 01:17:38 +00:00
|
|
|
|
|
2013-04-03 22:56:03 +00:00
|
|
|
|
/* REGION Rank Stuff */
|
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
rank: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
RANK = data.rank;
|
|
|
|
|
handleRankChange();
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
register: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
if(data.error) {
|
|
|
|
|
alert(data.error);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
login: function(data) {
|
2013-04-29 01:51:56 +00:00
|
|
|
|
if(!data.success) {
|
|
|
|
|
if(data.error != "Invalid session") {
|
|
|
|
|
alert(data.error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-03 22:56:03 +00:00
|
|
|
|
else {
|
2013-05-04 16:53:07 +00:00
|
|
|
|
$("#welcome").text("Logged in as " + uname);
|
2013-04-03 22:56:03 +00:00
|
|
|
|
$("#loginform").css("display", "none");
|
|
|
|
|
$("#logoutform").css("display", "");
|
|
|
|
|
$("#loggedin").css("display", "");
|
2013-04-26 04:04:51 +00:00
|
|
|
|
session = data.session || "";
|
2013-04-26 03:50:12 +00:00
|
|
|
|
createCookie("sync_uname", uname, 7);
|
|
|
|
|
createCookie("sync_session", session, 7);
|
2013-04-03 22:56:03 +00:00
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
|
|
|
|
/* REGION Chat */
|
2013-05-09 16:05:39 +00:00
|
|
|
|
usercount: function(data) {
|
2013-04-22 17:38:42 +00:00
|
|
|
|
var text = data.count + " connected user";
|
|
|
|
|
if(data.count != 1) {
|
|
|
|
|
text += "s";
|
|
|
|
|
}
|
|
|
|
|
$("#usercount").text(text);
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-03-07 01:38:16 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
chatMsg: function(data) {
|
2013-04-16 01:28:01 +00:00
|
|
|
|
addChatMessage(data);
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
userlist: function(data) {
|
2013-04-11 16:30:20 +00:00
|
|
|
|
$(".userlist_item").each(function() { $(this).remove(); });
|
2013-04-03 22:56:03 +00:00
|
|
|
|
for(var i = 0; i < data.length; i++) {
|
2013-05-09 16:05:39 +00:00
|
|
|
|
Callbacks.addUser(data[i]);
|
2013-04-03 22:56:03 +00:00
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
addUser: function(data) {
|
|
|
|
|
var div = $("<div/>").attr("class", "userlist_item");
|
|
|
|
|
var flair = $("<span/>").appendTo(div);
|
|
|
|
|
var nametag = $("<span/>").text(data.name).appendTo(div);
|
|
|
|
|
formatUserlistItem(div[0], data);
|
|
|
|
|
addUserDropdown(div, data.name);
|
|
|
|
|
var users = $("#userlist").children();
|
|
|
|
|
for(var i = 0; i < users.length; i++) {
|
|
|
|
|
var othername = users[i].children[1].innerHTML;
|
|
|
|
|
if(othername.toLowerCase() > data.name.toLowerCase()) {
|
|
|
|
|
div.insertBefore(users[i]);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
div.appendTo($("#userlist"));
|
2013-05-13 00:41:02 +00:00
|
|
|
|
|
|
|
|
|
if(data.name == uname) {
|
|
|
|
|
PROFILE.image = data.profile.image;
|
|
|
|
|
PROFILE.text = data.profile.text;
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
updateUser: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
if(data.name == uname) {
|
2013-05-13 01:15:05 +00:00
|
|
|
|
PROFILE.text = data.profile.text;
|
|
|
|
|
PROFILE.image = data.profile.image;
|
2013-04-03 22:56:03 +00:00
|
|
|
|
LEADER = data.leader;
|
2013-04-29 16:26:01 +00:00
|
|
|
|
RANK = data.rank;
|
2013-04-03 22:56:03 +00:00
|
|
|
|
handleRankChange();
|
|
|
|
|
if(LEADER) {
|
|
|
|
|
// I'm a leader! Set up sync function
|
|
|
|
|
sendVideoUpdate = function() {
|
|
|
|
|
PLAYER.getTime(function(seconds) {
|
|
|
|
|
socket.emit("mediaUpdate", {
|
|
|
|
|
id: PLAYER.id,
|
|
|
|
|
currentTime: seconds,
|
2013-05-13 22:05:01 +00:00
|
|
|
|
paused: PLAYER.paused,
|
2013-04-03 22:56:03 +00:00
|
|
|
|
type: PLAYER.type
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// I'm not a leader. Don't send syncs to the server
|
|
|
|
|
else {
|
|
|
|
|
sendVideoUpdate = function() { }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
var users = $("#userlist").children();
|
|
|
|
|
for(var i = 0; i < users.length; i++) {
|
|
|
|
|
var name = users[i].children[1].innerHTML;
|
|
|
|
|
// Reformat user
|
|
|
|
|
if(name == data.name) {
|
2013-04-19 19:50:08 +00:00
|
|
|
|
formatUserlistItem(users[i], data);
|
2013-04-03 22:56:03 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
userLeave: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
var users = $("#userlist").children();
|
|
|
|
|
for(var i = 0; i < users.length; i++) {
|
|
|
|
|
var name = users[i].children[1].innerHTML;
|
|
|
|
|
if(name == data.name) {
|
|
|
|
|
$("#userlist")[0].removeChild(users[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-03 22:56:03 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
drinkCount: function(data) {
|
2013-04-22 17:38:42 +00:00
|
|
|
|
if(data.count != 0) {
|
|
|
|
|
var text = data.count + " drink";
|
|
|
|
|
if(data.count != 1) {
|
|
|
|
|
text += "s";
|
|
|
|
|
}
|
|
|
|
|
$("#drinkcount").text(text);
|
2013-05-13 19:06:09 +00:00
|
|
|
|
$("#drinkbar").show();
|
2013-04-04 19:56:43 +00:00
|
|
|
|
}
|
|
|
|
|
else {
|
2013-05-13 19:06:09 +00:00
|
|
|
|
$("#drinkbar").hide();
|
2013-04-04 19:56:43 +00:00
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-04 19:56:43 +00:00
|
|
|
|
|
2013-04-03 22:56:03 +00:00
|
|
|
|
/* REGION Playlist Stuff */
|
2013-05-09 16:05:39 +00:00
|
|
|
|
playlist: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
// Clear the playlist first
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var ul = $("#queue")[0];
|
2013-02-16 05:02:42 +00:00
|
|
|
|
var n = ul.children.length;
|
|
|
|
|
for(var i = 0; i < n; i++) {
|
|
|
|
|
ul.removeChild(ul.children[0]);
|
|
|
|
|
}
|
|
|
|
|
for(var i = 0; i < data.pl.length; i++) {
|
|
|
|
|
var li = makeQueueEntry(data.pl[i]);
|
2013-03-25 18:54:18 +00:00
|
|
|
|
if(RANK >= Rank.Moderator || OPENQUEUE || LEADER)
|
2013-02-16 05:02:42 +00:00
|
|
|
|
addQueueButtons(li);
|
2013-04-24 18:10:08 +00:00
|
|
|
|
$(li).attr("title", data.pl[i].queueby
|
|
|
|
|
? ("Added by: " + data.pl[i].queueby)
|
|
|
|
|
: "Added by: Unknown");
|
2013-02-16 05:02:42 +00:00
|
|
|
|
$(li).appendTo(ul);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
updatePlaylistMeta: function(data) {
|
2013-04-24 19:28:20 +00:00
|
|
|
|
$("#plcount").text(data.count + " items");
|
|
|
|
|
$("#pllength").text(data.time);
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-04-24 19:28:20 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
queue: function(data) {
|
2013-02-16 05:02:42 +00:00
|
|
|
|
var li = makeQueueEntry(data.media);
|
2013-03-25 18:54:18 +00:00
|
|
|
|
if(RANK >= Rank.Moderator || OPENQUEUE || LEADER)
|
2013-02-16 05:02:42 +00:00
|
|
|
|
addQueueButtons(li);
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$(li).css("display", "none");
|
2013-02-16 05:02:42 +00:00
|
|
|
|
var idx = data.pos;
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var ul = $("#queue")[0];
|
2013-04-24 18:10:08 +00:00
|
|
|
|
$(li).attr("title", data.media.queueby
|
|
|
|
|
? ("Added by: " + data.media.queueby)
|
|
|
|
|
: "Added by: Unknown");
|
2013-02-16 05:02:42 +00:00
|
|
|
|
$(li).appendTo(ul);
|
|
|
|
|
if(idx < ul.children.length - 1)
|
|
|
|
|
moveVideo(ul.children.length - 1, idx);
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$(li).show("blind");
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
setTemp: function(data) {
|
2013-05-04 22:54:28 +00:00
|
|
|
|
var li = $("#queue").children()[data.idx];
|
|
|
|
|
var buttons = $(li).find(".qe_btn");
|
|
|
|
|
if(buttons.length == 5) {
|
2013-05-11 22:15:48 +00:00
|
|
|
|
$(buttons[4]).removeClass("btn-danger btn-success");
|
|
|
|
|
$(buttons[4]).addClass(data.temp ? "btn-success" : "btn-danger");
|
2013-05-04 22:54:28 +00:00
|
|
|
|
}
|
|
|
|
|
if(data.temp) {
|
|
|
|
|
$(li).addClass("alert alert-error");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$(li).removeClass("alert alert-error");
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-05-04 22:54:28 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
unqueue: function(data) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var li = $("#queue").children()[data.pos];
|
2013-04-03 22:56:03 +00:00
|
|
|
|
$(li).remove();
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
moveVideo: function(data) {
|
|
|
|
|
// Not recursive
|
2013-02-16 05:02:42 +00:00
|
|
|
|
moveVideo(data.src, data.dest);
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
updatePlaylistIdx: function(data) {
|
2013-03-29 20:05:08 +00:00
|
|
|
|
if(data.old != undefined) {
|
|
|
|
|
var liold = $("#queue").children()[data.old];
|
|
|
|
|
$(liold).removeClass("alert alert-info");
|
|
|
|
|
}
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var linew = $("#queue").children()[data.idx];
|
2013-02-16 05:02:42 +00:00
|
|
|
|
$(linew).addClass("alert alert-info");
|
2013-04-13 17:14:44 +00:00
|
|
|
|
$("#queue").scrollTop(0);
|
|
|
|
|
var scroll = $(linew).position().top - $("#queue").position().top;
|
|
|
|
|
$("#queue").scrollTop(scroll);
|
2013-03-29 20:05:08 +00:00
|
|
|
|
POSITION = data.idx;
|
2013-04-04 16:05:01 +00:00
|
|
|
|
if(CHANNELOPTS.allow_voteskip)
|
|
|
|
|
$("#voteskip").attr("disabled", false);
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
changeMedia: function(data) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#currenttitle").text("Currently Playing: " + data.title);
|
2013-03-25 18:54:18 +00:00
|
|
|
|
if(data.type != "sc" && MEDIATYPE == "sc")
|
2013-04-03 22:56:03 +00:00
|
|
|
|
// [](/goddamnitmango)
|
2013-03-25 18:54:18 +00:00
|
|
|
|
fixSoundcloudShit();
|
2013-04-03 20:18:35 +00:00
|
|
|
|
if(data.type != MEDIATYPE) {
|
|
|
|
|
MEDIATYPE = data.type;
|
|
|
|
|
PLAYER = new Media(data);
|
|
|
|
|
}
|
2013-05-04 22:54:28 +00:00
|
|
|
|
if(PLAYER.update) {
|
|
|
|
|
PLAYER.update(data);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-05-04 22:54:28 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
mediaUpdate: function(data) {
|
2013-05-04 22:54:28 +00:00
|
|
|
|
if(PLAYER.update) {
|
2013-04-03 20:18:35 +00:00
|
|
|
|
PLAYER.update(data);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
queueLock: function(data) {
|
2013-04-03 22:56:03 +00:00
|
|
|
|
OPENQUEUE = !data.locked;
|
|
|
|
|
if(OPENQUEUE) {
|
|
|
|
|
$("#playlist_controls").css("display", "");
|
|
|
|
|
if(RANK < Rank.Moderator) {
|
|
|
|
|
$("#qlockbtn").css("display", "none");
|
|
|
|
|
rebuildPlaylist();
|
|
|
|
|
if(!CHANNELOPTS.qopen_allow_qnext)
|
|
|
|
|
$("#queue_next").attr("disabled", true);
|
|
|
|
|
if(!CHANNELOPTS.qopen_allow_playnext)
|
|
|
|
|
$("#play_next").attr("disabled", true);
|
2013-02-16 05:02:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-04-03 22:56:03 +00:00
|
|
|
|
else if(RANK < Rank.Moderator && !LEADER) {
|
|
|
|
|
$("#playlist_controls").css("display", "none");
|
|
|
|
|
rebuildPlaylist();
|
2013-02-16 05:02:42 +00:00
|
|
|
|
}
|
2013-04-03 22:56:03 +00:00
|
|
|
|
if(OPENQUEUE) {
|
|
|
|
|
$("#qlockbtn").removeClass("btn-danger")
|
|
|
|
|
.addClass("btn-success")
|
|
|
|
|
.text("Lock Queue");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$("#qlockbtn").removeClass("btn-success")
|
|
|
|
|
.addClass("btn-danger")
|
|
|
|
|
.text("Unlock Queue");
|
2013-02-16 05:02:42 +00:00
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-02-16 05:02:42 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
librarySearchResults: function(data) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var n = $("#library").children().length;
|
2013-02-16 05:02:42 +00:00
|
|
|
|
for(var i = 0; i < n; i++) {
|
2013-03-24 17:23:48 +00:00
|
|
|
|
$("#library")[0].removeChild($("#library").children()[0]);
|
2013-02-16 05:02:42 +00:00
|
|
|
|
}
|
2013-03-24 17:23:48 +00:00
|
|
|
|
var ul = $("#library")[0];
|
2013-02-16 05:02:42 +00:00
|
|
|
|
for(var i = 0; i < data.results.length; i++) {
|
|
|
|
|
var li = makeQueueEntry(data.results[i]);
|
2013-04-04 20:55:43 +00:00
|
|
|
|
if(RANK >= Rank.Moderator || OPENQUEUE || LEADER) {
|
|
|
|
|
if(data.results[i].thumb)
|
|
|
|
|
addLibraryButtons(li, data.results[i].id, true);
|
|
|
|
|
else
|
|
|
|
|
addLibraryButtons(li, data.results[i].id);
|
|
|
|
|
}
|
2013-02-16 05:02:42 +00:00
|
|
|
|
$(li).appendTo(ul);
|
|
|
|
|
}
|
2013-05-09 16:05:39 +00:00
|
|
|
|
},
|
2013-03-16 21:49:58 +00:00
|
|
|
|
|
2013-05-09 16:05:39 +00:00
|
|
|
|
/* REGION Polls */
|
|
|
|
|
newPoll: function(data) {
|
|
|
|
|
closePoll();
|
|
|
|
|
var pollMsg = $("<div/>").addClass("poll-notify")
|
|
|
|
|
.text(data.initiator + " opened a poll: \"" + data.title + "\"")
|
|
|
|
|
.appendTo($("#messagebuffer"));
|
|
|
|
|
var poll = $("<div/>").addClass("well active").prependTo($("#pollcontainer"));
|
|
|
|
|
$("<button/>").addClass("close pull-right").text("×")
|
|
|
|
|
.appendTo(poll)
|
|
|
|
|
.click(function() { poll.remove(); });
|
|
|
|
|
if(RANK >= Rank.Moderator || LEADER) {
|
|
|
|
|
$("<button/>").addClass("btn btn-danger pull-right").text("End Poll")
|
|
|
|
|
.appendTo(poll)
|
|
|
|
|
.click(function() {
|
|
|
|
|
socket.emit("closePoll")
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$("<h3/>").text(data.title).appendTo(poll);
|
|
|
|
|
for(var i = 0; i < data.options.length; i++) {
|
|
|
|
|
var callback = (function(i) { return function() {
|
|
|
|
|
socket.emit("vote", {
|
|
|
|
|
option: i
|
|
|
|
|
});
|
|
|
|
|
poll.find(".option button").each(function() {
|
|
|
|
|
$(this).attr("disabled", "disabled");
|
|
|
|
|
});
|
|
|
|
|
} })(i);
|
|
|
|
|
$("<button/>").addClass("btn").text(data.counts[i])
|
|
|
|
|
.prependTo($("<div/>").addClass("option").text(data.options[i])
|
|
|
|
|
.appendTo(poll))
|
|
|
|
|
.click(callback);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updatePoll: function(data) {
|
|
|
|
|
var poll = $("#pollcontainer .active");
|
|
|
|
|
var i = 0;
|
|
|
|
|
poll.find(".option button").each(function() {
|
|
|
|
|
$(this).text(data.counts[i]);
|
|
|
|
|
i++;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
closePoll: function() {
|
|
|
|
|
// Not recursive
|
2013-03-16 21:49:58 +00:00
|
|
|
|
closePoll();
|
2013-05-09 16:05:39 +00:00
|
|
|
|
}
|
2013-02-16 05:02:42 +00:00
|
|
|
|
}
|