<commit_before>// Right nav highlighting
var sidebarBottom = document.getElementsByClassName("sidebar")[0].getBoundingClientRect().bottom;
var footerTop = document.getElementsByClassName("footer")[0].getBoundingClientRect().top;
var headerOffset = document.getElementsByClassName("container-fluid")[0].getBoundingClientRect().bottom;

var x = document.links.length;
var baseHref = document.getElementsByTagName('base')[0].href
for (i = 0; i < x; i++) {
  var munged = false;
  var thisHREF = document.links[i].href;
  var originalURL = "{{ page.url }}";
  if (thisHREF.indexOf(baseHref + "#") > -1) {
    // hash fix
    //console.log('BEFORE: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
    thisHREF = originalURL + thisHREF.replace(baseHref, "");
    //console.log('AFTER: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
  }
  if ((thisHREF.indexOf(window.location.hostname) > -1 || thisHREF.indexOf('http') == -1) && document.links[i].className.indexOf("nomunge") < 0) {
    munged = true;
    thisHREF = thisHREF.replace(".md", "/").replace("/index/", "/");
    document.links[i].setAttribute('href', thisHREF);
  }
}

// ensure that the left nav visibly displays the current topic
var current = document.getElementsByClassName("active currentPage");
if (current[0]) {
    var container = document.getElementsByClassName("sidebar");
    if (container[0]) {
      current[0].scrollIntoView(true);
      container[0].scrollTop -= 150;
    }
  }

function highlightRightNav(heading)
{
  if (heading == "title")
  {
    history.replaceState({},"Top of page on " + document.location.pathname,document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname);
    $("#my_toc a").each(function(){
      $(this).removeClass("active");
    });
    $("#sidebar-wrapper").animate({
      scrollTop: 0
    },800);
  } else {
    var targetAnchorHREF = document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname + "#" + heading;
    // make sure we aren't filtering out that heading level
    var noFilterFound = false;
    $("#my_toc a").each(function(){
      if (this.href==targetAnchorHREF) {
        noFilterFound = true;
      }
    });
    // now, highlight that heading
    if (noFilterFound)
    {
      $("#my_toc a").each(function(){
        //console.log("right-nav",this.href);
        if (this.href==targetAnchorHREF)
        {
          history.replaceState({},this.innerText,targetAnchorHREF);
          $(this).addClass("active");
          var sidebarOffset = (sidebarBottom > 200) ? 200 : headerOffset - 20;
          $("#sidebar-wrapper").animate({
            scrollTop: $("#sidebar-wrapper").scrollTop() + $(this).position().top - sidebarOffset
          },100);
          //document.getElementById("sidebar-wrapper").scrollTop = this.getBoundingClientRect().top - 200;
        } else {
          $(this).removeClass("active");
        }
      });
    }
  }
}
function checkNavSizes()
{
  sidebarBottom = document.getElementsByClassName("sidebar")[0].getBoundingClientRect().bottom;
  footerTop = document.getElementsByClassName("footer")[0].getBoundingClientRect().top;
  headerOffset = document.getElementsByClassName("container-fluid")[0].getBoundingClientRect().bottom;
  if (footerTop < sidebarBottom || (sidebarBottom < footerTop && sidebarBottom < $(window).height()))
  {
    // the footer is overlapping the sidebar
    var sidebarHeight = ((footerTop - headerOffset) < $(window).height()) ? (footerTop - headerOffset) : $(window).height();
    var tocNavHeight = (footerTop < $(window).height()) ? footerTop : $(window).height();
    document.getElementsByClassName("sidebar")[0].style.height = sidebarHeight + "px";
    document.getElementsByClassName("toc-nav")[0].style.height = footerTop + "px";
    highlightRightNav(currentHeading);
  }
}
$(window).resize(function() {
  checkNavSizes();
});
var currentHeading = "";
$(window).scroll(function(){
  checkNavSizes();
  var headingPositions = new Array();<commit_msg>Fix for JS error on homepage<commit_after>// Right nav highlighting
var sidebarObj = (document.getElementsByClassName("sidebar")[0]) ? document.getElementsByClassName("sidebar")[0] : document.getElementsByClassName("sidebar-home")[0]
var sidebarBottom = sidebarObj.getBoundingClientRect().bottom;
var footerTop = document.getElementsByClassName("footer")[0].getBoundingClientRect().top;
var headerOffset = document.getElementsByClassName("container-fluid")[0].getBoundingClientRect().bottom;

var x = document.links.length;
var baseHref = document.getElementsByTagName('base')[0].href
for (i = 0; i < x; i++) {
  var munged = false;
  var thisHREF = document.links[i].href;
  var originalURL = "{{ page.url }}";
  if (thisHREF.indexOf(baseHref + "#") > -1) {
    // hash fix
    //console.log('BEFORE: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
    thisHREF = originalURL + thisHREF.replace(baseHref, "");
    //console.log('AFTER: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
  }
  if ((thisHREF.indexOf(window.location.hostname) > -1 || thisHREF.indexOf('http') == -1) && document.links[i].className.indexOf("nomunge") < 0) {
    munged = true;
    thisHREF = thisHREF.replace(".md", "/").replace("/index/", "/");
    document.links[i].setAttribute('href', thisHREF);
  }
}

// ensure that the left nav visibly displays the current topic
var current = document.getElementsByClassName("active currentPage");
if (current[0]) {
    if (sidebarObj) {
      current[0].scrollIntoView(true);
      container[0].scrollTop -= 150;
    }
  }

function highlightRightNav(heading)
{
  if (heading == "title")
  {
    history.replaceState({},"Top of page on " + document.location.pathname,document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname);
    $("#my_toc a").each(function(){
      $(this).removeClass("active");
    });
    $("#sidebar-wrapper").animate({
      scrollTop: 0
    },800);
  } else {
    var targetAnchorHREF = document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname + "#" + heading;
    // make sure we aren't filtering out that heading level
    var noFilterFound = false;
    $("#my_toc a").each(function(){
      if (this.href==targetAnchorHREF) {
        noFilterFound = true;
      }
    });
    // now, highlight that heading
    if (noFilterFound)
    {
      $("#my_toc a").each(function(){
        //console.log("right-nav",this.href);
        if (this.href==targetAnchorHREF)
        {
          history.replaceState({},this.innerText,targetAnchorHREF);
          $(this).addClass("active");
          var sidebarOffset = (sidebarBottom > 200) ? 200 : headerOffset - 20;
          $("#sidebar-wrapper").animate({
            scrollTop: $("#sidebar-wrapper").scrollTop() + $(this).position().top - sidebarOffset
          },100);
          //document.getElementById("sidebar-wrapper").scrollTop = this.getBoundingClientRect().top - 200;
        } else {
          $(this).removeClass("active");
        }
      });
    }
  }
}
function checkNavSizes()
{
  sidebarBottom = sidebarObj.getBoundingClientRect().bottom;
  footerTop = document.getElementsByClassName("footer")[0].getBoundingClientRect().top;
  headerOffset = document.getElementsByClassName("container-fluid")[0].getBoundingClientRect().bottom;
  if (footerTop < sidebarBottom || (sidebarBottom < footerTop && sidebarBottom < $(window).height()))
  {
    // the footer is overlapping the sidebar
    var sidebarHeight = ((footerTop - headerOffset) < $(window).height()) ? (footerTop - headerOffset) : $(window).height();
    var tocNavHeight = (footerTop < $(window).height()) ? footerTop : $(window).height();
    document.getElementsByClassName("sidebar")[0].style.height = sidebarHeight + "px";
    document.getElementsByClassName("toc-nav")[0].style.height = footerTop + "px";
    highlightRightNav(currentHeading);
  }
}
$(window).resize(function() {
  checkNavSizes();
});
var currentHeading = "";
$(window).scroll(function(){
  checkNavSizes();
  var headingPositions = new Array();
{'fraction_non_alphanumeric': 0.17247617898926546, 'fraction_numerical': 0.009407791581232661, 'mean_word_length': 4.034608378870674, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1003408', 'n_tokens_mistral': 2543, 'n_tokens_neox': 2468, 'n_words': 436}