From 9447c2ff15a862b522d45fb36d3f98c9943ec48a Mon Sep 17 00:00:00 2001 From: "Nicolas A. Tonne" Date: Sun, 26 Apr 2015 16:54:46 +0200 Subject: [PATCH] Moar toasts, log out button --- php/panel.php | 65 +------------------------------------------- static/css/style.css | 11 +++++--- static/js/admin.js | 42 +++++++++++++++++++++------- 3 files changed, 40 insertions(+), 78 deletions(-) diff --git a/php/panel.php b/php/panel.php index 9751dafb..f83a73e6 100755 --- a/php/panel.php +++ b/php/panel.php @@ -14,7 +14,7 @@
  • - +
    @@ -107,66 +107,3 @@
  • - - - - - diff --git a/static/css/style.css b/static/css/style.css index 68e4575b..9c06b2d7 100755 --- a/static/css/style.css +++ b/static/css/style.css @@ -324,6 +324,7 @@ hide mdi-action-visibility mdi-action-visibility-off } .vote-span{ + opacity: 0.7; padding: 0 0 0 10px; } @@ -427,6 +428,12 @@ hide mdi-action-visibility mdi-action-visibility-off background-color:white !important; } +#admin-lock +{ + position:absolute; +} + + /************** Youtube controls **************/ @@ -547,7 +554,3 @@ hide mdi-action-visibility mdi-action-visibility-off transition: width 1s ease;*/ } -.mdi-action-lock -{ - position:absolute; -} diff --git a/static/js/admin.js b/static/js/admin.js index 2042919b..4db68a92 100755 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -7,31 +7,31 @@ socket.on("toast", function(msg) pass_corr = "correct"; switch(msg) { case "savedsettings": - msg="I saved your settings" + msg=rnd(["I've saved your settings", "I stored all your settings", "Your settings have been stored in a safe place"]) break; case "wrongpass": - msg="That's not the right password!" + msg=rnd(["That's not the right password!", "Wrong! Better luck next time...", "You seem to have mistyped the password", "Incorrect. Have you tried meditating?","Nope, wrong password!", "Wrong password. The authorities have been notified."]) break; case "shuffled": - msg="I vigorously stirred your playlist!" + msg=rnd(["I vigorously stirred your playlist!", "I hope you like your list stirred, not shaken.", "I shuffled your playlist with the cosmic background radiation as a seed. Enjoy.", "100% randomized, for your listening pleasure!", "I hope you enjoy your fresh playlist!"]) break; case "deletesong": - msg="Your song is now in a better place..." + msg=rnd(["Your song is now in a better place...", "You won't be seeing any more of that video...", "EXTERMINATE! EXTERMINATE! EXTERMINATE!", "I killed it with fire", "Thanks for deleting that song. I didn't like it anyways...", "Removed song securely."]) break; case "voted": - msg="You voted!" + msg=rnd(["You voted!", "You vote like a boss", "Voting is the key to democracy", "May you get your song to the very top!", "I love that song! I vouch for you.", "Only you vote that good", "I like the way you vote...", "Up the video goes!", "Voted Zöff for president", "Only 999 more to go!"]) break; case "alreadyvoted": - msg="You can't vote twice on that song!" + msg=rnd(["You can't vote twice on that song!", "I see you have voted on that song before", "One vote per person!", "I know you want to hear your song, but have patience!", "I'm sorry, but I can't let you vote twice, Dave."]) break; case "listhaspass": - msg="I'm sorry, but you have to be an admin to do that!" + msg=rnd(["I'm sorry, but you have to be an admin to do that!", "Only admins can do that", "You're not allowed to do that, try logging in!", "I can't let you do that", "Please log in to do that"]) break; case "noskip": - msg="Only Admins can skip songs, peasant!" + msg=rnd(["Only Admins can skip songs, peasant!", "You have to log in to skip songs on this channel", "Try clicking the settings icon and logging in before you skip"]) break; case "alreadyskip": - msg="Skipping is democratic, only one vote per person!" + msg=rnd(["Skipping is democratic, only one vote per person!", "More people have to vote to skip, not just you!", "Get someone else to skip too! You can't do it on yourself."]) break; } Materialize.toast(msg, 4000); @@ -48,7 +48,8 @@ socket.on("pw", function(msg) $(".card-action").removeClass("hide"); refresh_scroll(); - + $("#admin-lock").removeClass("mdi-action-lock"); + $("#admin-lock").addClass("mdi-action-lock-open clickable"); localStorage.setItem(chan.toLowerCase(), msg); Materialize.toast("Correct password. You now have access to the sacred realm of The Admin.", 4000); }); @@ -68,6 +69,22 @@ function pass_save() socket.emit('password', document.getElementById("password").value); } +function log_out(){ + if(localStorage[chan.toLowerCase()]){ + localStorage.removeItem(chan.toLowerCase()) + w_p = false; + names=["vote","addsongs","longsongs","frontpage", "allvideos", "removeplay", "skip", "shuffle"]; + for (var i = 0; i < names.length; i++) { + $("input[name="+names[i]+"]").attr("disabled", true); + } + $("#admin-lock").addClass("mdi-action-lock"); + $("#admin-lock").removeClass("mdi-action-lock-open clickable"); + Materialize.toast("Logged out", 4000); + }else{ + Materialize.toast("Not logged in", 4000); + } +} + //function used in html onlick function save(){ submitAdmin(document.getElementById("adminForm").elements); @@ -110,3 +127,8 @@ function shuffle() console.log(adminpass); socket.emit('shuffle', adminpass); } + +function rnd(arr) +{ + return arr[Math.floor(Math.random() * arr.length)]; +} \ No newline at end of file