48 lines
1.5 KiB
JavaScript
48 lines
1.5 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
function setupShell() {
|
|
const menu = document.getElementById("menuButton");
|
|
const nav = document.getElementById("primaryNav");
|
|
if (menu && nav) {
|
|
menu.addEventListener("click", function () {
|
|
const open = nav.dataset.open !== "true";
|
|
nav.dataset.open = String(open);
|
|
menu.setAttribute("aria-expanded", String(open));
|
|
});
|
|
}
|
|
|
|
const search = document.getElementById("globalSearchForm");
|
|
const searchInput = document.getElementById("globalSearchInput");
|
|
if (search && searchInput) {
|
|
search.addEventListener("submit", function (event) {
|
|
event.preventDefault();
|
|
const query = searchInput.value.trim();
|
|
const target = query
|
|
? "/assets/miners?query=" + encodeURIComponent(query)
|
|
: "/assets/miners";
|
|
window.location.assign(target);
|
|
});
|
|
}
|
|
|
|
const logout = document.getElementById("logoutButton");
|
|
if (logout) {
|
|
logout.addEventListener("click", async function () {
|
|
logout.disabled = true;
|
|
try {
|
|
await fetch("/api/auth/logout", {
|
|
method: "POST",
|
|
credentials: "same-origin"
|
|
});
|
|
} finally {
|
|
window.location.replace("/login");
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
setupShell();
|
|
})();
|