diff --git a/web/src/lib/favorites.js b/web/src/lib/favorites.js
index 8bdc015..16a8d42 100644
--- a/web/src/lib/favorites.js
+++ b/web/src/lib/favorites.js
@@ -1,8 +1,7 @@
-export async function AddFavorite() {
- let name = document.getElementById("name")?.value;
- let link = documnent.getElementById("link")?.value;
+export async function AddFavorite(token) {
+ let name = document.getElementById("name").value;
+ let link = document.getElementById("link").value;
let folder = document.getElementById("folder")?.value;
- let token = document.getElementById("token")?.token;
// Request
let route = `https://gerry.thetipo.rocks/favorites`
@@ -31,12 +30,9 @@ export async function AddFavorite() {
}
}
-export async function RemoveFavorite() {
- let name = document.getElementById("name")?.value;
- let token = document.getElementById("token")?.value;
-
+export async function RemoveFavorite(token, name) {
// Request
- let route = `https://gerry.thetipo.rocks/favorites`
+ let route = `https://gerry.thetipo.rocks/favorites` + new URLSearchParams({'name': name, 'token': token}).toString();
let response = await fetch(route, {
method: 'DELETE',
headers: {
@@ -60,26 +56,21 @@ export async function RemoveFavorite() {
}
}
-export async function GetFavorites() {
- let token = document.getElementById("token")?.value;
-
+export async function GetFavorites(token) {
// Request
- let route = `https://gerry.thetipo.rocks/favorites`
+ let route = `https://gerry.thetipo.rocks/favorites?` + new URLSearchParams({"token": token}).toString();
let response = await fetch(route, {
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
- body: {
- 'token': token,
- },
})
// Error Handling
switch(response.status) {
case 200:
- return 0;
+ return await response.json();
case 401:
return -1;
}
diff --git a/web/src/lib/queue.js b/web/src/lib/queue.js
index 9be1f27..1ea3cf7 100644
--- a/web/src/lib/queue.js
+++ b/web/src/lib/queue.js
@@ -1,18 +1,15 @@
// This file contains every function used in the queue.svelte component
-export async function AddToQueue() {
+export async function AddToQueue(GuildID, token) {
// Values needed for adding a song to a queue
- let GuildID = document.getElementById("id")?.value;
- let song = document.getElementById("song")?.value;
- let token = document.getElementById("token")?.value;
+ let song = document.getElementById("song").value;
let shuffle;
- let playlist = document.getElementById("playlist").value;
- let loop = document.getElementById("loop").value;
- let priority = document.getElementById("priority").value
+ let playlist = document.getElementById("playlist")?.checked;
+ let loop = document.getElementById("loop")?.checked;
+ let priority = document.getElementById("priority")?.checked
if(playlist) {
- shuffle = document.getElementById("shuffle").value;
+ shuffle = document.getElementById("shuffle")?.checked;
}
-
// Request
let route = `https://gerry.thetipo.rocks/queue/${GuildID}`
let response = await fetch(route, {
@@ -44,21 +41,15 @@ export async function AddToQueue() {
}
}
-export async function RemoveFromQueue() { // AKA skip
- let GuildID = document.getElementById("id")?.value;
- let clear = document.getElementById("clear")?.value;
-
+export async function RemoveFromQueue(GuildID, token, clear=false) { // AKA skip
// Request
- let route = `https://gerry.thetipo.rocks/queue/${GuildID}`
+ let route = `https://gerry.thetipo.rocks/queue/${GuildID}` + new URLSearchParams({'clean': clear, 'token': token}).toString();
let response = await fetch(route, {
method: "DELETE",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
- body: new URLSearchParams({
- 'clean': clear
- }).toString(),
})
// Error Handling
diff --git a/web/src/lib/song.js b/web/src/lib/song.js
index 4d3c2e4..8089aaa 100644
--- a/web/src/lib/song.js
+++ b/web/src/lib/song.js
@@ -1,22 +1,18 @@
-export async function ToggleSong(action = "") {
- let GuildID = document.getElementById("id").value;
- let token = document.getElementById("token").value;
+// This file contains a function used in the queue.svelte component
+export async function ToggleSong(GuildID, token, action = "") { // AKA Pause/Resume Song
// Request
- if(route === "") {
+ if(action === "") {
return -8
}
else {
- let route = `https://gerry.thetipo.rocks/song/${action}/${GuildID}`;
+ let route = `https://gerry.thetipo.rocks/song/${action}/${GuildID}?` + new URLSearchParams({"token": token}).toString();
let response = await fetch(route, {
method: "GET",
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
- body: {
- 'token': token,
- },
})
// Error Handling
diff --git a/web/src/routes/+layout.svelte b/web/src/routes/+layout.svelte
index da212a0..1dcadb7 100644
--- a/web/src/routes/+layout.svelte
+++ b/web/src/routes/+layout.svelte
@@ -3,3 +3,5 @@