diff options
author | Jesús <heckyel@hyperbola.info> | 2021-11-09 18:20:40 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-11-09 18:20:40 -0500 |
commit | 1e520729865883326ea52d8878c620979af74673 (patch) | |
tree | 071be2db0948d8c561ef516d7ed838fe3b52b5f0 /src/js | |
download | simple-1e520729865883326ea52d8878c620979af74673.tar.lz simple-1e520729865883326ea52d8878c620979af74673.tar.xz simple-1e520729865883326ea52d8878c620979af74673.zip |
initial import
Diffstat (limited to 'src/js')
-rw-r--r-- | src/js/switch-storage.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/js/switch-storage.js b/src/js/switch-storage.js new file mode 100644 index 0000000..fb200c4 --- /dev/null +++ b/src/js/switch-storage.js @@ -0,0 +1,13 @@ +// This code is only used to remember theme selection +const themeSwitch = document.getElementById('theme-switch'); +themeSwitch.checked = localStorage.getItem('switchedTheme') === 'true'; + +themeSwitch.addEventListener('change', function (e) { + if(e.currentTarget.checked === true) { + localStorage.setItem('switchedTheme', 'true'); + console.info('Add light theme to localstorage'); + } else { + localStorage.removeItem('switchedTheme'); + console.info('Remove light theme of localstorage'); + } +}); |