mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Added a try-again for commands with password if there exists an adminass saved
This commit is contained in:
@@ -61,6 +61,19 @@ var Admin = {
|
|||||||
msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]);
|
msg=Helper.rnd(["The song was skipped", "I have skipped a song", "Skipped to the beat", "Skipmaster3000", "They see me skippin', they hatin'"]);
|
||||||
break;
|
break;
|
||||||
case "listhaspass":
|
case "listhaspass":
|
||||||
|
if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
|
||||||
|
if(Crypt.get_pass() != undefined) {
|
||||||
|
tried_again = true;
|
||||||
|
if(lastCommand.length == 1) {
|
||||||
|
socket.emit(lastCommand[0]);
|
||||||
|
} else if(lastCommand.length == 2) {
|
||||||
|
socket.emit(lastCommand[0], lastCommand[1]);
|
||||||
|
}
|
||||||
|
lastCommand = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tried_again = false;
|
||||||
msg=Helper.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"]);
|
msg=Helper.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"]);
|
||||||
Crypt.remove_pass(chan.toLowerCase());
|
Crypt.remove_pass(chan.toLowerCase());
|
||||||
Admin.display_logged_out();
|
Admin.display_logged_out();
|
||||||
@@ -80,6 +93,19 @@ var Admin = {
|
|||||||
$("#import").removeClass("hide");
|
$("#import").removeClass("hide");
|
||||||
break;
|
break;
|
||||||
case "noskip":
|
case "noskip":
|
||||||
|
if(!tried_again && lastCommand != undefined && lastCommand.length > 0) {
|
||||||
|
if(Crypt.get_pass() != undefined) {
|
||||||
|
tried_again = true;
|
||||||
|
if(lastCommand.length == 1) {
|
||||||
|
socket.emit(lastCommand[0]);
|
||||||
|
} else if(lastCommand.length == 2) {
|
||||||
|
socket.emit(lastCommand[0], lastCommand[1]);
|
||||||
|
}
|
||||||
|
lastCommand = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tried_again = false;
|
||||||
msg=Helper.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"]);
|
msg=Helper.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;
|
break;
|
||||||
case "alreadyskip":
|
case "alreadyskip":
|
||||||
@@ -89,6 +115,7 @@ var Admin = {
|
|||||||
msg="Skipping is disabled the first 10 seconds.";
|
msg="Skipping is disabled the first 10 seconds.";
|
||||||
break;
|
break;
|
||||||
case "correctpass":
|
case "correctpass":
|
||||||
|
tried_again = false;
|
||||||
adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.tmp_pass : Crypt.get_pass(chan.toLowerCase());
|
adminpass = Crypt.get_pass(chan.toLowerCase()) == undefined ? Crypt.tmp_pass : Crypt.get_pass(chan.toLowerCase());
|
||||||
msg="Correct password. You now have access to the sacred realm of The Admin.";
|
msg="Correct password. You now have access to the sacred realm of The Admin.";
|
||||||
$("#thumbnail_form").css("display", "inline-block");
|
$("#thumbnail_form").css("display", "inline-block");
|
||||||
@@ -172,16 +199,16 @@ var Admin = {
|
|||||||
}
|
}
|
||||||
Admin.set_conf(msg[0]);
|
Admin.set_conf(msg[0]);
|
||||||
if(msg[0].adminpass !== "" && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Admin.beginning && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
if(msg[0].adminpass !== "" && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Admin.beginning && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
||||||
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
||||||
Admin.beginning = false;
|
Admin.beginning = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pass_save: function() {
|
pass_save: function() {
|
||||||
if(!w_p) {
|
if(!w_p) {
|
||||||
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase(), oldpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
socket.emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
emit('password', {password: Crypt.crypt_pass(CryptoJS.SHA256(document.getElementById("password").value).toString()), channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -329,7 +356,7 @@ var Admin = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
|
Crypt.set_userpass(chan.toLowerCase(), CryptoJS.SHA256(userpass).toString());
|
||||||
socket.emit("conf", configs);
|
emit("conf", configs);
|
||||||
},
|
},
|
||||||
|
|
||||||
hide_settings: function() {
|
hide_settings: function() {
|
||||||
@@ -338,7 +365,7 @@ var Admin = {
|
|||||||
|
|
||||||
shuffle: function() {
|
shuffle: function() {
|
||||||
if(!offline) {
|
if(!offline) {
|
||||||
socket.emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit('shuffle', {adminpass: adminpass !== undefined ? Crypt.crypt_pass(adminpass) : "", channel: chan.toLowerCase(), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
for(var x = 0; x < full_playlist.length; x++){
|
for(var x = 0; x < full_playlist.length; x++){
|
||||||
var num = Math.floor(Math.random()*1000000);
|
var num = Math.floor(Math.random()*1000000);
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ function chromecastListener(evt, data) {
|
|||||||
if(offline){
|
if(offline){
|
||||||
Player.playNext();
|
Player.playNext();
|
||||||
} else {
|
} else {
|
||||||
socket.emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit("skip", {error: json_parsed.data_code, id: json_parsed.videoId, pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -370,6 +370,18 @@ function change_offline(enabled, already_offline){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emit() {
|
||||||
|
lastCommand = [];
|
||||||
|
for(var i = 0; i < arguments.length; i++) {
|
||||||
|
lastCommand.push(arguments[i]);
|
||||||
|
}
|
||||||
|
if(arguments.length == 1) {
|
||||||
|
socket.emit(arguments[0]);
|
||||||
|
} else {
|
||||||
|
socket.emit(arguments[0], arguments[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function before_toast(){
|
function before_toast(){
|
||||||
if($('.toast').length > 0) {
|
if($('.toast').length > 0) {
|
||||||
var toastElement = $('.toast').first()[0];
|
var toastElement = $('.toast').first()[0];
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ var List = {
|
|||||||
|
|
||||||
vote: function(id, vote) {
|
vote: function(id, vote) {
|
||||||
if(!offline || (vote == "del" && (hasadmin && (!w_p && adminpass != "")))){
|
if(!offline || (vote == "del" && (hasadmin && (!w_p && adminpass != "")))){
|
||||||
socket.emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit('vote', {channel: chan, id: id, type: vote, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
if(vote == "pos"){
|
if(vote == "pos"){
|
||||||
List.voted_song(id, (new Date()).getTime()/1000);
|
List.voted_song(id, (new Date()).getTime()/1000);
|
||||||
@@ -548,7 +548,7 @@ var List = {
|
|||||||
|
|
||||||
skip: function(way) {
|
skip: function(way) {
|
||||||
if(!offline){
|
if(!offline){
|
||||||
socket.emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit('skip', {pass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), id:video_id, channel: chan.toLowerCase(), userpass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
} else {
|
} else {
|
||||||
if(way) {
|
if(way) {
|
||||||
Player.playNext();
|
Player.playNext();
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ var was_stopped = false;
|
|||||||
var timed_remove_check;
|
var timed_remove_check;
|
||||||
var slider_type = "horizontal";
|
var slider_type = "horizontal";
|
||||||
var programscroll = false;
|
var programscroll = false;
|
||||||
|
var lastCommand;
|
||||||
|
var tried_again = false;
|
||||||
var userscroll = false;
|
var userscroll = false;
|
||||||
var gotten_np = false;
|
var gotten_np = false;
|
||||||
var frontpage = 1;
|
var frontpage = 1;
|
||||||
@@ -186,7 +188,7 @@ $().ready(function(){
|
|||||||
socket.emit("offline", {status: true, channel: chan != undefined ? chan.toLowerCase() : ""});
|
socket.emit("offline", {status: true, channel: chan != undefined ? chan.toLowerCase() : ""});
|
||||||
}
|
}
|
||||||
if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
if(chan != undefined && (Crypt.get_pass(chan.toLowerCase()) !== undefined && Crypt.get_pass(chan.toLowerCase()) !== "")){
|
||||||
socket.emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
emit("password", {password: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), channel: chan.toLowerCase()});
|
||||||
}
|
}
|
||||||
if(chan != undefined && conf_arr.name !== undefined && conf_arr.name !== "" && conf_arr.chat_pass !== undefined && conf_arr.chat_pass !== ""){
|
if(chan != undefined && conf_arr.name !== undefined && conf_arr.name !== "" && conf_arr.chat_pass !== undefined && conf_arr.chat_pass !== ""){
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@@ -366,7 +368,7 @@ $(document).on("click", ".pagination-results a", function(e) {
|
|||||||
|
|
||||||
$(document).on("click", ".accept-delete", function(e) {
|
$(document).on("click", ".accept-delete", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit("delete_all", {channel: chan.toLowerCase(), adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit("delete_all", {channel: chan.toLowerCase(), adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
$("#delete_song_alert").modal("close");
|
$("#delete_song_alert").modal("close");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -459,13 +461,13 @@ $(document).on("click", "#offline-mode", function(e){
|
|||||||
|
|
||||||
$(document).on("submit", "#thumbnail_form", function(e){
|
$(document).on("submit", "#thumbnail_form", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit("suggest_thumbnail", {channel: chan, thumbnail: $("#chan_thumbnail").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
$("#chan_thumbnail").val("");
|
$("#chan_thumbnail").val("");
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("submit", "#description_form", function(e){
|
$(document).on("submit", "#description_form", function(e){
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
socket.emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit("suggest_description", {channel: chan, description: $("#chan_description").val(), adminpass: Crypt.crypt_pass(Crypt.get_pass(chan.toLowerCase())), pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
$("#chan_description").val("");
|
$("#chan_description").val("");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ var Search = {
|
|||||||
List.vote(id, "pos");
|
List.vote(id, "pos");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
socket.emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
emit("add", {id: id, start: start, end: end, title: title, adminpass: adminpass == "" ? "" : Crypt.crypt_pass(adminpass), list: chan.toLowerCase(), duration: duration, playlist: playlist, num: num, total: full_num, pass: embed ? '' : Crypt.crypt_pass(Crypt.get_userpass(chan.toLowerCase()))});
|
||||||
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
}//[id, decodeURIComponent(title), adminpass, duration, playlist]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user