From a113e4481ed306a40074255a072f8497bd84d882 Mon Sep 17 00:00:00 2001 From: bitkarrot <73979971+bitkarrot@users.noreply.github.com> Date: Thu, 5 Jun 2025 17:04:13 -0700 Subject: [PATCH] fix script to handle when select dropdown commented out --- index.html | 6 ++---- script.js | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index cad5639..b6db31c 100644 --- a/index.html +++ b/index.html @@ -44,9 +44,9 @@
+ - - + --> diff --git a/script.js b/script.js index 4b72c4c..43662e4 100644 --- a/script.js +++ b/script.js @@ -296,21 +296,27 @@ document.addEventListener('DOMContentLoaded', () => { }); // Color theme initialization - const colorThemeSelect = document.getElementById('colorThemeSelect'); + const colorThemeSelect = document.getElementById('colorThemeSelect'); // This will be null since we commented it out const savedColorTheme = localStorage.getItem('colorTheme'); const defaultTheme = 'default'; // Validate saved theme exists const initialTheme = colorThemes[savedColorTheme] ? savedColorTheme : defaultTheme; - colorThemeSelect.value = initialTheme; + // Only set the value if the element exists + if (colorThemeSelect) { + colorThemeSelect.value = initialTheme; + } applyColorTheme(initialTheme); // Color theme change event listener - colorThemeSelect.addEventListener('change', (e) => { - const selectedTheme = e.target.value; - localStorage.setItem('colorTheme', selectedTheme); - applyColorTheme(selectedTheme); - }); + // Only add the event listener if the element exists + if (colorThemeSelect) { + colorThemeSelect.addEventListener('change', (e) => { + const selectedTheme = e.target.value; + localStorage.setItem('colorTheme', selectedTheme); + applyColorTheme(selectedTheme); + }); + } // Test if marked is loaded if (typeof marked === 'undefined') {