mirror of
https://github.com/rottenwheel/revuo-weekly.git
synced 2024-12-22 15:47:46 +00:00
14 lines
No EOL
537 B
JavaScript
14 lines
No EOL
537 B
JavaScript
// Saves themes in-between pages to LocalStorage.
|
|
const themeSwitcher = document.getElementById('theme-switcher');
|
|
|
|
const setTheme = e => localStorage.setItem('theme', e.target.checked ? 'dark' : 'light');
|
|
const checkTheme = () => themeSwitcher.checked = localStorage.getItem('theme') === 'dark';
|
|
|
|
// Ensures backward compatibility with IE old versions
|
|
if (document.addEventListener) {
|
|
themeSwitcher.addEventListener('click', setTheme);
|
|
} else if (document.attachEvent) {
|
|
themeSwitcher.attachEvent('onclick', setTheme);
|
|
}
|
|
|
|
checkTheme() |