Huge update.
This commit is contained in:
32
resource/static/js/settings.js
Normal file
32
resource/static/js/settings.js
Normal file
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user