removed broken timer, finalised new responses
This commit is contained in:
parent
417ecc8ced
commit
2002dd1afa
1 changed files with 7 additions and 8 deletions
|
|
@ -47,21 +47,24 @@ async function getFromServer(bodyInfo, source="",password=adminPass) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = await response.json();
|
let data = await response.json(); // original json
|
||||||
if (response.status == ERR_NO_ADMIN) {
|
if (response.status == ERR_NO_ADMIN) {
|
||||||
// im suprised i didn't comment on this already but this is kinda lame desing
|
// im suprised i didn't comment on this already but this is kinda lame desing
|
||||||
// its not wrong but you know
|
// its not wrong but you know
|
||||||
// it is easy which i like
|
// it is easy which i like
|
||||||
// and it overrides any other non-async alerts which is nice
|
// and it overrides any other non-async alerts which is nice
|
||||||
alertText("Error: Admin restricted action")
|
alertText("Error: Admin restricted action")
|
||||||
} else if(response.status !== 200){
|
} else if(!response.ok){
|
||||||
alertText("Error: "+data.error);
|
alertText("Error: "+data.error);
|
||||||
}
|
}
|
||||||
|
// we add some information from the response just in case it is needed
|
||||||
|
data["ok"] = response.ok;
|
||||||
data["status"] = response.status;
|
data["status"] = response.status;
|
||||||
|
// console.log(data);
|
||||||
return await data;
|
return await data;
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("error print here:");
|
// console.log("error print here:");
|
||||||
console.log(e);
|
// console.log(e);
|
||||||
if (e == "TypeError: Failed to fetch"){
|
if (e == "TypeError: Failed to fetch"){
|
||||||
alertText("Error: Can't Connect to Server (is the ip set?)")
|
alertText("Error: Can't Connect to Server (is the ip set?)")
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -91,7 +94,6 @@ function getCookie(cname) {
|
||||||
}
|
}
|
||||||
//someone more organised than me would have set all these html elements to variables so they dont have to get them 50 times
|
//someone more organised than me would have set all these html elements to variables so they dont have to get them 50 times
|
||||||
// also someone who likes things not being dumb more than me would have separated the client and server buttons
|
// also someone who likes things not being dumb more than me would have separated the client and server buttons
|
||||||
let timer = null;
|
|
||||||
async function controlButton(buttonType) {
|
async function controlButton(buttonType) {
|
||||||
if (buttonType == "pp") { // Play-Pause button
|
if (buttonType == "pp") { // Play-Pause button
|
||||||
getFromServer({control: "play-pause"}, "controls")
|
getFromServer({control: "play-pause"}, "controls")
|
||||||
|
|
@ -106,9 +108,6 @@ async function controlButton(buttonType) {
|
||||||
document.getElementById("playlist-mode").style.display = "block";
|
document.getElementById("playlist-mode").style.display = "block";
|
||||||
document.getElementById("songlist-mode").style.display = "none";
|
document.getElementById("songlist-mode").style.display = "none";
|
||||||
document.getElementById("settings-mode").style.display = "none";
|
document.getElementById("settings-mode").style.display = "none";
|
||||||
timer = setInterval(() => {
|
|
||||||
|
|
||||||
})
|
|
||||||
generateVisualPlaylist();
|
generateVisualPlaylist();
|
||||||
} else if (buttonType == "se") { //SearchMode button
|
} else if (buttonType == "se") { //SearchMode button
|
||||||
document.getElementById("songlist").innerHTML = "<h1>Search to find songs!</h1>";
|
document.getElementById("songlist").innerHTML = "<h1>Search to find songs!</h1>";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue