release
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const path = window.location.pathname;
|
||||
|
||||
const navItems = {
|
||||
login: document.getElementById("nav-login"),
|
||||
settings: document.getElementById("nav-settings"),
|
||||
staff: document.getElementById("nav-staff"),
|
||||
logout: document.getElementById("nav-logout"),
|
||||
};
|
||||
|
||||
const isLoginPage = path === "/login";
|
||||
|
||||
/* ---------- Видимость пунктов ---------- */
|
||||
|
||||
if (isLoginPage) {
|
||||
navItems.login?.classList.remove("d-none");
|
||||
navItems.settings?.classList.add("d-none");
|
||||
navItems.staff?.classList.add("d-none");
|
||||
navItems.logout?.classList.add("d-none");
|
||||
} else {
|
||||
navItems.login?.classList.add("d-none");
|
||||
navItems.settings?.classList.remove("d-none");
|
||||
navItems.staff?.classList.remove("d-none");
|
||||
navItems.logout?.classList.remove("d-none");
|
||||
}
|
||||
|
||||
/* ---------- Подсветка активной страницы ---------- */
|
||||
|
||||
// Для "/" — ничего не подсвечиваем
|
||||
if (path === "/") {
|
||||
return;
|
||||
}
|
||||
|
||||
document
|
||||
.querySelectorAll(".nav-link[data-path]")
|
||||
.forEach(link => {
|
||||
if (link.dataset.path === path) {
|
||||
link.classList.add("active");
|
||||
} else {
|
||||
link.classList.remove("active");
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user