From 6a2e7bb9e2bd6c5da1b17fb636d3645f5bf46bc5 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Sat, 21 Sep 2013 02:22:51 -0500 Subject: [PATCH] Quick buttons for modflair and adminflair --- changelog | 5 +++++ www/assets/css/ytsync.css | 4 ++++ www/assets/js/ui.js | 45 ++++++++++++++++++++++++++++++++------- www/assets/js/util.js | 11 ++++++++++ www/channel.html | 8 ++++--- 5 files changed, 62 insertions(+), 11 deletions(-) diff --git a/changelog b/changelog index 03e22a91..27a6e6ab 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +Sat Sep 21 02:21 2013 CDT + * www/assets/js/ui.js, www/assets/js/ui.js, www/assets/js/util.js, + www/channel.html, www/assets/css/ytsync.css: Add quick buttons for + modflair and adminflair + Sat Sep 21 00:29 2013 CDT * www/assets/js/util.js: support a "Nobody" permission level (set arbitrarily high) diff --git a/www/assets/css/ytsync.css b/www/assets/css/ytsync.css index 0d74151e..b0f546a6 100644 --- a/www/assets/css/ytsync.css +++ b/www/assets/css/ytsync.css @@ -360,3 +360,7 @@ body { #ytapiplayer, #ytapiplayer > iframe { border: none; } + +#adminflair { + margin-left: 3px; +} diff --git a/www/assets/js/ui.js b/www/assets/js/ui.js index 4e9aa08e..997d5eb9 100644 --- a/www/assets/js/ui.js +++ b/www/assets/js/ui.js @@ -38,7 +38,8 @@ function generateToggle(chevron, div) { } /* setup show/hide toggles */ -generateToggle("#usercountwrap", "#userlist"); +generateToggle("#usercount", "#userlist"); +generateToggle("#userlisttoggle", "#userlist"); $("#usercountwrap").click(scrollChat); generateToggle("#librarytoggle", "#librarywrap"); generateToggle("#userpltoggle", "#userplaylistwrap"); @@ -69,14 +70,40 @@ $("#logout").click(function() { /* chatbox */ -$("#usercountwrap").mouseenter(function (ev) { +$("#modflair").click(function () { + var m = $("#modflair"); + if (m.hasClass("label-success")) { + USEROPTS.modhat = false; + m.removeClass("label-success") + .addClass("label-default"); + } else { + USEROPTS.modhat = true; + m.removeClass("label-default") + .addClass("label-success"); + } +}); + +$("#adminflair").click(function () { + var m = $("#adminflair"); + if (m.hasClass("label-important")) { + USEROPTS.adminhat = false; + m.removeClass("label-important") + .addClass("label-default"); + } else { + USEROPTS.adminhat = true; + m.removeClass("label-default") + .addClass("label-important"); + } +}); + +$("#usercount").mouseenter(function (ev) { var breakdown = calcUserBreakdown(); // re-using profile-box class for convenience var popup = $("
") .addClass("profile-box") .css("top", (ev.pageY + 5) + "px") .css("left", (ev.pageX) + "px") - .appendTo($("#usercountwrap")); + .appendTo($("#usercount")); var contents = ""; for(var key in breakdown) { @@ -87,8 +114,8 @@ $("#usercountwrap").mouseenter(function (ev) { popup.html(contents); }); -$("#usercountwrap").mousemove(function (ev) { - var popup = $("#usercountwrap").find(".profile-box"); +$("#usercount").mousemove(function (ev) { + var popup = $("#usercount").find(".profile-box"); if(popup.length == 0) return; @@ -96,8 +123,8 @@ $("#usercountwrap").mousemove(function (ev) { popup.css("left", (ev.pageX) + "px"); }); -$("#usercountwrap").mouseleave(function () { - $("#usercountwrap").find(".profile-box").remove(); +$("#usercount").mouseleave(function () { + $("#usercount").find(".profile-box").remove(); }); $("#messagebuffer").mouseenter(function() { SCROLLCHAT = false; }); @@ -107,7 +134,9 @@ $("#chatline").keydown(function(ev) { if(ev.keyCode == 13) { var msg = $("#chatline").val(); if(msg.trim()) { - if(USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) { + if (USEROPTS.adminhat && CLIENT.rank >= 255) { + msg = "/a " + msg; + } else if(USEROPTS.modhat && CLIENT.rank >= Rank.Moderator) { msg = "/m " + msg; } socket.emit("chatMsg", { diff --git a/www/assets/js/util.js b/www/assets/js/util.js index f6c15f71..a4cad014 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -798,6 +798,14 @@ function applyOpts() { } }); } + + if (USEROPTS.modhat) { + $("#modflair").removeClass("label-default") + .addClass("label-success"); + } else { + $("#modflair").removeClass("label-success") + .addClass("label-default"); + } } applyOpts(); @@ -1039,6 +1047,9 @@ function handlePermissionChange() { setVisible("#userpltogglewrap", CLIENT.rank >= 1); + setVisible("#modflair", CLIENT.rank >= 2); + setVisible("#adminflair", CLIENT.rank >= 255); + setVisible("#playlisttogglewrap", hasPermission("playlistadd")); $("#queue_next").attr("disabled", !hasPermission("playlistnext")); $("#qlockbtn").attr("disabled", CLIENT.rank < 2); diff --git a/www/channel.html b/www/channel.html index d57b04b2..c67498cb 100644 --- a/www/channel.html +++ b/www/channel.html @@ -64,9 +64,11 @@
-
- -

Not connected

+
+ + Not connected + +