-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
47 lines (41 loc) · 1.69 KB
/
Copy pathscript.js
File metadata and controls
47 lines (41 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Mobile Navigation Toggle
document.querySelector('.mobile-nav-toggle')?.addEventListener('click', function() {
document.querySelector('nav ul').classList.toggle('show');
});
// Function to highlight active theme button
function highlightActiveThemeButton(themeName) {
// Remove active class from all buttons first
document.querySelectorAll('.theme-button').forEach(btn => {
btn.classList.remove('active');
});
// Add active class to the selected theme button
const activeButton = document.querySelector(`.theme-button[data-theme="${themeName}"]`);
if (activeButton) {
activeButton.classList.add('active');
}
}
// Function to apply theme
function applyTheme(themeName) {
// First remove all theme classes
document.body.classList.remove('mayukai-light', 'mayukai-dark', 'tokyo-night-light', 'tokyo-night-dark');
// Then add the selected theme
document.body.classList.add(themeName);
// Highlight the active theme button
highlightActiveThemeButton(themeName);
}
// Theme Switcher
document.querySelectorAll('.theme-button').forEach(button => {
button.addEventListener('click', function() {
const theme = this.getAttribute('data-theme');
applyTheme(theme);
localStorage.setItem('theme', theme);
// Add console log to debug theme switching
console.log('Theme changed to:', theme);
});
});
// Load saved theme when the DOM is fully loaded
document.addEventListener('DOMContentLoaded', function() {
const savedTheme = localStorage.getItem('theme') || 'mayukai-light';
console.log('Loading saved theme:', savedTheme);
applyTheme(savedTheme);
});