fix script to handle when select dropdown commented out

This commit is contained in:
bitkarrot
2025-06-05 17:04:13 -07:00
parent 65461d3e84
commit a113e4481e
2 changed files with 15 additions and 11 deletions

View File

@@ -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') {