From afff414aad0d28b997b75ec6da0466f502af2c58 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 18 Dec 2013 23:50:19 -0500 Subject: [PATCH] Continue work on clientside --- templates/channel.jade | 1 + www/assets/js/callbacks.js | 95 +++++++++----------------------------- www/assets/js/util.js | 45 +++++++++--------- 3 files changed, 47 insertions(+), 94 deletions(-) diff --git a/templates/channel.jade b/templates/channel.jade index 084c0951..a453015a 100644 --- a/templates/channel.jade +++ b/templates/channel.jade @@ -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") diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 5f069945..a420032a 100644 --- a/www/assets/js/callbacks.js +++ b/www/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 = $("
") .addClass("userlist_item"); - var flair = $("").appendTo(div); + var icon = $("").appendTo(div); var nametag = $("").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); - $("