const navbarHTML = ` `; document.addEventListener('DOMContentLoaded', async () => { document.body.insertAdjacentHTML('afterbegin', navbarHTML); var path = window.location.pathname; var links = document.querySelectorAll('.nav-link'); let accountHref = '/login'; try { const resp = await fetch('/api/accounts/authorized'); const data = await resp.json(); if (data && data.success !== false) { accountHref = '/dash'; } } catch {} const accountLink = document.querySelector('.nav-link[href="#"]'); if (accountLink) { accountLink.setAttribute('href', accountHref); } links.forEach(link => { const href = link.getAttribute('href'); if (href === path) { link.id = 'nav-bar-selected'; } if ((path === '/dash' || path === '/login' || path === '/register') && (href === '/dash' || href === '/login')) { link.id = 'nav-bar-selected'; } }); }); window.toggleMenu = function () { const nav = document.querySelector('.nav-links'); const hamburger = document.querySelector('.hamburger'); nav.classList.toggle('show'); hamburger.classList.toggle('active'); };