Added a "clear playlist" admin function on the client
This commit is contained in:
parent
6a04ac30f5
commit
1e1eac4aa4
3 changed files with 28 additions and 2 deletions
|
|
@ -102,6 +102,11 @@ changes visibility with JS-->
|
|||
<input type="checkbox" title="volumechangecheck" id="volumechangesettingcheckbox"><label for="volumechangesettingcheckbox">Change volume</label><br>
|
||||
</div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<h2>Clear the playlist</h2>
|
||||
<p class="italic" title="With PartyMode enabled, the second song will be added back randomly">Wipe the playlist, except the currently playing song*</p>
|
||||
<button id="clear-button">Clear Playlist</button>
|
||||
</div>
|
||||
<p class="versionNumber">PartyJukebox is under an <a href="https://github.com/kristy-fournier/PartyJukebox/blob/main/LICENSE.md">AGPLV3</a> liscense. You can access the source code <a href=https://github.com/kristy-fournier/PartyJukebox>here</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -411,6 +411,16 @@ async function submitPerms(e) {
|
|||
}
|
||||
}
|
||||
|
||||
async function clearPlaylist() {
|
||||
let returncode = await getFromServer({control:"clear"},"controls");
|
||||
if(returncode == ERR_NO_ADMIN || returncode == null) {
|
||||
// alertText("Admin Restricted ")
|
||||
// there's an admin restrict alert built into getFromServer
|
||||
} else {
|
||||
alertText("Playlist Cleared!");
|
||||
}
|
||||
}
|
||||
|
||||
let optionslist = []
|
||||
|
||||
//sets all de stuff for buttons
|
||||
|
|
@ -427,7 +437,8 @@ document.getElementById("volumerange").onchange = async function() {
|
|||
// FIX THIS
|
||||
let returnValue = await getFromServer({setting:"volume",level:this.value}, "settings")
|
||||
if (returnValue == ERR_NO_ADMIN) {
|
||||
alertText("Error: Admin restricted action");
|
||||
// alertText("Error: Admin restricted action");
|
||||
// there's an admin restrict alert built into getFromServer
|
||||
} else if (returnValue["volumePassed"] !=0) {
|
||||
// i forgot about this, i had to do this because it confused the crap out of me one time
|
||||
// vlc doesn't let you change the volume of nothing, which makes sense if you think about it
|
||||
|
|
@ -441,6 +452,8 @@ document.getElementById("volumerange").onchange = async function() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//bit of a cheat code for clearing the alerts when they don't clear normally
|
||||
document.getElementById("title").addEventListener('click',function(){document.getElementById("alert").innerHTML = ""})
|
||||
document.getElementById("settings-button").addEventListener('click',function(){controlButton("st")});
|
||||
|
|
@ -455,6 +468,8 @@ document.getElementById("alerttimetextbox").addEventListener('keydown', function
|
|||
document.getElementById("adminpasswordbox").addEventListener('keydown',function(e){adminPassEnter(e)});
|
||||
document.getElementById("admincheckholder").addEventListener('click',function(e){submitPerms(e)});
|
||||
document.getElementById("partymode-button").addEventListener('click',function(){controlButton("pm")})
|
||||
document.getElementById("darkmode-button").addEventListener('click',function(){toggleDark()})
|
||||
document.getElementById("clear-button").addEventListener('click',function(){clearPlaylist()})
|
||||
//sets the fact that clicking a song needs to return its id to the function to find it
|
||||
document.getElementById("songlist").addEventListener('keydown', function(e){checkWhatSongWasClicked(e)});
|
||||
document.getElementById("songlist").addEventListener('click', function(e){checkWhatSongWasClicked(e)});
|
||||
|
|
@ -462,7 +477,6 @@ document.getElementById("songlist").addEventListener('click', function(e){checkW
|
|||
//makes the controls look mostly normal on all screens, best solution i could find, idk man
|
||||
let tempWidth = document.getElementById('controls').clientWidth;
|
||||
document.getElementById("controls").style.marginLeft = "-"+String(parseInt(tempWidth/2))+"px";
|
||||
document.getElementById("darkmode-button").addEventListener('click',function(){toggleDark()})
|
||||
|
||||
//for my use case (my immediate family), they dont know how to set an ip
|
||||
//using this allows the creator of the link for, a qr code for example, to set the ip before distributing the code, and it would all work smoothly
|
||||
|
|
|
|||
|
|
@ -117,6 +117,13 @@ def playerControls():
|
|||
return "200"
|
||||
else:
|
||||
return ERR_NO_ADMIN
|
||||
elif recieveData["control"] == "clear":
|
||||
if ADMIN_PASS == recieveData['password']: # this is only ever allowed with the adminpassword
|
||||
with playlistLock:
|
||||
playlist.clear()
|
||||
return "200"
|
||||
else:
|
||||
return ERR_NO_ADMIN
|
||||
else:
|
||||
return "400"
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue