From 74f6cd63f46afba7fc6fcf76976e36753e8d37c1 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 16 Dec 2023 10:35:45 +0000 Subject: [PATCH] other JS changes --- src/main/resources/static/js/darkmode.js | 11 +++++++---- src/main/resources/static/js/githubVersion.js | 11 +++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/resources/static/js/darkmode.js b/src/main/resources/static/js/darkmode.js index 066a0d69..d3c62266 100644 --- a/src/main/resources/static/js/darkmode.js +++ b/src/main/resources/static/js/darkmode.js @@ -140,8 +140,11 @@ document.addEventListener("DOMContentLoaded", function () { setMode("off") } - document.getElementById("dark-mode-toggle").addEventListener("click", function (event) { - event.preventDefault() - toggleDarkMode() - }) + var darkModeToggle = document.getElementById("dark-mode-toggle"); + if (darkModeToggle !== null) { + darkModeToggle.addEventListener("click", function (event) { + event.preventDefault(); + toggleDarkMode(); + }); + } }) diff --git a/src/main/resources/static/js/githubVersion.js b/src/main/resources/static/js/githubVersion.js index f2eb2f52..0fddc3ef 100644 --- a/src/main/resources/static/js/githubVersion.js +++ b/src/main/resources/static/js/githubVersion.js @@ -31,7 +31,11 @@ async function getLatestReleaseVersion() { async function checkForUpdate() { // Initialize the update button as hidden - document.getElementById("update-btn").style.display = "none"; + var updateBtn = document.getElementById("update-btn"); + if (updateBtn !== null) { + updateBtn.style.display = "none"; + } + const latestVersion = await getLatestReleaseVersion(); console.log("latestVersion=" + latestVersion) @@ -45,4 +49,7 @@ async function checkForUpdate() { } } -checkForUpdate(); \ No newline at end of file + +document.addEventListener('DOMContentLoaded', (event) => { + checkForUpdate(); +}); \ No newline at end of file