Display service catalogs #22

Merged
rixx merged 17 commits from 13-service-catalog into main 2025-03-25 11:18:20 +00:00
Showing only changes of commit d093d422ce - Show all commits

View file

@ -2,21 +2,30 @@
* This script marks the current path as active in the sidebar. * This script marks the current path as active in the sidebar.
*/ */
const markActive = (link) => {
const parentItem = link.closest('.sidebar-item');
if (parentItem) {
parentItem.classList.add('active');
} else {
link.classList.add('active');
}
}
const checkLink = (fuzzy) => {
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
const currentPath = window.location.pathname; const currentPath = window.location.pathname;
const sidebarLinks = document.querySelectorAll('.sidebar-link'); const sidebarLinks = [...document.querySelectorAll('a.sidebar-link')]
sidebarLinks.forEach(link => { const exactMatches = sidebarLinks.filter(link => link.getAttribute('href') === currentPath)
// Skip links that are inside buttons (like logout) if (exactMatches.length > 0) {
if (link.tagName === 'BUTTON') return; markActive(exactMatches[0])
} else {
if (link.getAttribute('href') === currentPath) { fuzzyMatches = sidebarLinks.filter(link => currentPath.startsWith(link.getAttribute('href')))
const parentItem = link.closest('.sidebar-item'); if (fuzzyMatches.length > 0) {
if (parentItem) { const longestMatch = fuzzyMatches.sort((a, b) => b.href.length - a.href.length)[0]
parentItem.classList.add('active'); markActive(longestMatch)
} else {
link.classList.add('active');
}
} }
}) }
}) })