From 1e520729865883326ea52d8878c620979af74673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Tue, 9 Nov 2021 18:20:40 -0500 Subject: initial import --- src/js/switch-storage.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/js/switch-storage.js (limited to 'src/js') 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'); + } +}); -- cgit v1.2.3