PageSourceSearch

https://assets.webis.de/js/selection.js

js webis.de collected 2026-10-01 10:17:42 UTC 2,236 bytes, 77 lines download raw bytes

1function clearHighlight() {
2  document.querySelectorAll('.target').forEach(target => {
3    target.classList.remove("target");
4  });
5}
6
7/*
8 * type: "table" for table row highlighting
9 *       "bibentry" for bibentry highlighting
10 */
11function refreshHighlight(type) {
12  clearHighlight();
13  const hash = window.location.hash;
14  if (hash !== "") {
15    const targeted = document.querySelector(window.location.hash);
16    if (targeted !== null) {
17      switch (type) {
18        case "table":
19          var el = targeted.closest("tr");
20          break;
21        case "bibentry":
22          var el = targeted.nextElementSibling;
23          while (el.tagName == "A") { el = el.nextElementSibling; }
24          break;
25      }
26
27      if (el !== null) {
28        el.classList.add("target");
29      }
30    }
31  }
32}
33
34/////////////////////////////////////////////////////////////
35// Specific code for publications
36/////////////////////////////////////////////////////////////
37
38function initBibHighlightOnCopyLink(copyLinkLinks = document.querySelectorAll('.copylink')) {
39  copyLinkLinks.forEach(el => el.addEventListener("click", (event) => {
40    const bibentry = event.target.parentElement;
41    clearHighlight();
42    bibentry.classList.add("target");
43  }));
44
45  refreshHighlight("bibentry");
46  window.addEventListener("hashchange", function () { refreshHighlight("bibentry"); });
47}
48
49/////////////////////////////////////////////////////////////
50// Specific code for tables
51/////////////////////////////////////////////////////////////
52
53function highlightRow(row) {
54  const idCell = row.querySelector("[id]");
55  if (idCell !== null) {
56    const id = idCell.getAttribute("id");
57    const hash = "#" + id;
58    if (window.location.hash !== hash) {
59      clearHighlight();
60      row.classList.add("target");
61      history.pushState( { target: id }, "", hash);
62    }
63  }
64}
65
66function initTableHighlightOnClick(tables = document.querySelectorAll('table')) {
67  tables.forEach(table => {
68    table.querySelectorAll('tr').forEach(row => {
69      row.addEventListener("click", evt => {
70        highlightRow(evt.target.closest("tr"));
71      });
72    });
73  });
74
75  refreshHighlight("table");
76  window.addEventListener("hashchange", function () { refreshHighlight("table") });
77}

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.