PageSourceSearch

https://investigate.ai/js/main.js?v=1edd6b72f7227d977df2bf125e3b6e55

js investigate.ai collected 2026-10-03 21:37:21 UTC 4,964 bytes, 165 lines download raw bytes

1/* slugSelecor and contentSelector come in from the main page */
2
3let sidebarLinkSelector = ".accordion a[href='/" + slugSelector + "/']"
4// We'll let us make mistakes about whether slugs have / to start/finish them
5sidebarLinkSelector = sidebarLinkSelector.replace("//", "/").replace("//", "/")
6console.log('Selecting', sidebarLinkSelector)
7// class 'toc' next to sidebar link
8let sidebarTocSelector = sidebarLinkSelector + " + .toc"
9
10let sidebarLink = document.querySelector(sidebarLinkSelector)
11
12if(sidebarLink) {
13  sidebarLink.addEventListener('click', function(event) {
14    event.preventDefault()
15    event.stopPropagation()
16  })
17
18  try {
19    sidebarLink.classList.add('bg-primary')
20  } catch(e) {
21    // Failed to add background class, TODO 
22  }
23
24  let next;
25  let prev;
26
27  try {
28    prev = sidebarLink.parentElement.previousElementSibling.querySelector('a')
29  } catch(e) {
30    try {
31      prev = sidebarLink.parentElement.parentElement.parentElement.parentElement.previousElementSibling.querySelector('li:last-child a')
32    } catch(e) {
33      try {
34        prev = sidebarLink.parentElement.parentElement.previousElementSibling.previousElementSibling.querySelector("li:last-child li:last-child a")
35      } catch(e) {
36        prev = sidebarLink.parentElement.parentElement.parentElement.parentElement.parentElement.previousElementSibling.previousElementSibling.querySelector('a')
37      }
38    }
39  }
40
41  try {
42    next = sidebarLink.parentElement.nextElementSibling.querySelector('a')
43  } catch(e) {
44    try {
45      next = sidebarLink.parentElement.parentElement.parentElement.parentElement.nextElementSibling.querySelector('a')
46    } catch(e) {
47      next = sidebarLink.parentElement.parentElement.parentElement.parentElement.parentElement.nextElementSibling.nextElementSibling.querySelector('a')
48    }
49  }
50
51  try {
52    /* Add previous link at end of notebook */
53    if(prev) {
54      var prevLink = document.createElement('a')
55      prevLink.href = next.href
56      prevLink.classList = "btn btn-default"
57      prevLink.innerText = "← Previous: " + prev.innerText;
58      [...document.querySelectorAll(".prev-column")].forEach(function(element) {
59        element.appendChild(prevLink.cloneNode(true))
60      })
61    }
62
63    /* Add next link at end of notebook */
64    if(next) {
65      var nextLink = document.createElement('a')
66      nextLink.href = next.href
67      nextLink.classList = "btn btn-primary"
68      nextLink.innerText = "Next: " + next.innerText + " →";
69      [...document.querySelectorAll(".next-column")].forEach(function(element) {
70        element.appendChild(nextLink.cloneNode(true))
71      })
72    }
73  } catch(e) {
74    // Failed to add prev/next, probably not a notebook page
75  }
76
77}
78
79/* Scroll to element in the sidebar */
80function scrollToElement(element) {
81  if(!element) {
82    return;
83  }
84  element.scrollIntoView()
85
86  let headers = document.querySelectorAll(".sidebar-sticky");
87  headers = [...headers]
88
89  let currentHeight = 0;
90  for(let i = 1; i < headers.length; i++) {
91    currentHeight += headers[i-1].offsetHeight - (i > 1 ? 20 : -5);
92    if(element.offsetTop > currentHeight) {
93      break
94    }
95  }
96
97  setTimeout(function() {
98      let parent = document.getElementsByClassName('sidebar-holder')[0]
99      parent.scrollBy(0, -currentHeight - element.offsetHeight - 5)
100  }, 100)
101
102}
103
104try {
105  window.addEventListener("load", function() {
106    scrollToElement(sidebarLink)
107  })
108} catch(e) {
109
110}
111
112let headers = document.querySelectorAll(".accordion > h4")
113headers = [...headers]
114headers.forEach(function(header) {
115  header.addEventListener('click', function() {
116    scrollToElement(header)
117  })
118})
119
120let node = sidebarLink
121try {
122  while(node = node.parentElement) {
123    try{
124      // Check the checkbox that opens the nav section
125      node.previousElementSibling.previousElementSibling.checked = true
126    } catch(e) {
127      // No checkbox
128    }
129  }
130} catch(e) {
131  // Failed to find checkbox
132}
133
134
135// Sidebar TOC
136tocbot.init({
137  // Where to render the table of contents.
138  tocSelector: sidebarTocSelector,
139  // Where to grab the headings to build the table of contents.
140  contentSelector: contentSelector,
141  // Which headings to grab inside of the contentSelector element.
142  headingSelector: 'h2, h3, h4',
143  collapseDepth: 1,
144  orderedList: false,
145  // activeLinkClass: 'active',
146  // listClass: 'menu menu-nav',
147  // listItemClass: 'menu-item',
148  headingLabelCallback: function (label) {
149    return label.replace("#", "")
150  }
151});
152// document.querySelector(sidebarTocSelector).previousElementSibling.setAttribute('href', '#')
153
154function setSidebarStickyPosition() {
155  let headers = document.querySelectorAll(".sidebar-sticky");
156  headers = [...headers]
157  
158  let currentHeight = 0;
159  for(let i = 1; i < headers.length; i++) {
160    currentHeight += headers[i-1].offsetHeight - (i > 1 ? 20 : 0);
161    headers[i].style.top = currentHeight + 'px'
162  }
163}
164setInterval(setSidebarStickyPosition, 250)
165window.addEventListener("load", setSidebarStickyPosition);

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.