Upload app.js
Browse files- static/app.js +15 -1
static/app.js
CHANGED
|
@@ -369,6 +369,8 @@ function syncUrl(replace = true) {
|
|
| 369 |
if (STATE.fulltext) params.set("fulltext", "1");
|
| 370 |
if (!STATE.searchPaths) params.set("search_paths", "0");
|
| 371 |
if (!STATE.historyEnabled) params.set("history", "0");
|
|
|
|
|
|
|
| 372 |
if (STATE.rightSidebarOpen) params.set("filters", "1");
|
| 373 |
const basePath = STATE.source ? `/${encodeURIComponent(STATE.source)}` : "/";
|
| 374 |
const nextUrl = params.toString() ? `${basePath}?${params.toString()}` : basePath;
|
|
@@ -394,7 +396,10 @@ function loadUrlState() {
|
|
| 394 |
DOM.searchPathsToggle.checked = STATE.searchPaths;
|
| 395 |
DOM.historyToggle.checked = STATE.historyEnabled;
|
| 396 |
DOM.sortSelect.value = sort;
|
|
|
|
| 397 |
STATE.rightSidebarOpen = params.get("filters") === "1";
|
|
|
|
|
|
|
| 398 |
if (STATE.minSize !== null) DOM.filterMinSize.value = STATE.minSize;
|
| 399 |
if (STATE.maxSize !== null) DOM.filterMaxSize.value = STATE.maxSize;
|
| 400 |
}
|
|
@@ -1016,11 +1021,13 @@ function attachEvents() {
|
|
| 1016 |
STATE.leftSidebarOpen = !STATE.leftSidebarOpen;
|
| 1017 |
if (STATE.isMobile && STATE.leftSidebarOpen) STATE.rightSidebarOpen = false;
|
| 1018 |
updateSidebarVisibility();
|
|
|
|
| 1019 |
});
|
| 1020 |
if (DOM.sidebarExpandBtn) {
|
| 1021 |
DOM.sidebarExpandBtn.addEventListener("click", () => {
|
| 1022 |
DOM.leftSidebar.classList.toggle("expanded-wide");
|
| 1023 |
DOM.sidebarExpandBtn.textContent = DOM.leftSidebar.classList.contains("expanded-wide") ? "→" : "↔";
|
|
|
|
| 1024 |
});
|
| 1025 |
}
|
| 1026 |
DOM.settingsBtn.addEventListener("click", () => {
|
|
@@ -1048,6 +1055,10 @@ function attachEvents() {
|
|
| 1048 |
DOM.mobileToggleBtn.addEventListener("click", () => {
|
| 1049 |
STATE.isMobile = !STATE.isMobile;
|
| 1050 |
applyMobileMode();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1051 |
});
|
| 1052 |
let historyDropdownActive = false;
|
| 1053 |
DOM.searchInput.addEventListener("focus", renderHistoryDropdown);
|
|
@@ -1320,7 +1331,10 @@ async function init() {
|
|
| 1320 |
cacheDom();
|
| 1321 |
STATE.isDark = localStorage.getItem("theme") !== "light";
|
| 1322 |
applyTheme();
|
| 1323 |
-
|
|
|
|
|
|
|
|
|
|
| 1324 |
syncRoute();
|
| 1325 |
applyMobileMode();
|
| 1326 |
loadUrlState();
|
|
|
|
| 369 |
if (STATE.fulltext) params.set("fulltext", "1");
|
| 370 |
if (!STATE.searchPaths) params.set("search_paths", "0");
|
| 371 |
if (!STATE.historyEnabled) params.set("history", "0");
|
| 372 |
+
if (!STATE.leftSidebarOpen) params.set("sidebar", "0");
|
| 373 |
+
if (DOM.leftSidebar.classList.contains("expanded-wide")) params.set("wide", "1");
|
| 374 |
if (STATE.rightSidebarOpen) params.set("filters", "1");
|
| 375 |
const basePath = STATE.source ? `/${encodeURIComponent(STATE.source)}` : "/";
|
| 376 |
const nextUrl = params.toString() ? `${basePath}?${params.toString()}` : basePath;
|
|
|
|
| 396 |
DOM.searchPathsToggle.checked = STATE.searchPaths;
|
| 397 |
DOM.historyToggle.checked = STATE.historyEnabled;
|
| 398 |
DOM.sortSelect.value = sort;
|
| 399 |
+
STATE.leftSidebarOpen = !STATE.isMobile && params.get("sidebar") !== "0";
|
| 400 |
STATE.rightSidebarOpen = params.get("filters") === "1";
|
| 401 |
+
DOM.leftSidebar.classList.toggle("expanded-wide", params.get("wide") === "1" && !STATE.isMobile);
|
| 402 |
+
if (DOM.sidebarExpandBtn) DOM.sidebarExpandBtn.textContent = params.get("wide") === "1" && !STATE.isMobile ? "→" : "↔";
|
| 403 |
if (STATE.minSize !== null) DOM.filterMinSize.value = STATE.minSize;
|
| 404 |
if (STATE.maxSize !== null) DOM.filterMaxSize.value = STATE.maxSize;
|
| 405 |
}
|
|
|
|
| 1021 |
STATE.leftSidebarOpen = !STATE.leftSidebarOpen;
|
| 1022 |
if (STATE.isMobile && STATE.leftSidebarOpen) STATE.rightSidebarOpen = false;
|
| 1023 |
updateSidebarVisibility();
|
| 1024 |
+
syncUrl();
|
| 1025 |
});
|
| 1026 |
if (DOM.sidebarExpandBtn) {
|
| 1027 |
DOM.sidebarExpandBtn.addEventListener("click", () => {
|
| 1028 |
DOM.leftSidebar.classList.toggle("expanded-wide");
|
| 1029 |
DOM.sidebarExpandBtn.textContent = DOM.leftSidebar.classList.contains("expanded-wide") ? "→" : "↔";
|
| 1030 |
+
syncUrl();
|
| 1031 |
});
|
| 1032 |
}
|
| 1033 |
DOM.settingsBtn.addEventListener("click", () => {
|
|
|
|
| 1055 |
DOM.mobileToggleBtn.addEventListener("click", () => {
|
| 1056 |
STATE.isMobile = !STATE.isMobile;
|
| 1057 |
applyMobileMode();
|
| 1058 |
+
localStorage.setItem("mobileMode", STATE.isMobile ? "mobile" : "desktop");
|
| 1059 |
+
loadUrlState();
|
| 1060 |
+
updateSidebarVisibility();
|
| 1061 |
+
syncUrl();
|
| 1062 |
});
|
| 1063 |
let historyDropdownActive = false;
|
| 1064 |
DOM.searchInput.addEventListener("focus", renderHistoryDropdown);
|
|
|
|
| 1331 |
cacheDom();
|
| 1332 |
STATE.isDark = localStorage.getItem("theme") !== "light";
|
| 1333 |
applyTheme();
|
| 1334 |
+
const savedMobileMode = localStorage.getItem("mobileMode");
|
| 1335 |
+
if (savedMobileMode === "mobile") STATE.isMobile = true;
|
| 1336 |
+
else if (savedMobileMode === "desktop") STATE.isMobile = false;
|
| 1337 |
+
else STATE.isMobile = window.innerWidth <= 768;
|
| 1338 |
syncRoute();
|
| 1339 |
applyMobileMode();
|
| 1340 |
loadUrlState();
|