PageSourceSearch

https://getnametag.com/js/document-types.js

js getnametag.com collected 2026-10-02 04:25:33 UTC 2,565 bytes, 76 lines download raw bytes

1/**
2 * Copyright 2025 Nametag Inc.
3 *
4 * All information contained herein is the property of Nametag Inc.. The
5 * intellectual and technical concepts contained herein are proprietary, trade
6 * secrets, and/or confidential to Nametag, Inc. and may be covered by U.S.
7 * and Foreign Patents, patents in process, and are protected by trade secret or
8 * copyright law. Reproduction or distribution, in whole or in part, is
9 * forbidden except by express written permission of Nametag, Inc.
10 */
11
12/**
13 * This is used with /docs/govtid-doctypes/ to add a search box
14 * to filter document types.
15 */
16const docTypes = document.getElementById("document-types");
17if (!!docTypes) {
18  const searchContainer = document.createElement("form");
19  searchContainer.style.marginBottom = "20px";
20  searchContainer.style.marginTop = "24px";
21  searchContainer.className = "search";
22
23  const searchInput = document.createElement("input");
24  searchInput.name = "doc-type-search";
25  searchInput.type = "text";
26  searchInput.placeholder = "Search document types";
27  searchContainer.appendChild(searchInput);
28
29  const searchButton = document.createElement("button");
30  searchButton.type = "submit";
31  searchButton.innerText = "Search";
32  searchContainer.appendChild(searchButton);
33
34  docTypes.parentNode.insertBefore(searchContainer, docTypes);
35  searchContainer.addEventListener("submit", e => {
36    e.preventDefault();
37    let hasMatch = false;
38
39    document.getElementById("no-results")?.remove();
40
41    const query = searchInput.value.toLowerCase().trim();
42    const rows = docTypes.getElementsByTagName("tr");
43    for (let i = 1; i < rows.length; i++) {
44      if (query !== "") {
45        let rowMatch = false;
46        const cells = rows[i].getElementsByTagName("td");
47        for (let j = 0; j < cells.length; j++) {
48          if (cells[j].innerText.toLowerCase().includes(query)) {
49            hasMatch = true;
50            rowMatch = true;
51            break;
52          }
53        }
54        rows[i].style.display = rowMatch ? "" : "none";
55      } else {
56        rows[i].style.display = "";
57        hasMatch = true;
58      }
59    }
60
61    if (hasMatch) {
62      docTypes.style.display = "";
63    } else {
64      docTypes.style.display = "none";
65
66      searchContainer.parentNode.insertBefore(
67        Object.assign(document.createElement("alert"), {
68          id: "no-results",
69          innerText: "No document types match your search.",
70          style: "color: #706e77; font-style: italic; position: relative; top: -8px;",
71        }),
72        searchContainer.nextSibling,
73      );
74    }
75  });
76}

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.