PageSourceSearch

https://seclists.org/shared/js/nst.js?v=2

js seclists.org collected 2026-09-24 07:30:31 UTC 2,235 bytes, 76 lines download raw bytes

1// https://gist.github.com/treyhuffine/2ced8b8c503e5246e2fd258ddbd21b8c
2const debounce = (func, wait) => {
3 let timeout;
4 return function executedFunction(...args) {
5  const later = () => {
6   clearTimeout(timeout);
7   func(...args);
8  };
9  clearTimeout(timeout);
10  timeout = setTimeout(later, wait);
11 };
12};
13function do_menu(e) {
14 document.getElementById('menu').classList.toggle('open');
15 e.preventDefault();
16}
17function reg(e) {
18 document.getElementById('menu-open').addEventListener('click', do_menu);
19 document.getElementById('menu-close').addEventListener('click', do_menu);
20 // Hide global nav for current site
21 let gn = document.getElementById('nst-gnav');
22 Array.prototype.forEach.call(gn.getElementsByTagName('a'), (a)=>{
23   if(document.location.hostname === a.hostname){
24    a.style.display='none';
25   }
26  });
27 gn.style.height = 'auto';
28 gn.style.visibility = 'visible';
29 let sn = document.getElementById('nst-sitenav');
30 if (sn) {
31  const mql_narrow = window.matchMedia('(max-width: 450px)');
32  function move_nav(mql) {
33   if (mql.matches){
34    document.getElementById('nst-head').appendChild(sn);
35    sn.style.margin='0px';
36    sn.style.display='flex';
37    return true;
38   }
39   return false;
40  }
41  if (!move_nav(mql_narrow)) {
42   mql_narrow.addEventListener('change', move_nav, {once:true});
43  }
44  let kids = sn.getElementsByTagName('a');
45  let lastkid;
46  Array.prototype.forEach.call(kids, (a) => {
47    if (document.location.href === a.href) {
48      // Mark current page
49     a.classList.add('here');
50    }
51    lastkid=a;
52   });
53  let kstyle = document.createElement('style');
54  document.head.appendChild(kstyle);
55  let ksheet = kstyle.sheet;
56  let kfunc = function() {
57    if (ksheet.cssRules.length > 0) {
58     ksheet.deleteRule(0);
59    }
60    if (lastkid.offsetTop > sn.offsetTop) {
61     let nrows = Math.floor((lastkid.offsetTop - sn.offsetTop) / lastkid.offsetHeight) + 1;
62     ksheet.insertRule('#nst-sitenav > a { flex-basis: '+ Math.floor(nrows * 100 / (kids.length + 1)) +'%; }', 0);
63    }
64   };
65  kfunc();
66  var do_resize = debounce(kfunc, 250);
67  window.addEventListener('resize', do_resize);
68 } 
69}
70
71if (document.readyState !== "loading") {
72 reg();
73}
74else {
75 document.addEventListener('DOMContentLoaded', reg);
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.