2024-08-05 16:53:24 +00:00
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
var sidebar = document.getElementById('sidebar');
|
|
|
|
var mainContent = document.getElementById('mainContent');
|
|
|
|
var toggleButton = document.getElementById('toggleSidebarButton');
|
2024-09-23 16:37:58 +00:00
|
|
|
var timeNow = document.getElementById('time_now');
|
2024-08-05 16:53:24 +00:00
|
|
|
|
|
|
|
// update localStorage based on the current state
|
|
|
|
function updateStorage() {
|
|
|
|
var isSidebarCollapsed = sidebar.classList.contains('collapsed');
|
|
|
|
localStorage.setItem('sidebarState', isSidebarCollapsed ? 'collapsed' : 'expanded');
|
|
|
|
}
|
|
|
|
|
|
|
|
// apply saved state
|
|
|
|
function applySavedState() {
|
|
|
|
var savedState = localStorage.getItem('sidebarState');
|
|
|
|
if (savedState === 'collapsed') {
|
2024-08-05 17:21:34 +00:00
|
|
|
toggleButton.value = ">>";
|
|
|
|
toggleButton.textContent = ">>";
|
2024-08-05 16:53:24 +00:00
|
|
|
sidebar.classList.add('collapsed');
|
|
|
|
mainContent.classList.add('expanded');
|
2024-09-23 16:37:58 +00:00
|
|
|
timeNow.style.display = 'none';
|
2024-08-05 16:53:24 +00:00
|
|
|
} else {
|
2024-08-05 17:21:34 +00:00
|
|
|
toggleButton.value = "<<";
|
|
|
|
toggleButton.textContent = "<<";
|
2024-08-05 16:53:24 +00:00
|
|
|
sidebar.classList.remove('collapsed');
|
|
|
|
mainContent.classList.remove('expanded');
|
2024-09-23 16:37:58 +00:00
|
|
|
timeNow.style.display = 'block';
|
2024-08-05 16:53:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Initialize
|
|
|
|
applySavedState();
|
|
|
|
|
|
|
|
toggleButton.addEventListener('click', function () {
|
|
|
|
// toggle sidebar and main content
|
|
|
|
sidebar.classList.toggle('collapsed');
|
2024-08-07 14:41:56 +00:00
|
|
|
document.documentElement.classList.toggle('sidebar-collapsed');
|
2024-08-05 16:53:24 +00:00
|
|
|
mainContent.classList.toggle('expanded');
|
2024-08-05 17:21:34 +00:00
|
|
|
// Toggle the value between ">>" and "<<"
|
|
|
|
if (toggleButton.value === ">>") {
|
|
|
|
toggleButton.value = "<<";
|
|
|
|
toggleButton.textContent = "<<";
|
2024-09-23 16:37:58 +00:00
|
|
|
timeNow.style.display = 'block';
|
2024-08-05 17:21:34 +00:00
|
|
|
} else {
|
|
|
|
toggleButton.value = ">>";
|
|
|
|
toggleButton.textContent = ">>";
|
2024-09-23 16:37:58 +00:00
|
|
|
timeNow.style.display = 'none';
|
2024-08-05 17:21:34 +00:00
|
|
|
}
|
2024-08-05 16:53:24 +00:00
|
|
|
|
|
|
|
// Update with the new state
|
|
|
|
updateStorage();
|
|
|
|
});
|
|
|
|
});
|