From 35203f4edad56a789b8e205f40fb8d7f8d9f9a1a Mon Sep 17 00:00:00 2001 From: recanman Date: Sat, 27 Jan 2024 09:18:05 -0800 Subject: [PATCH] fix saving of mobile theme, add IE compatibility --- js/main.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/js/main.js b/js/main.js index e26b971..7fed2e7 100644 --- a/js/main.js +++ b/js/main.js @@ -67,12 +67,20 @@ if (document.body.clientWidth < 940) { ] ] - // Switch the theme when the theme switcher is clicked. - themeSwitcher.addEventListener('change', () => { + const checkMobileTheme = () => { const theme = themeVariables[themeSwitcher.checked ? 1 : 0]; theme.forEach(variable => { document.documentElement.style.setProperty(`--${variable.name}`, variable.value); }); - }); + }; + + // Ensure IE compatibility + if (document.addEventListener) { + themeSwitcher.addEventListener('change', checkMobileTheme); + } else if (document.attachEvent) { + themeSwitcher.attachEvent('onchange', checkMobileTheme); + } + + checkMobileTheme(); } \ No newline at end of file