From Walloping Owl, 2 Years ago, written in JavaScript.
Embed
  1. (function($) {
  2. $(document).ready(function(){
  3.  
  4.   // putting lines by the pre blocks
  5.   $("pre").each(function(){
  6.     var pre = $(this).text().split("\n");
  7.     var lines = new Array(pre.length+1);
  8.     for(var i = 0; i < pre.length; i++) {
  9.       var wrap = Math.floor(pre[i].split("").length / 70)
  10.       if (pre[i]==""&&i==pre.length-1) {
  11.         lines.splice(i, 1);
  12.       } else {
  13.         lines[i] = i+1;
  14.         for(var j = 0; j < wrap; j++) {
  15.           lines[i] += "\n";
  16.         }
  17.       }
  18.     }
  19.     $(this).before("<pre class='lines'>" + lines.join("\n") + "</pre>");
  20.   });
  21.  
  22.   var headings = [];
  23.  
  24.   var collectHeaders = function(){
  25.     headings.push({"top":$(this).offset().top - 15,"text":$(this).text()});
  26.   }
  27.  
  28.   if($(".markdown-body h1").length > 1) $(".markdown-body h1").each(collectHeaders)
  29.   else if($(".markdown-body h2").length > 1) $(".markdown-body h2").each(collectHeaders)
  30.   else if($(".markdown-body h3").length > 1) $(".markdown-body h3").each(collectHeaders)
  31.  
  32.   $(window).scroll(function(){
  33.     if(headings.length==0) return true;
  34.     var scrolltop = $(window).scrollTop() || 0;
  35.     if(headings[0] && scrolltop < headings[0].top) {
  36.       $(".current-section").css({"opacity":0,"visibility":"hidden"});
  37.       return false;
  38.     }
  39.     $(".current-section").css({"opacity":1,"visibility":"visible"});
  40.     for(var i in headings) {
  41.       if(scrolltop >= headings[i].top) {
  42.         $(".current-section .name").text(headings[i].text);
  43.       }
  44.     }
  45.   });
  46.  
  47.   $(".current-section a").click(function(){
  48.     $(window).scrollTop(0);
  49.     return false;
  50.   })
  51. });
  52. })(jQuery)

A PHP Error was encountered

Severity: Core Warning

Message: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/mcrypt.so' (tried: /usr/lib/php/20170718/mcrypt.so (/usr/lib/php/20170718/mcrypt.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so (/usr/lib/php/20170718//usr/lib/php/20170718/mcrypt.so.so: cannot open shared object file: No such file or directory))

Filename: Unknown

Line Number: 0

Backtrace: