diff --git a/py_app/app/static/script.js b/py_app/app/static/script.js index dbc6ea4..acbe491 100644 --- a/py_app/app/static/script.js +++ b/py_app/app/static/script.js @@ -35,10 +35,12 @@ document.addEventListener('DOMContentLoaded', () => { // Helper function to update the theme toggle button text function updateThemeToggleButtonText() { - if (body.classList.contains('dark-mode')) { - themeToggleButton.textContent = 'Change to Light Mode'; - } else { - themeToggleButton.textContent = 'Change to Dark Mode'; + if (themeToggleButton) { + if (body.classList.contains('dark-mode')) { + themeToggleButton.textContent = 'Change to Light Mode'; + } else { + themeToggleButton.textContent = 'Change to Dark Mode'; + } } } @@ -52,11 +54,13 @@ document.addEventListener('DOMContentLoaded', () => { updateThemeToggleButtonText(); // Toggle the theme on button click - themeToggleButton.addEventListener('click', () => { - const isDarkMode = body.classList.toggle('dark-mode'); - safeStorage.setItem('theme', isDarkMode ? 'dark' : 'light'); - updateThemeToggleButtonText(); // Update the button text after toggling - }); + if (themeToggleButton) { + themeToggleButton.addEventListener('click', () => { + const isDarkMode = body.classList.toggle('dark-mode'); + safeStorage.setItem('theme', isDarkMode ? 'dark' : 'light'); + updateThemeToggleButtonText(); // Update the button text after toggling + }); + } // Date formatting is now handled consistently on the backend