Delete all songs button added. DANGER

This commit is contained in:
Kasper Rynning-Tønnesen
2017-06-01 13:30:12 +02:00
parent 558deadd45
commit a85623dbbf
8 changed files with 67 additions and 7 deletions

View File

@@ -1538,7 +1538,7 @@ nav ul li:hover, nav ul li.active {
background-color: rgba(0,0,0,0.1); background-color: rgba(0,0,0,0.1);
} }
.change_user_pass:hover { .change_user_pass:hover, .delete-all:hover {
background-color: initial; background-color: initial;
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -38,6 +38,9 @@ var Admin = {
$('#chan_thumbnail').tooltip("remove"); $('#chan_thumbnail').tooltip("remove");
w_p = true; w_p = true;
break; break;
case "deleted_songs":
msg="All songs in the channel has been deleted!";
break;
case "shuffled": case "shuffled":
msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","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!"]); msg=Helper.rnd(["♫ You stir me right round, baby. ♫","♫ Stir, stir, stir my boat ♫","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; break;
@@ -123,6 +126,7 @@ var Admin = {
$("#password").val(""); $("#password").val("");
$("#password").attr("placeholder", "Change admin password"); $("#password").attr("placeholder", "Change admin password");
$(".user-password-li").removeClass("hide"); $(".user-password-li").removeClass("hide");
$(".delete-all").removeClass("hide");
if($(".password_protected").prop("checked")) { if($(".password_protected").prop("checked")) {
$(".change_user_pass").removeClass("hide"); $(".change_user_pass").removeClass("hide");
} }
@@ -206,6 +210,10 @@ var Admin = {
$(".user-password-li").addClass("hide") $(".user-password-li").addClass("hide")
} }
if(!$(".delete-all").hasClass("hide")) {
$(".delete-all").addClass("hide");
}
if($(".password_protected").prop("checked")) { if($(".password_protected").prop("checked")) {
$(".change_user_pass").removeClass("hide"); $(".change_user_pass").removeClass("hide");
} }

View File

@@ -1105,6 +1105,11 @@ $(document).on("click", ".close-user-password", function() {
} }
}); });
$(document).on("click", ".delete-all-songs", function(e){
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()))});
});
$(document).on("click", ".not-exported-container .not-exported-element #extra-export-container-text .extra-add-text", function(){ $(document).on("click", ".not-exported-container .not-exported-element #extra-export-container-text .extra-add-text", function(){
this.select(); this.select();
}); });

View File

@@ -32,10 +32,13 @@ var Player = {
if(!obj.np){ if(!obj.np){
document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!"; document.getElementById('song-title').innerHTML = "Empty channel. Add some songs!";
document.title = "Zoff - the shared YouTube based radio";
//$("#player_overlay").height($("#player").height()); //$("#player_overlay").height($("#player").height());
if(!window.MSStream && !chromecastAvailable) { if(!window.MSStream && !chromecastAvailable) {
$("#player_overlay").toggleClass("hide"); if($("#player_overlay").hasClass("hide")) {
$("#player_overlay").removeClass("hide");
}
} }
try{ try{
if(!chromecastAvailable) { if(!chromecastAvailable) {

View File

@@ -91,7 +91,6 @@
<input name="removeplay" type="checkbox" class="conf" /><span class="lever"></span> <input name="removeplay" type="checkbox" class="conf" /><span class="lever"></span>
<span class="right-span">Remove</span> <span class="right-span">Remove</span>
</label></div></li> </label></div></li>
<li class="user-password-li hide"><span class="switch-text"> <li class="user-password-li hide"><span class="switch-text">
Channel password Channel password
</span> </span>
@@ -103,6 +102,9 @@
<li class="change_user_pass hide"> <li class="change_user_pass hide">
<a href="#!" class="change_user_pass_btn btn waves-effect blue">Change password</a> <a href="#!" class="change_user_pass_btn btn waves-effect blue">Change password</a>
</li> </li>
<li class="delete-all hide">
<a href="#" class="delete-all-songs btn red">Delete all songs</a>
</li>
</ul> </ul>
</form> </form>
</div> </div>

View File

@@ -657,6 +657,44 @@ io.on('connection', function(socket){
} }
}); });
socket.on('delete_all', function(msg) {
if(typeof(msg) == 'object' && msg.hasOwnProperty('channel') && msg.hasOwnProperty('adminpass') && msg.hasOwnProperty('pass')) {
var hash = hash_pass(decrypt_string(socketid, msg.adminpass));
var hash_userpass = decrypt_string(socketid, msg.pass);
if(coll !== undefined) {
try {
coll = msg.channel;
if(coll.length == 0) return;
coll = emojiStrip(coll).toLowerCase();
//coll = decodeURIComponent(coll);
coll = coll.replace("_", "");
coll = encodeURIComponent(coll).replace(/\W/g, '');
coll = filter.clean(coll);
} catch(e) {
return;
}
}
db.collection(coll).find({views: {$exists: true}}, function(err, conf) {
if(conf.length == 1 && conf) {
conf = conf[0];
if(conf.adminpass == hash && conf.adminpass != "" && ((conf.userpass != "" || (conf.userpass == hash_userpass)))) {
db.collection(coll).remove({views: {$exists: false}}, {multi: true}, function(err, succ) {
send_list(coll, false, true, true, true);
socket.emit("toast", "deleted_songs");
});
} else {
socket.emit("toast", "listhaspass");
}
}
});
} else {
socket.emit("update_required");
return;
}
})
socket.on('vote', function(msg) socket.on('vote', function(msg)
{ {
if(typeof(msg) === 'object' && msg !== undefined && msg !== null) if(typeof(msg) === 'object' && msg !== undefined && msg !== null)
@@ -1533,8 +1571,12 @@ function send_play(coll, socket)
socket.emit("np", toSend); socket.emit("np", toSend);
} }
} }
}catch(e){ } catch(e){
socket.emit("np", {}); if(socket) {
socket.emit("np", {});
} else {
io.to(coll).emit("np", {});
}
} }
}); });
}); });