mirror of https://github.com/calzoneman/sync.git
Still working on things
This commit is contained in:
parent
0214910d7e
commit
9c3596b04a
|
@ -39,13 +39,6 @@ html, body {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
.videolist li {
|
|
||||||
margin: 2px 0 0 auto;
|
|
||||||
padding: 2px;
|
|
||||||
font-size: 8pt;
|
|
||||||
border: 1px solid #aaaaaa; // [](/w21)
|
|
||||||
}
|
|
||||||
|
|
||||||
.qe_btn {
|
.qe_btn {
|
||||||
height: 20px;
|
height: 20px;
|
||||||
font-family: Monospace;
|
font-family: Monospace;
|
||||||
|
@ -85,10 +78,6 @@ html, body {
|
||||||
font-size: 8pt;
|
font-size: 8pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#queue {
|
|
||||||
margin-bottom: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#usercountwrap, #currenttitle {
|
#usercountwrap, #currenttitle {
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
|
@ -103,10 +92,24 @@ html, body {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#leftpane-inner div.span12, #rightpane-inner div.span12 {
|
#leftpane-inner div.span12, #rightpane-inner div.span12,
|
||||||
|
#leftpane-inner ul, #rightpane-inner ul {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#queue {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.queue_entry {
|
||||||
|
cursor: row-resize;
|
||||||
|
background-color: #ffffff;
|
||||||
|
margin: 2px 0 0 auto;
|
||||||
|
padding: 2px;
|
||||||
|
font-size: 8pt;
|
||||||
|
border: 1px solid #aaaaaa; // [](/w21)
|
||||||
|
}
|
||||||
|
|
||||||
#plmeta {
|
#plmeta {
|
||||||
border: 1px solid #aaaaaa;
|
border: 1px solid #aaaaaa;
|
||||||
background-color: #ffffff;
|
background-color: #ffffff;
|
||||||
|
|
|
@ -11,14 +11,15 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
||||||
|
|
||||||
Callbacks = {
|
Callbacks = {
|
||||||
|
|
||||||
|
/* fired when socket connection completes */
|
||||||
connect: function() {
|
connect: function() {
|
||||||
socket.emit("joinChannel", {
|
socket.emit("joinChannel", {
|
||||||
name: CHANNEL
|
name: CHANNEL.name
|
||||||
});
|
});
|
||||||
if(uname && session) {
|
if(uname && session) {
|
||||||
socket.emit("login", {
|
socket.emit("login", {
|
||||||
name: uname,
|
name: NAME,
|
||||||
session: session
|
session: SESSION
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$("<div/>").addClass("server-msg-reconnect")
|
$("<div/>").addClass("server-msg-reconnect")
|
||||||
|
@ -34,7 +35,7 @@ Callbacks = {
|
||||||
.addClass("server-msg-disconnect")
|
.addClass("server-msg-disconnect")
|
||||||
.text("Disconnected from server. Attempting reconnection...")
|
.text("Disconnected from server. Attempting reconnection...")
|
||||||
.appendTo($("#messagebuffer"));
|
.appendTo($("#messagebuffer"));
|
||||||
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
scrollChat();
|
||||||
},
|
},
|
||||||
|
|
||||||
errorMsg: function(data) {
|
errorMsg: function(data) {
|
||||||
|
@ -42,15 +43,9 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
announcement: function(data) {
|
announcement: function(data) {
|
||||||
$("#announcerow").html("");
|
$("#announcements").html("");
|
||||||
$("#announcerow").css("display", "");
|
makeAlert(data.title, data.text)
|
||||||
var div = $("<div/>").addClass("alert")
|
.appendTo($("#announcements"));
|
||||||
.appendTo($("#announcerow"));
|
|
||||||
$("<button/>").addClass("close pull-right").text("×")
|
|
||||||
.appendTo(div)
|
|
||||||
.click(function() { div.remove(); });
|
|
||||||
$("<h3/>").text(data.title).appendTo(div);
|
|
||||||
$("<p/>").html(data.text).appendTo(div);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
kick: function(data) {
|
kick: function(data) {
|
||||||
|
@ -58,7 +53,7 @@ Callbacks = {
|
||||||
$("<div/>").addClass("server-msg-disconnect")
|
$("<div/>").addClass("server-msg-disconnect")
|
||||||
.text("Kicked: " + data.reason)
|
.text("Kicked: " + data.reason)
|
||||||
.appendTo($("#messagebuffer"));
|
.appendTo($("#messagebuffer"));
|
||||||
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollheight"));
|
scrollChat();
|
||||||
},
|
},
|
||||||
|
|
||||||
noflood: function(data) {
|
noflood: function(data) {
|
||||||
|
@ -66,13 +61,14 @@ Callbacks = {
|
||||||
.addClass("server-msg-disconnect")
|
.addClass("server-msg-disconnect")
|
||||||
.text(data.action + ": " + data.msg)
|
.text(data.action + ": " + data.msg)
|
||||||
.appendTo($("#messagebuffer"));
|
.appendTo($("#messagebuffer"));
|
||||||
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
scrollChat();
|
||||||
},
|
},
|
||||||
|
|
||||||
channelNotRegistered: function() {
|
channelNotRegistered: function() {
|
||||||
var div = $("<div/>").addClass("alert alert-info").attr("id", "chregnotice")
|
var div = $("<div/>").addClass("alert alert-info")
|
||||||
|
.attr("id", "chregnotice")
|
||||||
.insertBefore($("#main"));
|
.insertBefore($("#main"));
|
||||||
$("<button/>").addClass("close pull-right").text("×")
|
$("<button/>").addClass("close pull-right").html("×")
|
||||||
.appendTo(div)
|
.appendTo(div)
|
||||||
.click(function() { div.remove(); });
|
.click(function() { div.remove(); });
|
||||||
$("<h3/>").text("This channel isn't registered").appendTo(div);
|
$("<h3/>").text("This channel isn't registered").appendTo(div);
|
||||||
|
@ -88,7 +84,8 @@ Callbacks = {
|
||||||
$("#chregnotice").remove();
|
$("#chregnotice").remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert(data.error);
|
makeAlert("Error", data.error, "alert-error")
|
||||||
|
.insertAfter($("#chregnotice"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -101,17 +98,15 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateMotd: function(data) {
|
setMotd: function(data) {
|
||||||
$("#motdtext").val(data.motd);
|
$("#motd").html(data.html);
|
||||||
if(data.motd != "")
|
if(data.motd != "")
|
||||||
$("#motd").parent().css("display", "");
|
$("#motd").show();
|
||||||
else
|
else
|
||||||
$("#motd").parent().css("display", "none");
|
$("#motd").hide();
|
||||||
$("#motd")[0].innerHTML = data.html;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
chatFilters: function(data) {
|
chatFilters: function(entries) {
|
||||||
var entries = data.filters;
|
|
||||||
var tbl = $("#filtereditor table");
|
var tbl = $("#filtereditor table");
|
||||||
if(tbl.children().length > 1) {
|
if(tbl.children().length > 1) {
|
||||||
$(tbl.children()[1]).remove();
|
$(tbl.children()[1]).remove();
|
||||||
|
@ -179,7 +174,9 @@ Callbacks = {
|
||||||
var dummy = new RegExp(re, flags);
|
var dummy = new RegExp(re, flags);
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
alert("Invalid regex: " + e);
|
makeAlert("Invalid regex", e+"", "alert-error")
|
||||||
|
.insertAfter($("#filtereditor table"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
socket.emit("chatFilter", {
|
socket.emit("chatFilter", {
|
||||||
cmd: "update",
|
cmd: "update",
|
||||||
|
@ -197,6 +194,7 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
channelOpts: function(opts) {
|
channelOpts: function(opts) {
|
||||||
|
// TODO update if necessary when HTML admin stuff added
|
||||||
$("#opt_pagetitle").attr("placeholder", opts.pagetitle);
|
$("#opt_pagetitle").attr("placeholder", opts.pagetitle);
|
||||||
document.title = opts.pagetitle;
|
document.title = opts.pagetitle;
|
||||||
PAGETITLE = opts.pagetitle;
|
PAGETITLE = opts.pagetitle;
|
||||||
|
@ -216,21 +214,12 @@ Callbacks = {
|
||||||
$("#opt_allow_voteskip").prop("checked", opts.allow_voteskip);
|
$("#opt_allow_voteskip").prop("checked", opts.allow_voteskip);
|
||||||
$("#opt_voteskip_ratio").val(opts.voteskip_ratio);
|
$("#opt_voteskip_ratio").val(opts.voteskip_ratio);
|
||||||
if(opts.customjs.trim() != "") {
|
if(opts.customjs.trim() != "") {
|
||||||
if(opts.customjs != CUSTOMJS) {
|
if(opts.customjs != CHANNEL.opts.customjs) {
|
||||||
$.getScript(opts.customjs);
|
$.getScript(opts.customjs);
|
||||||
CUSTOMJS = opts.customjs;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CHANNELOPTS = opts;
|
CHANNEL.opts = opts;
|
||||||
if(opts.qopen_allow_qnext)
|
|
||||||
$("#queue_next").attr("disabled", false);
|
|
||||||
else if(RANK < Rank.Moderator && !LEADER)
|
|
||||||
$("#queue_next").attr("disabled", true);
|
|
||||||
if(opts.qopen_allow_playnext)
|
|
||||||
$("#play_next").attr("disabled", false);
|
|
||||||
else if(RANK < Rank.Moderator && !LEADER)
|
|
||||||
$("#play_next").attr("disabled", true);
|
|
||||||
|
|
||||||
if(opts.allow_voteskip)
|
if(opts.allow_voteskip)
|
||||||
$("#voteskip").attr("disabled", false);
|
$("#voteskip").attr("disabled", false);
|
||||||
|
@ -240,7 +229,8 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
setPermissions: function(perms) {
|
setPermissions: function(perms) {
|
||||||
CHANPERMS = perms;
|
CHANNEL.perms = perms;
|
||||||
|
if(CLIENT.rank >= Rank.Admin)
|
||||||
genPermissionsEditor();
|
genPermissionsEditor();
|
||||||
handlePermissionChange();
|
handlePermissionChange();
|
||||||
},
|
},
|
||||||
|
@ -267,8 +257,7 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
banlist: function(data) {
|
banlist: function(entries) {
|
||||||
var entries = data.entries;
|
|
||||||
var tbl = $("#banlist table");
|
var tbl = $("#banlist table");
|
||||||
if(tbl.children().length > 1) {
|
if(tbl.children().length > 1) {
|
||||||
$(tbl.children()[1]).remove();
|
$(tbl.children()[1]).remove();
|
||||||
|
@ -280,6 +269,7 @@ Callbacks = {
|
||||||
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
|
$("<i/>").addClass("icon-remove-circle").appendTo(remove);
|
||||||
var ip = $("<td/>").text(entries[i].ip).appendTo(tr);
|
var ip = $("<td/>").text(entries[i].ip).appendTo(tr);
|
||||||
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
var name = $("<td/>").text(entries[i].name).appendTo(tr);
|
||||||
|
var aliases = $("<td/>").text(entries[i].aliases).appendTo(tr);
|
||||||
var banner = $("<td/>").text(entries[i].banner).appendTo(tr);
|
var banner = $("<td/>").text(entries[i].banner).appendTo(tr);
|
||||||
|
|
||||||
var callback = (function(id, name) { return function() {
|
var callback = (function(id, name) { return function() {
|
||||||
|
@ -292,47 +282,8 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
seenlogins: function(data) {
|
channelRanks: function(entries) {
|
||||||
var entries = data.entries;
|
// TODO Edit if necessary
|
||||||
var tbl = $("#loginlog table");
|
|
||||||
if(tbl.children().length > 1) {
|
|
||||||
$(tbl.children()[1]).remove();
|
|
||||||
}
|
|
||||||
$("#loginlog_pagination").remove();
|
|
||||||
entries.sort(function(a, b) {
|
|
||||||
var x = a.names.join(",").toLowerCase();
|
|
||||||
var y = b.names.join(",").toLowerCase();
|
|
||||||
// Force blanknames to the bottom
|
|
||||||
if(x == "") {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(y == "") {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return x == y ? 0 : (x < y ? -1 : 1);
|
|
||||||
});
|
|
||||||
$("#loginlog").data("entries", entries);
|
|
||||||
if(entries.length > 20) {
|
|
||||||
var pag = $("<div/>").addClass("pagination span12")
|
|
||||||
.attr("id", "loginlog_pagination")
|
|
||||||
.prependTo($("#loginlog"));
|
|
||||||
var btns = $("<ul/>").appendTo(pag);
|
|
||||||
for(var i = 0; i < entries.length / 20; i++) {
|
|
||||||
var li = $("<li/>").appendTo(btns);
|
|
||||||
(function(i) {
|
|
||||||
$("<a/>").attr("href", "javascript:void(0)")
|
|
||||||
.text(i+1)
|
|
||||||
.click(function() {
|
|
||||||
loadLoginlogPage(i);
|
|
||||||
})
|
|
||||||
.appendTo(li);
|
|
||||||
})(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
loadLoginlogPage(0);
|
|
||||||
},
|
|
||||||
|
|
||||||
acl: function(entries) {
|
|
||||||
entries.sort(function(a, b) {
|
entries.sort(function(a, b) {
|
||||||
var x = a.name.toLowerCase();
|
var x = a.name.toLowerCase();
|
||||||
var y = b.name.toLowerCase();
|
var y = b.name.toLowerCase();
|
||||||
|
@ -387,11 +338,12 @@ Callbacks = {
|
||||||
|
|
||||||
/* REGION Rank Stuff */
|
/* REGION Rank Stuff */
|
||||||
|
|
||||||
rank: function(data) {
|
rank: function(r) {
|
||||||
RANK = data.rank;
|
CLIENT.rank = r;
|
||||||
handlePermissionChange();
|
handlePermissionChange();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/* should not be relevant since registration is on account.html */
|
||||||
register: function(data) {
|
register: function(data) {
|
||||||
if(data.error) {
|
if(data.error) {
|
||||||
alert(data.error);
|
alert(data.error);
|
||||||
|
@ -405,20 +357,24 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#welcome").text("Logged in as " + uname);
|
$("#welcome").text("Logged in as " + data.name);
|
||||||
$("#loginform").css("display", "none");
|
$("#loginform").css("display", "none");
|
||||||
$("#logoutform").css("display", "");
|
$("#logoutform").css("display", "");
|
||||||
$("#loggedin").css("display", "");
|
$("#loggedin").css("display", "");
|
||||||
session = data.session || "";
|
SESSION = data.session || "";
|
||||||
createCookie("sync_uname", uname, 7);
|
CLIENT.name = data.name;
|
||||||
createCookie("sync_session", session, 7);
|
CLIENT.logged_in = true;
|
||||||
|
if(SESSION) {
|
||||||
|
createCookie("cytube_uname", CLIENT.name, 7);
|
||||||
|
createCookie("cytube_session", SESSION, 7);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* REGION Chat */
|
/* REGION Chat */
|
||||||
usercount: function(data) {
|
usercount: function(count) {
|
||||||
var text = data.count + " connected user";
|
var text = count + " connected user";
|
||||||
if(data.count != 1) {
|
if(count != 1) {
|
||||||
text += "s";
|
text += "s";
|
||||||
}
|
}
|
||||||
$("#usercount").text(text);
|
$("#usercount").text(text);
|
||||||
|
@ -443,12 +399,8 @@ Callbacks = {
|
||||||
var div = $("<div/>").attr("class", "userlist_item");
|
var div = $("<div/>").attr("class", "userlist_item");
|
||||||
var flair = $("<span/>").appendTo(div);
|
var flair = $("<span/>").appendTo(div);
|
||||||
var nametag = $("<span/>").text(data.name).appendTo(div);
|
var nametag = $("<span/>").text(data.name).appendTo(div);
|
||||||
formatUserlistItem(div[0], data);
|
formatUserlistItem(div, data);
|
||||||
addUserDropdown(div, data.name);
|
addUserDropdown(div, data.name);
|
||||||
if(data.name == uname) {
|
|
||||||
PROFILE.image = data.profile.image;
|
|
||||||
PROFILE.text = data.profile.text;
|
|
||||||
}
|
|
||||||
var users = $("#userlist").children();
|
var users = $("#userlist").children();
|
||||||
for(var i = 0; i < users.length; i++) {
|
for(var i = 0; i < users.length; i++) {
|
||||||
var othername = users[i].children[1].innerHTML;
|
var othername = users[i].children[1].innerHTML;
|
||||||
|
@ -461,15 +413,15 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
updateUser: function(data) {
|
updateUser: function(data) {
|
||||||
if(data.name == uname) {
|
if(data.name == CLIENT.name) {
|
||||||
PROFILE.text = data.profile.text;
|
CLIENT.leader = data.leader;
|
||||||
PROFILE.image = data.profile.image;
|
CLIENT.rank = data.rank;
|
||||||
LEADER = data.leader;
|
|
||||||
RANK = data.rank;
|
|
||||||
handlePermissionChange();
|
handlePermissionChange();
|
||||||
if(LEADER) {
|
if(CLIENT.leader) {
|
||||||
// I'm a leader! Set up sync function
|
// I'm a leader! Set up sync function
|
||||||
sendVideoUpdate = function() {
|
if(LEADTMR)
|
||||||
|
clearInterval(LEADTMR);
|
||||||
|
LEADTMR = setInterval(function() {
|
||||||
PLAYER.getTime(function(seconds) {
|
PLAYER.getTime(function(seconds) {
|
||||||
socket.emit("mediaUpdate", {
|
socket.emit("mediaUpdate", {
|
||||||
id: PLAYER.id,
|
id: PLAYER.id,
|
||||||
|
@ -478,11 +430,13 @@ Callbacks = {
|
||||||
type: PLAYER.type
|
type: PLAYER.type
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}, 5000);
|
||||||
}
|
}
|
||||||
// I'm not a leader. Don't send syncs to the server
|
// I'm not a leader. Don't send syncs to the server
|
||||||
else {
|
else {
|
||||||
sendVideoUpdate = function() { }
|
if(LEADTMR)
|
||||||
|
clearInterval(LEADTMR);
|
||||||
|
LEADTMR = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -491,7 +445,7 @@ Callbacks = {
|
||||||
var name = users[i].children[1].innerHTML;
|
var name = users[i].children[1].innerHTML;
|
||||||
// Reformat user
|
// Reformat user
|
||||||
if(name == data.name) {
|
if(name == data.name) {
|
||||||
formatUserlistItem(users[i], data);
|
formatUserlistItem($(users[i]), data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +456,10 @@ Callbacks = {
|
||||||
for(var i = 0; i < users.length; i++) {
|
for(var i = 0; i < users.length; i++) {
|
||||||
var name = users[i].children[1].innerHTML;
|
var name = users[i].children[1].innerHTML;
|
||||||
if(name == data.name) {
|
if(name == data.name) {
|
||||||
$("#userlist")[0].removeChild(users[i]);
|
$(users[i]).remove();
|
||||||
|
// Note: no break statement here because allowing
|
||||||
|
// the loop to continue means a free cleanup if something
|
||||||
|
// goes wrong and there's a duplicate name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -524,41 +481,40 @@ Callbacks = {
|
||||||
/* REGION Playlist Stuff */
|
/* REGION Playlist Stuff */
|
||||||
playlist: function(data) {
|
playlist: function(data) {
|
||||||
// Clear the playlist first
|
// Clear the playlist first
|
||||||
var ul = $("#queue")[0];
|
var q = $("#queue");
|
||||||
var n = ul.children.length;
|
q.html("");
|
||||||
for(var i = 0; i < n; i++) {
|
|
||||||
ul.removeChild(ul.children[0]);
|
|
||||||
}
|
for(var i = 0; i < data.length; i++) {
|
||||||
for(var i = 0; i < data.pl.length; i++) {
|
Callbacks.queue({
|
||||||
var li = makeQueueEntry(data.pl[i]);
|
media: data[i],
|
||||||
if(RANK >= Rank.Moderator || OPENQUEUE || LEADER)
|
pos: q.children().length
|
||||||
addQueueButtons(li);
|
});
|
||||||
$(li).attr("title", data.pl[i].queueby
|
|
||||||
? ("Added by: " + data.pl[i].queueby)
|
|
||||||
: "Added by: Unknown");
|
|
||||||
$(li).appendTo(ul);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePlaylistMeta: function(data) {
|
setPlaylistMeta: function(data) {
|
||||||
$("#plcount").text(data.count + " items");
|
var c = data.count + " item";
|
||||||
|
if(data.count != 1)
|
||||||
|
c += "s";
|
||||||
|
$("#plcount").text(c);
|
||||||
$("#pllength").text(data.time);
|
$("#pllength").text(data.time);
|
||||||
},
|
},
|
||||||
|
|
||||||
queue: function(data) {
|
queue: function(data) {
|
||||||
var li = makeQueueEntry(data.media);
|
var li = makeQueueEntry(data.media);
|
||||||
if(RANK >= Rank.Moderator || OPENQUEUE || LEADER)
|
li.hide();
|
||||||
addQueueButtons(li);
|
addQueueButtons(li);
|
||||||
$(li).css("display", "none");
|
|
||||||
var idx = data.pos;
|
var idx = data.pos;
|
||||||
var ul = $("#queue")[0];
|
var q = $("#queue");
|
||||||
$(li).attr("title", data.media.queueby
|
li.attr("title", data.media.queueby
|
||||||
? ("Added by: " + data.media.queueby)
|
? ("Added by: " + data.media.queueby)
|
||||||
: "Added by: Unknown");
|
: "Added by: Unknown");
|
||||||
$(li).appendTo(ul);
|
if(idx < q.children().length - 1)
|
||||||
if(idx < ul.children.length - 1)
|
li.insertBefore(q.children()[idx])
|
||||||
moveVideo(ul.children.length - 1, idx);
|
else
|
||||||
$(li).show("blind");
|
li.appendTo(q);
|
||||||
|
li.show("blind");
|
||||||
},
|
},
|
||||||
|
|
||||||
queueFail: function(data) {
|
queueFail: function(data) {
|
||||||
|
@ -566,21 +522,23 @@ Callbacks = {
|
||||||
data = "Queue failed. Check your link to make sure it is valid.";
|
data = "Queue failed. Check your link to make sure it is valid.";
|
||||||
}
|
}
|
||||||
makeAlert("Error", data, "alert-error")
|
makeAlert("Error", data, "alert-error")
|
||||||
.insertAfter($("#playlist_controls"));
|
.insertAfter($("#mediaurl").parent());
|
||||||
},
|
},
|
||||||
|
|
||||||
setTemp: function(data) {
|
setTemp: function(data) {
|
||||||
|
// TODO redo this when buttons are decided
|
||||||
var li = $("#queue").children()[data.idx];
|
var li = $("#queue").children()[data.idx];
|
||||||
var buttons = $(li).find(".qe_btn");
|
li = $(li);
|
||||||
|
var buttons = li.find(".qe_btn");
|
||||||
if(buttons.length == 5) {
|
if(buttons.length == 5) {
|
||||||
$(buttons[4]).removeClass("btn-danger btn-success");
|
$(buttons[4]).removeClass("btn-danger btn-success");
|
||||||
$(buttons[4]).addClass(data.temp ? "btn-success" : "btn-danger");
|
$(buttons[4]).addClass(data.temp ? "btn-success" : "btn-danger");
|
||||||
}
|
}
|
||||||
if(data.temp) {
|
if(data.temp) {
|
||||||
$(li).addClass("alert alert-error");
|
li.addClass("alert alert-error");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$(li).removeClass("alert alert-error");
|
li.removeClass("alert alert-error");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -590,22 +548,24 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
moveVideo: function(data) {
|
moveVideo: function(data) {
|
||||||
// Not recursive
|
playlistMove(data.src, data.dest);
|
||||||
moveVideo(data.src, data.dest);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePlaylistIdx: function(data) {
|
setPosition: function(data) {
|
||||||
if(data.old != undefined) {
|
$("#queue li").each(function() {
|
||||||
var liold = $("#queue").children()[data.old];
|
$(this).removeClass("queue_active");
|
||||||
$(liold).removeClass("alert alert-info");
|
});
|
||||||
}
|
if(data.position < 0)
|
||||||
var linew = $("#queue").children()[data.idx];
|
return;
|
||||||
$(linew).addClass("alert alert-info");
|
POSITION = data.position;
|
||||||
|
var linew = $("#queue").children()[POSITION];
|
||||||
|
$(linew).addClass("queue_active");
|
||||||
|
|
||||||
$("#queue").scrollTop(0);
|
$("#queue").scrollTop(0);
|
||||||
var scroll = $(linew).position().top - $("#queue").position().top;
|
var scroll = $(linew).position().top - $("#queue").position().top;
|
||||||
$("#queue").scrollTop(scroll);
|
$("#queue").scrollTop(scroll);
|
||||||
POSITION = data.idx;
|
|
||||||
if(CHANNELOPTS.allow_voteskip)
|
if(CHANNEL.opts.allow_voteskip)
|
||||||
$("#voteskip").attr("disabled", false);
|
$("#voteskip").attr("disabled", false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -616,12 +576,12 @@ Callbacks = {
|
||||||
fixSoundcloudShit();
|
fixSoundcloudShit();
|
||||||
if(data.type != "jw" && PLAYER.type == "jw") {
|
if(data.type != "jw" && PLAYER.type == "jw") {
|
||||||
// Is it so hard to not mess up my DOM?
|
// Is it so hard to not mess up my DOM?
|
||||||
var wtf = $("<div/>").attr("id", "ytapiplayer")
|
$("<div/>").attr("id", "ytapiplayer")
|
||||||
.insertBefore($("#ytapiplayer_wrapper"));
|
.insertBefore($("#ytapiplayer_wrapper"));
|
||||||
$("#ytapiplayer_wrapper").remove();
|
$("#ytapiplayer_wrapper").remove();
|
||||||
}
|
}
|
||||||
if(data.type != PLAYER.type) {
|
if(data.type != PLAYER.type) {
|
||||||
PLAYER = new Media(data);
|
PLAYER = new Player(data);
|
||||||
}
|
}
|
||||||
if(PLAYER.update) {
|
if(PLAYER.update) {
|
||||||
PLAYER.update(data);
|
PLAYER.update(data);
|
||||||
|
@ -634,9 +594,10 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
queueLock: function(data) {
|
setPlaylistLocked: function(data) {
|
||||||
OPENQUEUE = !data.locked;
|
CHANNEL.openqueue = !data.locked;
|
||||||
if(OPENQUEUE) {
|
// TODO handlePermissionsChange?
|
||||||
|
if(CHANNEL.openqueue) {
|
||||||
$("#playlist_controls").css("display", "");
|
$("#playlist_controls").css("display", "");
|
||||||
if(RANK < Rank.Moderator) {
|
if(RANK < Rank.Moderator) {
|
||||||
$("#qlockbtn").css("display", "none");
|
$("#qlockbtn").css("display", "none");
|
||||||
|
@ -651,19 +612,19 @@ Callbacks = {
|
||||||
$("#playlist_controls").css("display", "none");
|
$("#playlist_controls").css("display", "none");
|
||||||
rebuildPlaylist();
|
rebuildPlaylist();
|
||||||
}
|
}
|
||||||
if(OPENQUEUE) {
|
if(CHANNEL.openqueue) {
|
||||||
$("#qlockbtn").removeClass("btn-danger")
|
$("#qlockbtn").removeClass("btn-danger")
|
||||||
.addClass("btn-success")
|
.addClass("btn-success")
|
||||||
.text("Lock Queue");
|
.text("Lock Playlist");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("#qlockbtn").removeClass("btn-success")
|
$("#qlockbtn").removeClass("btn-success")
|
||||||
.addClass("btn-danger")
|
.addClass("btn-danger")
|
||||||
.text("Unlock Queue");
|
.text("Unlock Playlist");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
librarySearchResults: function(data) {
|
searchResults: function(data) {
|
||||||
clearSearchResults();
|
clearSearchResults();
|
||||||
$("#library").data("entries", data.results);
|
$("#library").data("entries", data.results);
|
||||||
if(data.results.length > 100) {
|
if(data.results.length > 100) {
|
||||||
|
@ -688,13 +649,14 @@ Callbacks = {
|
||||||
|
|
||||||
/* REGION Polls */
|
/* REGION Polls */
|
||||||
newPoll: function(data) {
|
newPoll: function(data) {
|
||||||
closePoll();
|
Callbacks.closePoll();
|
||||||
var pollMsg = $("<div/>").addClass("poll-notify")
|
var pollMsg = $("<div/>").addClass("poll-notify")
|
||||||
.text(data.initiator + " opened a poll: \"" + data.title + "\"")
|
.text(data.initiator + " opened a poll: \"" + data.title + "\"")
|
||||||
.appendTo($("#messagebuffer"));
|
.appendTo($("#messagebuffer"));
|
||||||
$("#messagebuffer").scrollTop($("#messagebuffer").prop("scrollHeight"));
|
scrollChat();
|
||||||
|
|
||||||
var poll = $("<div/>").addClass("well active").prependTo($("#pollcontainer"));
|
var poll = $("<div/>").addClass("well active").prependTo($("#pollcontainer"));
|
||||||
$("<button/>").addClass("close pull-right").text("×")
|
$("<button/>").addClass("close pull-right").html("×")
|
||||||
.appendTo(poll)
|
.appendTo(poll)
|
||||||
.click(function() { poll.remove(); });
|
.click(function() { poll.remove(); });
|
||||||
if(hasPermission("pollctl")) {
|
if(hasPermission("pollctl")) {
|
||||||
|
@ -707,18 +669,20 @@ Callbacks = {
|
||||||
|
|
||||||
$("<h3/>").text(data.title).appendTo(poll);
|
$("<h3/>").text(data.title).appendTo(poll);
|
||||||
for(var i = 0; i < data.options.length; i++) {
|
for(var i = 0; i < data.options.length; i++) {
|
||||||
var callback = (function(i) { return function() {
|
(function(i) {
|
||||||
|
var callback = function() {
|
||||||
socket.emit("vote", {
|
socket.emit("vote", {
|
||||||
option: i
|
option: i
|
||||||
});
|
});
|
||||||
poll.find(".option button").each(function() {
|
poll.find(".option button").each(function() {
|
||||||
$(this).attr("disabled", "disabled");
|
$(this).attr("disabled", "disabled");
|
||||||
});
|
});
|
||||||
} })(i);
|
}
|
||||||
$("<button/>").addClass("btn").text(data.counts[i])
|
$("<button/>").addClass("btn").text(data.counts[i])
|
||||||
.prependTo($("<div/>").addClass("option").text(data.options[i])
|
.prependTo($("<div/>").addClass("option").text(data.options[i])
|
||||||
.appendTo(poll))
|
.appendTo(poll))
|
||||||
.click(callback);
|
.click(callback);
|
||||||
|
})(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,8 +699,16 @@ Callbacks = {
|
||||||
},
|
},
|
||||||
|
|
||||||
closePoll: function() {
|
closePoll: function() {
|
||||||
// Not recursive
|
if($("#pollcontainer .active").length != 0) {
|
||||||
closePoll();
|
var poll = $("#pollcontainer .active");
|
||||||
|
poll.removeClass("active").addClass("muted");
|
||||||
|
poll.find(".option button").each(function() {
|
||||||
|
$(this).attr("disabled", true);
|
||||||
|
});
|
||||||
|
poll.find(".btn-danger").each(function() {
|
||||||
|
$(this).remove()
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
savePlaylist: function(data) {
|
savePlaylist: function(data) {
|
||||||
|
@ -744,8 +716,9 @@ Callbacks = {
|
||||||
makeAlert("Success", "Playlist saved.", "alert-success");
|
makeAlert("Success", "Playlist saved.", "alert-success");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("DBG error " + data.error);
|
makeAlert("Error", data.error, "alert-error")
|
||||||
makeAlert("Error", data.error, "alert-error");
|
.addClass("span12")
|
||||||
|
.insertBefore($("#userpl_list"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -753,8 +726,7 @@ Callbacks = {
|
||||||
if(data.error) {
|
if(data.error) {
|
||||||
makeAlert("Error", data.error, "alert-error")
|
makeAlert("Error", data.error, "alert-error")
|
||||||
.addClass("span12")
|
.addClass("span12")
|
||||||
.css("margin-left", "0")
|
.insertBefore($("#userpl_list"));
|
||||||
.insertBefore($("#userpl_name").parent());
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var pls = data.pllist;
|
var pls = data.pllist;
|
||||||
|
@ -827,6 +799,7 @@ Callbacks = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
$.getScript(IO_URL+"/socket.io/socket.io.js", function() {
|
$.getScript(IO_URL+"/socket.io/socket.io.js", function() {
|
||||||
try {
|
try {
|
||||||
socket = io.connect(IO_URL);
|
socket = io.connect(IO_URL);
|
||||||
|
@ -838,9 +811,14 @@ $.getScript(IO_URL+"/socket.io/socket.io.js", function() {
|
||||||
Callbacks.disconnect();
|
Callbacks.disconnect();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
window.setupNewSocket = function() {
|
setupCallbacks = function() {
|
||||||
for(var key in Callbacks) {
|
for(var key in Callbacks) {
|
||||||
socket.on(key, Callbacks[key]);
|
(function(key) {
|
||||||
|
socket.on(key, function() {
|
||||||
|
Callbacks[key]();
|
||||||
|
});
|
||||||
|
})(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
var CLIENT = {
|
var CLIENT = {
|
||||||
rank: -1,
|
rank: -1,
|
||||||
|
leader: false,
|
||||||
name: "",
|
name: "",
|
||||||
logged_in: false,
|
logged_in: false,
|
||||||
profile: {
|
profile: {
|
||||||
|
@ -12,6 +13,7 @@ var CHANNEL = {
|
||||||
opts: {},
|
opts: {},
|
||||||
openqueue: false,
|
openqueue: false,
|
||||||
perms: {},
|
perms: {},
|
||||||
|
name: false // TODO load name from URL
|
||||||
};
|
};
|
||||||
|
|
||||||
var PLAYER = false;
|
var PLAYER = false;
|
||||||
|
@ -31,6 +33,7 @@ var TITLE_BLINK;
|
||||||
var KICKED = false;
|
var KICKED = false;
|
||||||
var NAME = readCookie("cytube_uname");
|
var NAME = readCookie("cytube_uname");
|
||||||
var SESSION = readCookie("cytube_session");
|
var SESSION = readCookie("cytube_session");
|
||||||
|
var LEADTMR = false;
|
||||||
|
|
||||||
function getOrDefault(k, def) {
|
function getOrDefault(k, def) {
|
||||||
var v = localStorage.getItem(k);
|
var v = localStorage.getItem(k);
|
||||||
|
@ -95,3 +98,6 @@ function readCookie(name) {
|
||||||
function eraseCookie(name) {
|
function eraseCookie(name) {
|
||||||
createCookie(name,"",-1);
|
createCookie(name,"",-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* to be implemented in callbacks.js */
|
||||||
|
function setupCallbacks() { }
|
||||||
|
|
|
@ -2,11 +2,13 @@
|
||||||
function generateToggle(chevron, div) {
|
function generateToggle(chevron, div) {
|
||||||
$(chevron).click(function() {
|
$(chevron).click(function() {
|
||||||
if($(div).css("display") == "none") {
|
if($(div).css("display") == "none") {
|
||||||
|
$(chevron).html($(chevron).html().replace(/Show/, "Hide"));
|
||||||
$(div).show();
|
$(div).show();
|
||||||
$(chevron+" i").removeClass("icon-chevron-down")
|
$(chevron+" i").removeClass("icon-chevron-down")
|
||||||
.addClass("icon-chevron-up");
|
.addClass("icon-chevron-up");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$(chevron).html($(chevron).html().replace(/Hide/, "Show"));
|
||||||
$(div).hide();
|
$(div).hide();
|
||||||
$(chevron+" i").removeClass("icon-chevron-up")
|
$(chevron+" i").removeClass("icon-chevron-up")
|
||||||
.addClass("icon-chevron-down");
|
.addClass("icon-chevron-down");
|
||||||
|
@ -43,7 +45,7 @@ $("#logout").click(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
/* chatbox */
|
/* chatbox */
|
||||||
$("#chatline").keyDown(function(ev) {
|
$("#chatline").keydown(function(ev) {
|
||||||
if(ev.keyCode == 13) {
|
if(ev.keyCode == 13) {
|
||||||
var msg = $("#chatline").val();
|
var msg = $("#chatline").val();
|
||||||
if(msg.trim()) {
|
if(msg.trim()) {
|
||||||
|
@ -155,6 +157,11 @@ $("#userpl_save").click(function() {
|
||||||
|
|
||||||
/* playlist controls */
|
/* playlist controls */
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$("#queue").sortable();
|
||||||
|
$("#queue").disableSelection();
|
||||||
|
});
|
||||||
|
|
||||||
function queue(pos) {
|
function queue(pos) {
|
||||||
var links = $("#mediaurl").val().split(",");
|
var links = $("#mediaurl").val().split(",");
|
||||||
if(pos == "next") {
|
if(pos == "next") {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
<link href="./assets/css/bootstrap.css" rel="stylesheet">
|
<link href="./assets/css/bootstrap.css" rel="stylesheet">
|
||||||
<link href="./assets/css/bootstrap-responsive.css" rel="stylesheet">
|
<link href="./assets/css/bootstrap-responsive.css" rel="stylesheet">
|
||||||
<link href="./assets/css/ytsync.css" rel="stylesheet" id="defaultcss">
|
<link href="./assets/css/ytsync.css" rel="stylesheet" id="defaultcss">
|
||||||
|
<link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
padding-top: 60px;
|
padding-top: 60px;
|
||||||
|
@ -53,7 +54,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- announcement area -->
|
<!-- announcement area -->
|
||||||
<div class="row-fluid" id="announcements" style="display: none">
|
<div class="row-fluid" id="announcements">
|
||||||
</div>
|
</div>
|
||||||
<!-- main row -->
|
<!-- main row -->
|
||||||
<div class="row" id="main">
|
<div class="row" id="main">
|
||||||
|
@ -168,9 +169,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="./assets/js/jquery.js"></script>
|
<script src="./assets/js/jquery.js"></script>
|
||||||
|
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
|
||||||
<!-- My Javascript -->
|
<!-- My Javascript -->
|
||||||
<script src="./assets/js/data.js"></script>
|
<script src="./assets/js/data.js"></script>
|
||||||
|
<script src="./assets/js/util.js"></script>
|
||||||
<script src="./assets/js/ui.js"></script>
|
<script src="./assets/js/ui.js"></script>
|
||||||
|
<script src="./assets/js/callbacks.js"></script>
|
||||||
<!--
|
<!--
|
||||||
<script src="./assets/js/iourl.js"></script>
|
<script src="./assets/js/iourl.js"></script>
|
||||||
<script src="./assets/js/notwebsocket.js"></script>
|
<script src="./assets/js/notwebsocket.js"></script>
|
||||||
|
@ -178,7 +182,9 @@
|
||||||
<script src="./assets/js/functions.js"></script>
|
<script src="./assets/js/functions.js"></script>
|
||||||
<script src="./assets/js/client.js"></script>
|
<script src="./assets/js/client.js"></script>
|
||||||
<script src="./assets/js/callbacks.js"></script>
|
<script src="./assets/js/callbacks.js"></script>
|
||||||
|
-->
|
||||||
<!-- APIs -->
|
<!-- APIs -->
|
||||||
|
<!--
|
||||||
<script src="http://api.dmcdn.net/all.js"></script>
|
<script src="http://api.dmcdn.net/all.js"></script>
|
||||||
<script src="http://jwpsrv.com/library/QouFCLBMEeKC+CIACpYGxA.js"></script>
|
<script src="http://jwpsrv.com/library/QouFCLBMEeKC+CIACpYGxA.js"></script>
|
||||||
<script src="./assets/js/sc.js"></script>
|
<script src="./assets/js/sc.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue