PageSourceSearch

https://ralph-wang.github.io/js/auto-toc.js

js ralph-wang.github.io collected 2026-10-03 09:49:15 UTC 582 bytes, 28 lines download raw bytes

1;
2var sections = $('div.entry-content h2, div.entry-content h3');
3
4var titles = $('ul#markdown-toc a');
5
6if (sections.length == titles.length) {
7  titles[0].className = 'toc-active';
8
9  var tops = [];
10
11  sections.each(function () {
12    var that = $(this);
13    tops.push(that.offset().top);
14  });
15
16  $(window).scroll(function () {
17    var that = $(this);
18    var nowTop = that.scrollTop();
19    var i;
20    for (i = 0; i < tops.length; i++) {
21      if (nowTop <= tops[i]) {
22        titles.removeClass();
23        titles[i].className = 'toc-active';
24        break;
25      }
26    }
27  });
28}

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.