This commit is contained in:
RochesterX
2025-11-28 19:40:43 -05:00
parent b1d604cdc2
commit 374ac4aff7
3 changed files with 8 additions and 4 deletions

View File

@@ -3,6 +3,10 @@ import { formatSalary } from "./utils.js";
const token = window.localStorage.getItem("token"); const token = window.localStorage.getItem("token");
if (!token) {
window.location.href = "/login";
}
const highest = document.querySelector("#highest"); const highest = document.querySelector("#highest");
updateHighest(); updateHighest();

View File

@@ -1 +1 @@
<meta http-equiv="refresh" content="0; url=/login"> <meta http-equiv="refresh" content="0; url=/home">

View File

@@ -29,7 +29,7 @@ updateIsWatched();
watchButton.onclick = async e => { watchButton.onclick = async e => {
e.preventDefault(); e.preventDefault();
const [, , id] = window.location.pathname.split("/"); const id = window.location.pathname.split("/")[2].replace("#", "");
const resultObject = await postData("/toggleWatched", { id: id }, token); const resultObject = await postData("/toggleWatched", { id: id }, token);
//alert(resultObject.message); //alert(resultObject.message);
updateIsWatched(); updateIsWatched();
@@ -43,14 +43,14 @@ showStatsButton.onclick = async e => {
} }
async function updateIsWatched() { async function updateIsWatched() {
const [, , id] = window.location.pathname.split("/"); const id = window.location.pathname.split("/")[2].replace("#", "");
const resultObject = await postData("/isWatched", {id: id}, token); const resultObject = await postData("/isWatched", {id: id}, token);
const isWatched = resultObject.isWatched; const isWatched = resultObject.isWatched;
watchButton.innerHTML = isWatched ? "Stop Watching Player" : "Watch Player"; watchButton.innerHTML = isWatched ? "Stop Watching Player" : "Watch Player";
} }
async function populatePlayerData() { async function populatePlayerData() {
const [, , id] = window.location.pathname.split("/"); const id = window.location.pathname.split("/")[2].replace("#", "");
let resultObject = await postData("/getPlayerStats", { let resultObject = await postData("/getPlayerStats", {
playerID: id playerID: id
}, token); }, token);