2024-01-11 01:07:48 +00:00
|
|
|
// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
|
|
|
|
// The above is a GNU LibreJS specific license declaration. The Expat license is the same as the MIT license.
|
|
|
|
// See: https://www.gnu.org/software/librejs/free-your-javascript.html#magnet-link-license
|
|
|
|
|
2023-10-15 23:40:48 +00:00
|
|
|
// Saves themes in-between pages to LocalStorage.
|
|
|
|
const themeSwitcher = document.getElementById('theme-switcher');
|
2019-03-29 04:32:42 +00:00
|
|
|
|
2023-10-15 23:40:48 +00:00
|
|
|
const setTheme = e => localStorage.setItem('theme', e.target.checked ? 'dark' : 'light');
|
|
|
|
const checkTheme = () => themeSwitcher.checked = localStorage.getItem('theme') === 'dark';
|
2019-03-29 04:32:42 +00:00
|
|
|
|
|
|
|
// Ensures backward compatibility with IE old versions
|
2023-10-15 23:40:48 +00:00
|
|
|
if (document.addEventListener) {
|
|
|
|
themeSwitcher.addEventListener('click', setTheme);
|
|
|
|
} else if (document.attachEvent) {
|
|
|
|
themeSwitcher.attachEvent('onclick', setTheme);
|
2019-03-29 04:32:42 +00:00
|
|
|
}
|
|
|
|
|
2023-10-15 23:40:48 +00:00
|
|
|
checkTheme()
|