aboutsummaryrefslogtreecommitdiffstats
path: root/src/js/switch-storage.js
blob: fb200c4d08e8c65a808c79703f99c6ec67b1cd9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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');
  }
});