/** * nav.js -- Shared navigation component for AutoParts DB * * Injects a consistent header/nav bar into
. * Auto-highlights the current page link based on window.location.pathname. * * The injected header includes a
slot * that pages can populate with additional header content (search bars, stats, etc.) * after this script runs. */ (function () { 'use strict'; var path = window.location.pathname; function isActive(href) { var h = href.replace(/\/+$/, '') || '/'; var p = path.replace(/\/+$/, '') || '/'; if (h === p) return true; if ((h === '/' || h === '/index.html') && (p === '/' || p === '/index.html')) return true; if ((h === '/admin.html' || h === '/admin') && (p === '/admin.html' || p === '/admin')) return true; if ((h === '/diagramas' || h === '/diagrams.html') && (p === '/diagramas' || p === '/diagrams.html')) return true; if ((h === '/customer-landing.html') && (p === '/customer-landing.html')) return true; return false; } var navLinks = [ { label: 'Cat\u00e1logo', href: '/' }, { label: 'Diagramas', href: '/diagramas' }, { label: 'Admin', href: '/admin' } ]; var linksHTML = navLinks.map(function (link) { var baseStyle = 'text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s;'; if (isActive(link.href)) { baseStyle += ' color: var(--accent);'; } else { baseStyle += ' color: var(--text-secondary);'; } return '' + link.label + ''; }).join(''); var html = '' + '
' + '
' // Logo + '' + '
\u2699\uFE0F
' + 'AUTOPARTS DB' + '
' // Slot for extra page-specific content (search bars, stats, etc.) + '
' // Nav links + '' + '
' + '
'; var target = document.getElementById('shared-nav'); if (target) { target.innerHTML = html; } })();