<commit_before>//alert();

// Nested navigation by https://www.w3.org/ 
var MainNav = function (domNode) {
  this.rootNode = domNode;
  this.triggerNodes = [];
  this.controlledNodes = [];
  this.openIndex = null;
  this.useArrowKeys = true;
};
MainNav.prototype.init = function () {
  var buttons = this.rootNode.querySelectorAll('button[aria-expanded][aria-controls]');
  for (var i = 0; i < buttons.length; i++) {
    var button = buttons[i];
    var menu = button.parentNode.querySelector('ul');
    if (menu) {
      // save ref to button and controlled menu
      this.triggerNodes.push(button);
      this.controlledNodes.push(menu);
      // collapse menus
      button.setAttribute('aria-expanded', 'false');
      this.toggleMenu(menu, false);
      // attach event listeners
      menu.addEventListener('keydown', this.handleMenuKeyDown.bind(this));
      button.addEventListener('click', this.handleButtonClick.bind(this));
      button.addEventListener('keydown', this.handleButtonKeyDown.bind(this));
    }
  }
  this.rootNode.addEventListener('focusout', this.handleBlur.bind(this));
};
MainNav.prototype.toggleMenu = function (domNode, show) {
  if (domNode) {
    domNode.style.display = show ? 'block' : 'none';
  }
};
MainNav.prototype.toggleExpand = function (index, expanded) {
  // close open menu, if applicable
  if (this.openIndex !== index) {
    this.toggleExpand(this.openIndex, false);
  }
  // handle menu at called index
  if (this.triggerNodes[index]) {
    this.openIndex = expanded ? index : null;
    this.triggerNodes[index].setAttribute('aria-expanded', expanded);
    this.toggleMenu(this.controlledNodes[index], expanded);
  }
};
MainNav.prototype.controlFocusByKey = function (keyboardEvent, nodeList, currentIndex) {
  switch (keyboardEvent.key) {
    case 'ArrowUp':
    case 'ArrowLeft':
      keyboardEvent.preventDefault();
      if (currentIndex > -1) {
        var prevIndex = Math.max(0, currentIndex - 1);
        nodeList[prevIndex].focus();
      }
      break;
    case 'ArrowDown':
    case 'ArrowRight':
      keyboardEvent.preventDefault();
      if (currentIndex > -1) {
        var nextIndex = Math.min(nodeList.length - 1, currentIndex + 1);
        nodeList[nextIndex].focus();
      }
      break;
    case 'Home':
      keyboardEvent.preventDefault();
      nodeList[0].focus();
      break;
    case 'End':
      keyboardEvent.preventDefault();
      nodeList[nodeList.length - 1].focus();
      break;
  }
};
/* Event Handlers */
MainNav.prototype.handleBlur = function (event) {
  var menuContainsFocus = this.rootNode.contains(event.relatedTarget);
  if (!menuContainsFocus && this.openIndex !== null) {
    this.toggleExpand(this.openIndex, false);
  }
};
MainNav.prototype.handleButtonKeyDown = function (event) {
  var targetButtonIndex = this.triggerNodes.indexOf(document.activeElement);
  // close on escape
  if (event.key === 'Escape') {
    this.toggleExpand(this.openIndex, false);
  }
  // move focus into the open menu if the current menu is open
  else if (this.useArrowKeys && this.openIndex === targetButtonIndex && event.key === 'ArrowDown') {
    event.preventDefault();
    this.controlledNodes[this.openIndex].querySelector('a').focus();
  }
  // handle arrow key navigation between top-level buttons, if set
  else if (this.useArrowKeys) {
    this.controlFocusByKey(event, this.triggerNodes, targetButtonIndex);
  }
};
MainNav.prototype.handleButtonClick = function (event) {
  var button = event.target;
  var buttonIndex = this.triggerNodes.indexOf(button);
  var buttonExpanded = button.getAttribute('aria-expanded') === 'true';
  this.toggleExpand(buttonIndex, !buttonExpanded);
};
MainNav.prototype.handleMenuKeyDown = function (event) {
  if (this.openIndex === null) {
    return;
  }
  var menuLinks = Array.prototype.slice.call(this.controlledNodes[this.openIndex].querySelectorAll('a'));
  var currentIndex = menuLinks.indexOf(document.activeElement);
  // close on escape
  if (event.key === 'Escape') {
    this.triggerNodes[this.openIndex].focus();
    this.toggleExpand(this.openIndex, false);
  }
  // handle arrow key navigation within menu links, if set
  else if (this.useArrowKeys) {
    this.controlFocusByKey(event, menuLinks, currentIndex);
  }
};
// switch on/off arrow key navigation
MainNav.prototype.updateKeyControls = function (useArrowKeys) {
  this.useArrowKeys = useArrowKeys;
};
/* Initialize Main Menus */
window.addEventListener('load', function (event) {
  var menus = document.querySelectorAll('.mainnav');
  var mainMenus = [];
  for (var i = 0; i < menus.length; i++) {
    mainMenus[i] = new MainNav(menus[i]);
    mainMenus[i].init();
  }
  // listen to arrow key checkbox
  /*
  var arrowKeySwitch = document.getElementById('arrow-behavior-switch');
  arrowKeySwitch.addEventListener('change', function (event) {
    var checked = arrowKeySwitch.checked;
    for (var i = 0; i < mainMenus.length; i++) {
      mainMenus[i].updateKeyControls(checked);
    }
  });
  */
  // fake link behavior
  var links = document.querySelectorAll('[href="#design-system"]');
  var examplePageHeading = document.getElementById('design-system');
  for (var i = 0; i < links.length; i++) {
    links[i].addEventListener('click', function (event) {
      var pageTitle = event.target.innerText;
      examplePageHeading.innerText = pageTitle;
      // handle aria-current
      for (var n = 0; n < links.length; n++) {
        links[n].removeAttribute('aria-current');
      }
      this.setAttribute('aria-current', 'page');
    });
  }
}, false);

// Accordion by https://inclusivedesignprinciples.org/
(function() {
  var translations = {
    en: {
      EXPAND: "Expand all",
      COLLAPSE: "Collapse all"
    },
    es: {
      EXPAND: "muestra todo",
      COLLAPSE: "esconde todos"
    },
    fr: {
      EXPAND: "ouvrir tout",
      COLLAPSE: "fermer tout"
    },
  };
  var pageLang = document.querySelector('html').getAttribute('lang');
  var strings = translations[pageLang] || translations['en'];
  function collapse(toggle, target) {
    toggle.setAttribute('aria-expanded', 'false');
    target.hidden = true;
  }
  function expand(toggle, target) {
    toggle.setAttribute('aria-expanded', 'true');
    target.hidden = false;
  }
  var toggles = document.querySelectorAll('[data-expands]');
  [].forEach.call(toggles, function(toggle) {<commit_msg>Nested navigation erased from js.<commit_after>//alert();

// Accordion by https://inclusivedesignprinciples.org/
(function() {
  var translations = {
    en: {
      EXPAND: "Expand all",
      COLLAPSE: "Collapse all"
    },
    es: {
      EXPAND: "muestra todo",
      COLLAPSE: "esconde todos"
    },
    fr: {
      EXPAND: "ouvrir tout",
      COLLAPSE: "fermer tout"
    },
  };
  var pageLang = document.querySelector('html').getAttribute('lang');
  var strings = translations[pageLang] || translations['en'];
  function collapse(toggle, target) {
    toggle.setAttribute('aria-expanded', 'false');
    target.hidden = true;
  }
  function expand(toggle, target) {
    toggle.setAttribute('aria-expanded', 'true');
    target.hidden = false;
  }
  var toggles = document.querySelectorAll('[data-expands]');
  [].forEach.call(toggles, function(toggle) {
{'fraction_non_alphanumeric': 0.14558274574865201, 'fraction_numerical': 0.0019355730678833126, 'mean_word_length': 3.5813806206459784, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, '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': '6406993', 'n_tokens_mistral': 2221, 'n_tokens_neox': 2228, 'n_words': 469}