33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
const darkToggle = document.getElementById('dark-mode-toggle');
|
|
const notificationDropDown = document.getElementById('notification-setting');
|
|
|
|
const savedSettingNotif = localStorage.getItem('notification-setting');
|
|
if (savedSettingNotif) {
|
|
notificationDropDown.value = savedSettingNotif;
|
|
}
|
|
|
|
const savedSettingDark = localStorage.getItem('dark-mode-toggle');
|
|
if (savedSettingDark === 'true') {
|
|
darkToggle.checked = true;
|
|
document.body.classList.add('dark');
|
|
} else {
|
|
darkToggle.checked = false;
|
|
document.body.classList.remove('dark');
|
|
}
|
|
|
|
darkToggle.addEventListener('change', () => {
|
|
if (darkToggle.checked) {
|
|
document.body.classList.add('transition');
|
|
document.body.classList.add('dark');
|
|
localStorage.setItem('dark-mode-toggle', 'true');
|
|
} else {
|
|
document.body.classList.add('transition');
|
|
document.body.classList.remove('dark');
|
|
localStorage.setItem('dark-mode-toggle', 'false');
|
|
}
|
|
});
|
|
|
|
notificationDropDown.addEventListener('change', () => {
|
|
localStorage.setItem('notification-setting', notificationDropDown.value);
|
|
});
|