-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
50 lines (43 loc) · 1.8 KB
/
Copy pathscripts.js
File metadata and controls
50 lines (43 loc) · 1.8 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
48
49
50
// Apply the saved theme on page load
document.addEventListener("DOMContentLoaded", () => {
const savedTheme = localStorage.getItem("theme") || "mocha";
const body = document.body;
body.classList.remove("mocha", "latte"); // Clear existing theme classes
body.classList.add(savedTheme); // Apply saved theme
const themeToggle = document.getElementById("theme-toggle");
if (themeToggle) {
themeToggle.checked = savedTheme === "mocha";
}
});
// Update the theme and save the preference
document.getElementById("theme-toggle").addEventListener("change", function () {
const newTheme = this.checked ? "mocha" : "latte";
const body = document.body;
body.classList.remove("mocha", "latte"); // Clear existing theme classes
body.classList.add(newTheme); // Apply the new theme
localStorage.setItem("theme", newTheme);
});
const collapsible = document.getElementById('collapsible');
const tab = document.getElementById('sidebar-tab');
if (collapsible.classList.contains('collapsed')) {
tab.innerHTML = '→'; // Open arrow
} else {
tab.innerHTML = '←'; // Close arrow
}
document.getElementById('sidebar-tab').addEventListener('click', function () {
// Toggle the 'collapsed' class on the sidebar
collapsible.classList.toggle('collapsed');
// Update the tab content based on the sidebar's state
if (collapsible.classList.contains('collapsed')) {
tab.innerHTML = '→'; // Open arrow
} else {
tab.innerHTML = '←'; // Close arrow
}
});
// Enable throbbers when loading content
document.body.addEventListener('htmx:beforeRequest', function() {
document.getElementById('throbber').style.display = 'block';
});
document.body.addEventListener('htmx:afterRequest', function() {
document.getElementById('throbber').style.display = 'none';
});