aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/switch-storage.js
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2021-12-01 22:45:05 -0500
committerJesús <heckyel@hyperbola.info>2021-12-01 22:45:05 -0500
commit0ef5a8fe632e568c1b80572ae23e46c61f2da185 (patch)
tree352d7273796b975227eca82f34857be71abf9052 /src/js/switch-storage.js
downloadcountries-0ef5a8fe632e568c1b80572ae23e46c61f2da185.tar.lz
countries-0ef5a8fe632e568c1b80572ae23e46c61f2da185.tar.xz
countries-0ef5a8fe632e568c1b80572ae23e46c61f2da185.zip
initial public
Diffstat (limited to 'src/js/switch-storage.js')
-rw-r--r--src/js/switch-storage.js13
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');
+ }
+});