Paydirt
This commit is contained in:
@@ -10,7 +10,28 @@ const tableBody = document.getElementById("results");
|
||||
const table = document.getElementById("table");
|
||||
const nomatch = document.getElementById("nomatch");
|
||||
|
||||
const watchButton = document.querySelector("#watch");
|
||||
|
||||
//const watchlist = await postData("/getWatchlist", {}, token);
|
||||
|
||||
populatePlayerData();
|
||||
updateIsWatched();
|
||||
|
||||
watchButton.onclick = async e => {
|
||||
e.preventDefault();
|
||||
|
||||
const [, , id] = window.location.pathname.split("/");
|
||||
const resultObject = await postData("/toggleWatched", { id: id }, token);
|
||||
alert(resultObject.message);
|
||||
updateIsWatched();
|
||||
}
|
||||
|
||||
async function updateIsWatched() {
|
||||
const [, , id] = window.location.pathname.split("/");
|
||||
const resultObject = await postData("/isWatched", {id: id}, token);
|
||||
const isWatched = resultObject.isWatched;
|
||||
watchButton.innerHTML = isWatched ? "Stop Watching Player" : "Watch Player";
|
||||
}
|
||||
|
||||
async function populatePlayerData() {
|
||||
const [, , id] = window.location.pathname.split("/");
|
||||
|
||||
Reference in New Issue
Block a user