/* ANAX · auto-mark current nav item with .is-active + aria-current="page" Strategy: compare window.location.pathname to each in topbar. - Exact match → mega submenu item gets .is-active - First-segment match → top-level parent menu (Markets/Platforms/etc) gets .is-active - Home (/) → Home nav item gets .is-active */ (function () { var path = location.pathname.replace(/\/index\.html$/, '/').replace(/\/+$/, '') || '/'; var top = path.split('/').filter(Boolean)[0] || ''; // 'markets' | 'about' | etc. // 1 · deep-page exact match inside mega menus document.querySelectorAll('.topbar .nav .mega a[href]').forEach(function (a) { var href = a.getAttribute('href'); if (!href) return; try { var u = new URL(href, location.origin + location.pathname).pathname.replace(/\/index\.html$/, '/').replace(/\/+$/, '') || '/'; if (u === path) { a.classList.add('is-active'); a.setAttribute('aria-current', 'page'); // Bubble active state up to the parent
  • (top-level mega item) var parentLi = a.closest('.topbar .nav > li'); if (parentLi) parentLi.classList.add('is-active'); } } catch (e) {} }); // 2 · top-level nav link exact match (Home/About/Contact) document.querySelectorAll('.topbar .nav > li > a[href]').forEach(function (a) { var href = a.getAttribute('href'); if (!href) return; try { var u = new URL(href, location.origin + location.pathname).pathname.replace(/\/index\.html$/, '/').replace(/\/+$/, '') || '/'; if (u === path) { a.parentElement.classList.add('is-active'); a.setAttribute('aria-current', 'page'); } } catch (e) {} }); // 3 · top-level segment fallback (markets/* → Markets parent) if (top) { document.querySelectorAll('.topbar .nav > li > button[aria-haspopup]').forEach(function (btn) { var li = btn.parentElement; // any inside mega whose first path segment matches var match = li.querySelector('.mega a[href*="' + top + '/"], .mega a[href^="' + top + '"]'); if (match && !li.classList.contains('is-active')) { li.classList.add('is-active'); } }); } })();