PageSourceSearch

https://www.usa.gov/themes/custom/usagov/scripts/newFooter.js

js usa.gov collected 2026-10-01 06:09:27 UTC 2,728 bytes, 79 lines download raw bytes

1window.addEventListener("resize", checkForMobile);
2window.addEventListener("load", checkForMobile);
3
4var EXPANDED = "aria-expanded";
5var CONTROLS = "aria-controls";
6var HIDDEN = "hidden";
7
8function showLinks(event) {
9  "use strict";
10  if (window.innerWidth < 480) {
11    // get current selected button settings for later
12    var selected = event.target;
13    var selectedWasOpen = selected.getAttribute(EXPANDED) === "true";
14
15    // change(close) other selected settings
16    document
17      .querySelectorAll(".usa-gov-footer__primary-link")
18      .forEach(function (button) {
19        button.setAttribute(EXPANDED, "false");
20
21        var buttonId = button.getAttribute(CONTROLS);
22        var buttonControls = document.getElementById(buttonId);
23
24        buttonControls.setAttribute(HIDDEN, "");
25      });
26
27    // change current selected settings
28    selected.setAttribute(EXPANDED, !selectedWasOpen);
29    var selectedIsOpen = selected.getAttribute(EXPANDED) === "true";
30
31    var selectedId = selected.getAttribute(CONTROLS);
32    var selectedControls = document.getElementById(selectedId);
33    if (selectedIsOpen) {
34      selectedControls.removeAttribute(HIDDEN);
35    }
36 else {
37      selectedControls.setAttribute(HIDDEN, "");
38    }
39  }
40}
41
42function checkForMobile() {
43  "use strict";
44  // isMobile uses same check that telephone numbers use to set to links
45  var isMobile = window.innerWidth < 480 ? true : false;
46  var newElementType = isMobile ? "button" : "h3";
47
48  document
49    .querySelectorAll(".usa-gov-footer__primary-link")
50    .forEach(function (primaryLink) {
51      var newElement = document.createElement(newElementType);
52      newElement.textContent = primaryLink.textContent;
53
54      // hardcoded because we know what it is and this should only be used until update from uswds
55      newElement.setAttribute("class", "usa-gov-footer__primary-link");
56      newElement.classList.toggle(
57        "usa-gov-footer__primary-link--button",
58        isMobile
59      );
60      if (isMobile) {
61        var menuId = "usa-footer-menu-list-".concat(
62          Math.floor(Math.random() * 100000)
63        );
64        newElement.setAttribute(CONTROLS, menuId);
65        newElement.setAttribute(EXPANDED, "false");
66        primaryLink.nextElementSibling.setAttribute("id", menuId);
67        newElement.setAttribute("type", "button");
68        var primaryLinkId = newElement.getAttribute(CONTROLS);
69        var primaryLinkControls = document.getElementById(primaryLinkId);
70        primaryLinkControls.setAttribute(HIDDEN, "");
71        newElement.addEventListener("click", showLinks);
72      }
73 else {
74        primaryLink.nextElementSibling.removeAttribute(HIDDEN);
75      }
76      primaryLink.after(newElement);
77      primaryLink.remove();
78    });
79}

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.