<commit_before>var Guidebar = {
  guidebar: "",
  documentHeight: 0,
  sectionheaders:[],

  // Get vertical position of the guide element within the guidebar
  // Returns percentage used in vertical positioning
  getElementOffset: function (el) {
    return (el.offsetTop / documentHeight * 100);
  },

  getDocumentHeight: function () { //  Needed for cross-browser compatibility
    return height =
      Math.max(
        document.body.scrollHeight,
        document.body.offsetHeight,
        document.documentElement.clientHeight,
        document.documentElement.scrollHeight,
        document.documentElement.offsetHeight
      );
  },

  initialize: function (tag) {
    documentHeight = Guidebar.getDocumentHeight();
    guidebar = document.getElementById("guidebar");
    sectionHeaders = document.getElementsByTagName(tag);

    var sectionText; // the section text
    var guide; // the element to be added to the DOM

    for ( var i = 0; i < sectionHeaders.length; i++ ) {

      guide = document.createElement("p");
      sectionText = document.createTextNode(sectionHeaders[i].innerHTML);

      // Add the element to the DOM
      guide.appendChild(sectionText);
      guidebar.appendChild(guide);

      // Position the guide within the guidebar
      guide.style.top = Guidebar.getElementOffset(sectionHeaders[i]) + "%";

      // Make the guide clickable
      guide.setAttribute("data-offset",sectionHeaders[i].offsetTop);
      guide.addEventListener("click", function () { window.scrollTo(0,this.getAttribute("data-offset")) }, false);

    }
  },

  resetGuidebar: function () {
    guidebar.innerHTML = "";
    Guidebar.createGuidebar();
  }
};

// If content is responsive, we will need to recalculate positions on resize
window.addEventListener("resize", Guidebar.resetGuidebar);
<commit_msg>fixed resizing bug and cleaned up some function names<commit_after>var Guidebar = {
  guidebar: "",
  documentHeight: 0,
  sectionheaders:[],
  selector: "",

  // Get vertical position of the guide element within the guidebar
  // Returns percentage used in vertical positioning
  getElementOffset: function (el) {
    return (el.offsetTop / documentHeight * 100);
  },

  getDocumentHeight: function () { //  Needed for cross-browser compatibility
    return height =
      Math.max(
        document.body.scrollHeight,
        document.body.offsetHeight,
        document.documentElement.clientHeight,
        document.documentElement.scrollHeight,
        document.documentElement.offsetHeight
      );
  },

  initialize: function (selector) {
    Guidebar.selector = selector;
    documentHeight = Guidebar.getDocumentHeight();
    guidebar = document.getElementById("guidebar");
    sectionHeaders = document.getElementsByTagName(selector);

    var sectionText; // the section text
    var guide; // the element to be added to the DOM

    for ( var i = 0; i < sectionHeaders.length; i++ ) {

      guide = document.createElement("p");
      sectionText = document.createTextNode(sectionHeaders[i].innerHTML);

      // Add the element to the DOM
      guide.appendChild(sectionText);
      guidebar.appendChild(guide);

      // Position the guide within the guidebar
      guide.style.top = Guidebar.getElementOffset(sectionHeaders[i]) + "%";

      // Make the guide clickable
      guide.setAttribute("data-offset",sectionHeaders[i].offsetTop);
      guide.addEventListener("click", function () { window.scrollTo(0,this.getAttribute("data-offset")) }, false);

    }
  },

  reset: function () {
    guidebar = document.getElementById("guidebar");
    while (guidebar.firstChild) {
        guidebar.removeChild(guidebar.firstChild);
    }
    Guidebar.initialize(Guidebar.selector);
  }
};

// If content is responsive, we need to recalculate positions on resize
window.addEventListener("resize", Guidebar.reset);

{'fraction_non_alphanumeric': 0.10972438897555903, 'fraction_numerical': 0.0031201248049922, 'mean_word_length': 3.3765642775881686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5747178', 'n_tokens_mistral': 1041, 'n_tokens_neox': 991, 'n_words': 256}