Continue work on clientside
This commit is contained in:
parent
5c40a72d47
commit
afff414aad
|
@ -181,5 +181,6 @@ html(lang="en")
|
|||
// $('#channeloptions a[href="#cs-miscoptions"]').tab('show');
|
||||
script(src="/assets/js/data.js")
|
||||
script(src="/assets/js/util.js")
|
||||
script(src="/assets/js/paginator.js")
|
||||
script(src="/assets/js/ui.js")
|
||||
script(src="/assets/js/callbacks.js")
|
||||
|
|
|
@ -619,6 +619,10 @@ Callbacks = {
|
|||
/* REGION Rank Stuff */
|
||||
|
||||
rank: function(r) {
|
||||
if (r > -1) {
|
||||
$("#guestlogin").hide();
|
||||
$("#chatline").show();
|
||||
}
|
||||
if(r >= 255)
|
||||
SUPERADMIN = true;
|
||||
CLIENT.rank = r;
|
||||
|
@ -657,13 +661,6 @@ Callbacks = {
|
|||
}
|
||||
},
|
||||
|
||||
/* should not be relevant since registration is on account.html */
|
||||
register: function(data) {
|
||||
if(data.error) {
|
||||
alert(data.error);
|
||||
}
|
||||
},
|
||||
|
||||
login: function(data) {
|
||||
if(!data.success) {
|
||||
if(data.error != "Session expired") {
|
||||
|
@ -671,17 +668,8 @@ Callbacks = {
|
|||
}
|
||||
}
|
||||
else {
|
||||
$("#welcome").text("Logged in as " + data.name);
|
||||
$("#loginform").css("display", "none");
|
||||
$("#logoutform").css("display", "");
|
||||
$("#loggedin").css("display", "");
|
||||
SESSION = data.session || "";
|
||||
CLIENT.name = data.name;
|
||||
CLIENT.logged_in = true;
|
||||
if(SESSION) {
|
||||
createCookie("cytube_uname", CLIENT.name, 7);
|
||||
createCookie("cytube_session", SESSION, 7);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -709,7 +697,7 @@ Callbacks = {
|
|||
},
|
||||
|
||||
userlist: function(data) {
|
||||
$(".userlist_item").each(function() { $(this).remove(); });
|
||||
$(".userlist_item").remove();
|
||||
for(var i = 0; i < data.length; i++) {
|
||||
Callbacks.addUser(data[i]);
|
||||
}
|
||||
|
@ -722,11 +710,11 @@ Callbacks = {
|
|||
user.remove();
|
||||
var div = $("<div/>")
|
||||
.addClass("userlist_item");
|
||||
var flair = $("<span/>").appendTo(div);
|
||||
var icon = $("<span/>").appendTo(div);
|
||||
var nametag = $("<span/>").text(data.name).appendTo(div);
|
||||
div.data("name", data.name);
|
||||
div.data("rank", data.rank);
|
||||
div.data("leader", false);
|
||||
div.data("leader", Boolean(data.leader));
|
||||
div.data("profile", data.profile);
|
||||
div.data("icon", data.meta.icon);
|
||||
div.data("afk", data.meta.afk);
|
||||
|
@ -746,7 +734,7 @@ Callbacks = {
|
|||
|
||||
setLeader: function (name) {
|
||||
$(".userlist_item").each(function () {
|
||||
$(this).find(".icon-star-empty").remove();
|
||||
$(this).find(".glyphicon-star-empty").remove();
|
||||
if ($(this).data("leader")) {
|
||||
$(this).data("leader", false);
|
||||
addUserDropdown($(this));
|
||||
|
@ -808,43 +796,6 @@ Callbacks = {
|
|||
formatUserlistItem(user);
|
||||
},
|
||||
|
||||
/* DEPRECATED
|
||||
SEE:
|
||||
- setUserIcon
|
||||
- setAFK
|
||||
- setLeader
|
||||
- setUserProfile
|
||||
- setUserRank
|
||||
*/
|
||||
updateUser: function(data) {
|
||||
if(data.name == CLIENT.name) {
|
||||
CLIENT.leader = data.leader;
|
||||
CLIENT.rank = data.rank;
|
||||
handlePermissionChange();
|
||||
if(CLIENT.leader) {
|
||||
// I'm a leader! Set up sync function
|
||||
if(LEADTMR)
|
||||
clearInterval(LEADTMR);
|
||||
LEADTMR = setInterval(sendVideoUpdate, 5000);
|
||||
}
|
||||
// I'm not a leader. Don't send syncs to the server
|
||||
else {
|
||||
if(LEADTMR)
|
||||
clearInterval(LEADTMR);
|
||||
LEADTMR = false;
|
||||
}
|
||||
|
||||
}
|
||||
var user = findUserlistItem(data.name);
|
||||
if(user !== null) {
|
||||
user.data("rank", data.rank);
|
||||
formatUserlistItem(user, data);
|
||||
addUserDropdown(user, data);
|
||||
if(USEROPTS.sort_rank)
|
||||
sortUserlist();
|
||||
}
|
||||
},
|
||||
|
||||
setAFK: function (data) {
|
||||
var user = findUserlistItem(data.name);
|
||||
if(user === null)
|
||||
|
@ -940,7 +891,7 @@ Callbacks = {
|
|||
},
|
||||
|
||||
queueFail: function (data) {
|
||||
queueMessage(data, "alert-error");
|
||||
queueMessage(data, "alert-danger");
|
||||
},
|
||||
|
||||
setTemp: function(data) {
|
||||
|
@ -1038,16 +989,16 @@ Callbacks = {
|
|||
.addClass("btn-success")
|
||||
.attr("title", "Playlist Unlocked");
|
||||
$("#qlockbtn").find("i")
|
||||
.removeClass("icon-lock")
|
||||
.addClass("icon-ok");
|
||||
.removeClass("glyphicon-lock")
|
||||
.addClass("glyphicon-ok");
|
||||
}
|
||||
else {
|
||||
$("#qlockbtn").removeClass("btn-success")
|
||||
.addClass("btn-danger")
|
||||
.attr("title", "Playlist Locked");
|
||||
$("#qlockbtn").find("i")
|
||||
.removeClass("icon-ok")
|
||||
.addClass("icon-lock");
|
||||
.removeClass("glyphicon-ok")
|
||||
.addClass("glyphicon-lock");
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1055,8 +1006,7 @@ Callbacks = {
|
|||
$("#search_clear").remove();
|
||||
clearSearchResults();
|
||||
$("#library").data("entries", data.results);
|
||||
$("<button/>").addClass("btn btn-block")
|
||||
.addClass("span12")
|
||||
$("<button/>").addClass("btn btn-default btn-sm btn-block")
|
||||
.css("margin-left", "0")
|
||||
.attr("id", "search_clear")
|
||||
.text("Clear Results")
|
||||
|
@ -1102,7 +1052,7 @@ Callbacks = {
|
|||
.appendTo(poll)
|
||||
.click(function() { poll.remove(); });
|
||||
if(hasPermission("pollctl")) {
|
||||
$("<button/>").addClass("btn btn-danger pull-right").text("End Poll")
|
||||
$("<button/>").addClass("btn btn-danger btn-sm pull-right").text("End Poll")
|
||||
.appendTo(poll)
|
||||
.click(function() {
|
||||
socket.emit("closePoll")
|
||||
|
@ -1121,7 +1071,7 @@ Callbacks = {
|
|||
});
|
||||
$(this).parent().addClass("option-selected");
|
||||
}
|
||||
$("<button/>").addClass("btn").text(data.counts[i])
|
||||
$("<button/>").addClass("btn btn-default btn-sm").text(data.counts[i])
|
||||
.prependTo($("<div/>").addClass("option").html(data.options[i])
|
||||
.appendTo(poll))
|
||||
.click(callback);
|
||||
|
@ -1159,7 +1109,7 @@ Callbacks = {
|
|||
makeAlert("Success", "Playlist saved.", "alert-success");
|
||||
}
|
||||
else {
|
||||
makeAlert("Error", data.error, "alert-error")
|
||||
makeAlert("Error", data.error, "alert-danger")
|
||||
.addClass("span12")
|
||||
.insertBefore($("#userpl_list"));
|
||||
}
|
||||
|
@ -1167,8 +1117,7 @@ Callbacks = {
|
|||
|
||||
listPlaylists: function(data) {
|
||||
if(data.error) {
|
||||
makeAlert("Error", data.error, "alert-error")
|
||||
.addClass("span12")
|
||||
makeAlert("Error", data.error, "alert-danger")
|
||||
.insertBefore($("#userpl_list"));
|
||||
}
|
||||
else {
|
||||
|
@ -1200,9 +1149,9 @@ Callbacks = {
|
|||
.css("float", "left")
|
||||
.prependTo(li);
|
||||
var del = $("<button/>")
|
||||
.addClass("btn btn-mini btn-danger")
|
||||
.addClass("btn btn-xs btn-danger")
|
||||
.prependTo(bg);
|
||||
$("<i/>").addClass("icon-trash").appendTo(del);
|
||||
$("<span/>").addClass("glyphicon glyphicon-trash").appendTo(del);
|
||||
(function(li) {
|
||||
del.click(function() {
|
||||
var go = confirm("Are you sure you want to delete playlist '" + li.data("pl-name") + "'?");
|
||||
|
@ -1215,7 +1164,7 @@ Callbacks = {
|
|||
})(li);
|
||||
if(hasPermission("playlistaddlist")) {
|
||||
(function(li) {
|
||||
$("<button/>").addClass("btn btn-mini")
|
||||
$("<button/>").addClass("btn btn-xs btn-default")
|
||||
.text("End")
|
||||
.prependTo(bg)
|
||||
.click(function() {
|
||||
|
@ -1228,7 +1177,7 @@ Callbacks = {
|
|||
|
||||
if(hasPermission("playlistnext")) {
|
||||
(function(li) {
|
||||
$("<button/>").addClass("btn btn-mini")
|
||||
$("<button/>").addClass("btn btn-xs btn-default")
|
||||
.text("Next")
|
||||
.prependTo(bg)
|
||||
.click(function() {
|
||||
|
|
|
@ -53,6 +53,8 @@ function formatURL(data) {
|
|||
return "http://imgur.com/a/" + data.id;
|
||||
case "us":
|
||||
return "http://ustream.tv/" + data.id;
|
||||
case "gd":
|
||||
return data.id;
|
||||
default:
|
||||
return "#";
|
||||
}
|
||||
|
@ -117,18 +119,18 @@ function formatUserlistItem(div) {
|
|||
name.mouseleave(function() {
|
||||
profile.remove();
|
||||
});
|
||||
var flair = div.children()[0];
|
||||
flair.innerHTML = "";
|
||||
var icon = div.children()[0];
|
||||
icon.innerHTML = "";
|
||||
// denote current leader with a star
|
||||
if(data.leader) {
|
||||
$("<i/>").addClass("icon-star-empty").appendTo(flair);
|
||||
$("<span/>").addClass("glyphicon glyphicon-star-empty").appendTo(icon);
|
||||
}
|
||||
if(data.afk) {
|
||||
name.css("font-style", "italic");
|
||||
$("<i/>").addClass("icon-time").appendTo(flair);
|
||||
$("<span/>").addClass("glyphicon glyphicon-time").appendTo(icon);
|
||||
}
|
||||
if (data.icon) {
|
||||
$("<i/>").addClass(data.icon).prependTo(flair);
|
||||
$("<span/>").addClass(data.icon).prependTo(icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +167,7 @@ function addUserDropdown(entry) {
|
|||
*/
|
||||
if(CLIENT.rank >= 3 && CLIENT.rank > rank && rank > 0 && rank != 1.5) {
|
||||
var sel = $("<select/>")
|
||||
.addClass("input-block-level")
|
||||
.addClass("form-control")
|
||||
.appendTo(menu);
|
||||
$("<option/>").attr("value", "1").text("Regular User")
|
||||
.appendTo(sel);
|
||||
|
@ -190,7 +192,7 @@ function addUserDropdown(entry) {
|
|||
}
|
||||
|
||||
/* ignore button */
|
||||
var ignore = $("<button/>").addClass("btn btn-mini btn-block")
|
||||
var ignore = $("<button/>").addClass("btn btn-xs btn-default btn-block")
|
||||
.appendTo(menu)
|
||||
.click(function () {
|
||||
if(IGNORED.indexOf(name) == -1) {
|
||||
|
@ -209,7 +211,7 @@ function addUserDropdown(entry) {
|
|||
|
||||
/* gib/remove leader (moderator+ only) */
|
||||
if(CLIENT.rank >= 2) {
|
||||
var ldr = $("<button/>").addClass("btn btn-mini btn-block")
|
||||
var ldr = $("<button/>").addClass("btn btn-xs btn-default btn-block")
|
||||
.appendTo(menu);
|
||||
if(leader) {
|
||||
ldr.text("Remove Leader");
|
||||
|
@ -230,7 +232,7 @@ function addUserDropdown(entry) {
|
|||
|
||||
/* kick button */
|
||||
if(hasPermission("kick")) {
|
||||
$("<button/>").addClass("btn btn-mini btn-block")
|
||||
$("<button/>").addClass("btn btn-xs btn-default btn-block")
|
||||
.text("Kick")
|
||||
.click(function () {
|
||||
socket.emit("chatMsg", {
|
||||
|
@ -242,7 +244,7 @@ function addUserDropdown(entry) {
|
|||
|
||||
/* ban buttons */
|
||||
if(hasPermission("ban")) {
|
||||
$("<button/>").addClass("btn btn-mini btn-block")
|
||||
$("<button/>").addClass("btn btn-xs btn-default btn-block")
|
||||
.text("Name Ban")
|
||||
.click(function () {
|
||||
socket.emit("chatMsg", {
|
||||
|
@ -250,7 +252,7 @@ function addUserDropdown(entry) {
|
|||
});
|
||||
})
|
||||
.appendTo(menu);
|
||||
$("<button/>").addClass("btn btn-mini btn-block")
|
||||
$("<button/>").addClass("btn btn-xs btn-default btn-block")
|
||||
.text("IP Ban")
|
||||
.click(function () {
|
||||
socket.emit("chatMsg", {
|
||||
|
@ -323,8 +325,8 @@ function sortUserlist() {
|
|||
list.sort(function (a, b) {
|
||||
var r1 = $(a).data("rank");
|
||||
var r2 = $(b).data("rank");
|
||||
var afk1 = $(a).find(".icon-time").length > 0;
|
||||
var afk2 = $(b).find(".icon-time").length > 0;
|
||||
var afk1 = $(a).find(".glyphicon-time").length > 0;
|
||||
var afk2 = $(b).find(".glyphicon-time").length > 0;
|
||||
var name1 = a.children[1].innerHTML.toLowerCase();
|
||||
var name2 = b.children[1].innerHTML.toLowerCase();
|
||||
|
||||
|
@ -422,8 +424,8 @@ function addQueueButtons(li) {
|
|||
var menu = $("<div/>").addClass("btn-group").appendTo(li);
|
||||
// Play
|
||||
if(hasPermission("playlistjump")) {
|
||||
$("<button/>").addClass("btn btn-mini qbtn-play")
|
||||
.html("<i class='icon-play'></i>Play")
|
||||
$("<button/>").addClass("btn btn-xs btn-default qbtn-play")
|
||||
.html("<span class='glyphicon glyphicon-play'></i>Play")
|
||||
.click(function() {
|
||||
socket.emit("jumpTo", li.data("uid"));
|
||||
})
|
||||
|
@ -431,8 +433,8 @@ function addQueueButtons(li) {
|
|||
}
|
||||
// Queue next
|
||||
if(hasPermission("playlistmove")) {
|
||||
$("<button/>").addClass("btn btn-mini qbtn-next")
|
||||
.html("<i class='icon-share-alt'></i>Queue Next")
|
||||
$("<button/>").addClass("btn btn-xs btn-default qbtn-next")
|
||||
.html("<span class='glyphicon glyphicon-share-alt'></i>Queue Next")
|
||||
.click(function() {
|
||||
socket.emit("moveMedia", {
|
||||
from: li.data("uid"),
|
||||
|
@ -444,8 +446,8 @@ function addQueueButtons(li) {
|
|||
// Temp/Untemp
|
||||
if(hasPermission("settemp")) {
|
||||
var tempstr = li.data("temp")?"Make Permanent":"Make Temporary";
|
||||
$("<button/>").addClass("btn btn-mini qbtn-tmp")
|
||||
.html("<i class='icon-flag'></i>" + tempstr)
|
||||
$("<button/>").addClass("btn btn-xs btn-default qbtn-tmp")
|
||||
.html("<span class='glyphicon glyphicon-flag'></i>" + tempstr)
|
||||
.click(function() {
|
||||
socket.emit("setTemp", {
|
||||
uid: li.data("uid"),
|
||||
|
@ -456,8 +458,8 @@ function addQueueButtons(li) {
|
|||
}
|
||||
// Delete
|
||||
if(hasPermission("playlistdelete")) {
|
||||
$("<button/>").addClass("btn btn-mini qbtn-delete")
|
||||
.html("<i class='icon-trash'></i>Delete")
|
||||
$("<button/>").addClass("btn btn-xs btn-default qbtn-delete")
|
||||
.html("<span class='glyphicon glyphicon-trash'></i>Delete")
|
||||
.click(function() {
|
||||
socket.emit("delete", li.data("uid"));
|
||||
})
|
||||
|
@ -522,6 +524,7 @@ function rebuildPlaylist() {
|
|||
/* menus */
|
||||
|
||||
/* user settings menu */
|
||||
// TODO fix this
|
||||
function showOptionsMenu() {
|
||||
hidePlayer();
|
||||
var modal = $("<div/>").addClass("modal hide fade")
|
||||
|
|
Loading…
Reference in a new issue