kontrolvm/assets/switchtheme.js
KuJoe 013372dbb8
Some checks failed
PHPMD / Run PHPMD scanning (push) Has been cancelled
Psalm Security Scan / php-security (push) Has been cancelled
Reapply "Removed dark theme"
This reverts commit 1af69f2a60.
2025-03-26 19:58:26 -04:00

20 lines
No EOL
605 B
JavaScript

// JavaScript code to handle theme switching (from previous responses)
const themeToggle = document.getElementById('theme-toggle');
const body = document.body;
// Load the user's preferred theme from localStorage
const savedTheme = localStorage.getItem('theme');
if(savedTheme === 'dark') {
body.classList.add('dark-mode');
themeToggle.checked = true;
}
themeToggle.addEventListener('change', () => {
if(themeToggle.checked) {
body.classList.add('dark-mode');
localStorage.setItem('theme', 'dark');
} else {
body.classList.remove('dark-mode');
localStorage.setItem('theme', 'light');
}
});