From 374ac4aff742e514174313398b8f017bbd4efdd0 Mon Sep 17 00:00:00 2001 From: RochesterX Date: Fri, 28 Nov 2025 19:40:43 -0500 Subject: [PATCH] # --- public/home.js | 4 ++++ public/index.html | 2 +- public/player.js | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/public/home.js b/public/home.js index d9df785..dacb45d 100644 --- a/public/home.js +++ b/public/home.js @@ -3,6 +3,10 @@ import { formatSalary } from "./utils.js"; const token = window.localStorage.getItem("token"); +if (!token) { + window.location.href = "/login"; +} + const highest = document.querySelector("#highest"); updateHighest(); diff --git a/public/index.html b/public/index.html index 7a166ac..11aff87 100644 --- a/public/index.html +++ b/public/index.html @@ -1 +1 @@ - + diff --git a/public/player.js b/public/player.js index 6489156..c853476 100644 --- a/public/player.js +++ b/public/player.js @@ -29,7 +29,7 @@ updateIsWatched(); watchButton.onclick = async e => { e.preventDefault(); - const [, , id] = window.location.pathname.split("/"); + const id = window.location.pathname.split("/")[2].replace("#", ""); const resultObject = await postData("/toggleWatched", { id: id }, token); //alert(resultObject.message); updateIsWatched(); @@ -43,14 +43,14 @@ showStatsButton.onclick = async e => { } 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 isWatched = resultObject.isWatched; watchButton.innerHTML = isWatched ? "Stop Watching Player" : "Watch Player"; } async function populatePlayerData() { - const [, , id] = window.location.pathname.split("/"); + const id = window.location.pathname.split("/")[2].replace("#", ""); let resultObject = await postData("/getPlayerStats", { playerID: id }, token);