PageSourceSearch

https://www.cardinalcomet.com/shared/scripts/nav.js

js cardinalcomet.com collected 2026-10-05 08:09:31 UTC 1,707 bytes, 41 lines download raw bytes

1const navbar = document.getElementById('navbar');
2		
3const allTopNavListItems = navbar.querySelectorAll(':scope > li');
4for (const menuItem of allTopNavListItems) {
5    if (menuItem.classList.contains('has-submenu')) {
6        var activatingA = menuItem.querySelector('a');
7        var btn = '<button><span><i class="fa-solid fa-caret-down"></i><span class="visuallyhidden">show submenu for “' + activatingA.text + '”</span></span></button>';
8        activatingA.insertAdjacentHTML('afterend', btn);
9
10        menuItem.querySelector('button').addEventListener("click", function(event) {
11            const parentNode = this.parentNode;
12            if (parentNode.className == "has-submenu") {
13                openMenu(parentNode);
14            } else {
15                closeMenu(parentNode);
16            }
17            event.preventDefault();
18        });
19    }
20    menuItem.addEventListener('keyup', (event) => {
21        if (menuItem === document.activeElement || menuItem.contains(document.activeElement)) {
22            for (const navParentItem of allTopNavListItems) {
23                if (navParentItem.classList.contains('has-submenu') && menuItem !== navParentItem) {
24                    closeMenu(navParentItem);
25                }
26            }
27        }
28    });
29}
30
31function openMenu(menuItem) {
32    menuItem.classList.add('open');
33    menuItem.querySelector('a').setAttribute('aria-expanded', "true");
34    menuItem.querySelector('button').setAttribute('aria-expanded', "true");
35}
36
37function closeMenu(menuItem) {
38    menuItem.classList.remove("open");
39    menuItem.querySelector('a').setAttribute('aria-expanded', "false");
40    menuItem.querySelector('button').setAttribute('aria-expanded', "false");
41}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.