// Common Navigation and UI Utilities for ChemiFactory MES/HMI document.addEventListener("DOMContentLoaded", () => { renderNavigation(); highlightActiveLink(); }); // Navigation configuration const navItems = [ { name: "λμ보λ", icon: "π", path: "index.html" }, { name: "μμ° κ³ν", icon: "π ", path: "plan.html" }, { name: "μμ° νν©", icon: "βοΈ", path: "equipment.html" }, { name: "κ³ κ°μ¬ κ΄λ¦¬", icon: "π€", path: "customer.html" }, { name: "곡κΈμ¬ κ΄λ¦¬", icon: "π", path: "supplier.html" }, { name: "κΈ°κΈ° κ΄λ¦¬", icon: "π οΈ", path: "device.html" }, { name: "μ¬κ³ κ΄λ¦¬", icon: "π¦", path: "inventory.html" }, { name: "κ³μ°/λΆμ", icon: "π", path: "analysis.html" }, { name: "μ€μ ", icon: "βοΈ", path: "setting.html" } ]; function renderNavigation() { const sidebar = document.getElementById("sidebar"); if (!sidebar) return; let html = `
`; sidebar.innerHTML = html; } function highlightActiveLink() { // Current page filename detection const path = window.location.pathname; const page = path.split("/").pop() || "index.html"; const links = document.querySelectorAll(".nav-item-link"); links.forEach(link => { const itemPath = link.getAttribute("data-path"); if (page === itemPath || (page === "" && itemPath === "index.html")) { link.classList.add("active"); } else { link.classList.remove("active"); } }); }