login and dashboard pages
This commit is contained in:
34
py_app/app/static/script.js
Normal file
34
py_app/app/static/script.js
Normal file
@@ -0,0 +1,34 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const themeToggle = document.getElementById('theme-toggle');
|
||||
const body = document.body;
|
||||
|
||||
// Check for saved theme in localStorage
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme) {
|
||||
body.className = savedTheme;
|
||||
updateButtonText();
|
||||
}
|
||||
|
||||
// Toggle theme on button click
|
||||
if (themeToggle) {
|
||||
themeToggle.addEventListener('click', () => {
|
||||
if (body.classList.contains('light-mode')) {
|
||||
body.className = 'dark-mode';
|
||||
localStorage.setItem('theme', 'dark-mode');
|
||||
} else {
|
||||
body.className = 'light-mode';
|
||||
localStorage.setItem('theme', 'light-mode');
|
||||
}
|
||||
updateButtonText();
|
||||
});
|
||||
}
|
||||
|
||||
// Function to update the button text
|
||||
function updateButtonText() {
|
||||
if (body.classList.contains('light-mode')) {
|
||||
themeToggle.textContent = 'Change to dark theme';
|
||||
} else {
|
||||
themeToggle.textContent = 'Change to light theme';
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user