<commit_before>/* eslint-env browser */

'use strict';

(function() {
  function toStorageKey(el, suffix) {
    return 'splitter-' + el.id + '-' + suffix;
  }

  // Initializes a splitter element by patching the DOM and installing event handlers.
  function initializeSplitter(el) {
    var handle = document.createElement('div');
    handle.classList.add('handle');
    el.appendChild(handle);

    var isVertical = el.classList.contains('vertical');
    var dragging = false;
    var prevEl = el.previousElementSibling;
    var nextEl = el.nextElementSibling;
    var parentEl = el.parentElement;

    var dragOverlay = document.querySelector('#dragOverlay');

    // Set the size of one of the splitter element's siblings to the given value.
    // `which` must be one of 'next' or 'prev'.
    function setSiblingSize(which, value) {
      var node = which === 'prev' ? prevEl : nextEl;
      node.style.flexGrow = value;
      if (el.id) {
        localStorage.setItem(toStorageKey(el, which), value);
      }
    }

    handle.onmousedown = function(e) {
      if (!el.classList.contains('disabled')) {
        dragging = true;
        dragOverlay.style.display = 'block';
        dragOverlay.style.cursor = isVertical ? 'ew-resize' : 'ns-resize';
        e.preventDefault();
      }
    };
    window.addEventListener('mousemove', function(e) {
      var parentElBounds = parentEl.getBoundingClientRect();
      var relativeX = e.clientX - parentElBounds.left;
      var relativeY = e.clientY - parentElBounds.top;

      var innerSize = isVertical ? parentElBounds.width : parentElBounds.height;
      var pos = isVertical ? relativeX : relativeY;

      if (dragging && pos > 0 && pos < innerSize) {
        setSiblingSize('next', innerSize - pos);
        setSiblingSize('prev', pos);
        e.preventDefault();
        e.stopPropagation();
      }
    });
    window.addEventListener('mouseup', function(e) {
      dragging = false;
      dragOverlay.removeAttribute('style');
    });

    // Reset the sizes to 50% when the handle is double-clicked.
    handle.ondblclick = function(e) {
      setSiblingSize('next', 1);
      setSiblingSize('prev', 1);
    };

    // Restore the sizes from localStorage.
    if (el.id) {
      var nextPos = localStorage.getItem(toStorageKey(el, 'next'));
      var prevPos = localStorage.getItem(toStorageKey(el, 'prev'));
      if (nextPos && prevPos) {
        nextEl.style.flexGrow = nextPos;<commit_msg>Visualizer: Prevent error due to splitter changes.<commit_after>/* eslint-env browser */

'use strict';

(function() {
  function toStorageKey(el, suffix) {
    return 'splitter-' + el.id + '-' + suffix;
  }

  // Initializes a splitter element by patching the DOM and installing event handlers.
  function initializeSplitter(el) {
    var handle = document.createElement('div');
    handle.classList.add('handle');
    el.appendChild(handle);

    var isVertical = el.classList.contains('vertical');
    var dragging = false;
    var prevEl = el.previousElementSibling;
    var nextEl = el.nextElementSibling;
    var parentEl = el.parentElement;

    var dragOverlay = document.querySelector('#dragOverlay');

    // Set the size of one of the splitter element's siblings to the given value.
    // `which` must be one of 'next' or 'prev'.
    function setSiblingSize(which, value) {
      var node = which === 'prev' ? prevEl : nextEl;
      node.style.flexGrow = value;
      if (el.id) {
        localStorage.setItem(toStorageKey(el, which), value);
      }
    }

    handle.onmousedown = function(e) {
      if (!el.classList.contains('disabled')) {
        dragging = true;
        dragOverlay.style.display = 'block';
        dragOverlay.style.cursor = isVertical ? 'ew-resize' : 'ns-resize';
        e.preventDefault();
      }
    };
    window.addEventListener('mousemove', function(e) {
      var parentElBounds = parentEl.getBoundingClientRect();
      var relativeX = e.clientX - parentElBounds.left;
      var relativeY = e.clientY - parentElBounds.top;

      var innerSize = isVertical ? parentElBounds.width : parentElBounds.height;
      var pos = isVertical ? relativeX : relativeY;

      if (dragging && pos > 0 && pos < innerSize) {
        setSiblingSize('next', innerSize - pos);
        setSiblingSize('prev', pos);
        e.preventDefault();
        e.stopPropagation();
      }
    });
    window.addEventListener('mouseup', function(e) {
      dragging = false;
      dragOverlay.removeAttribute('style');
    });

    // Reset the sizes to 50% when the handle is double-clicked.
    handle.ondblclick = function(e) {
      setSiblingSize('next', 1);
      setSiblingSize('prev', 1);
    };

    // Restore the sizes from localStorage.
    if (el.id) {
      var nextPos = localStorage.getItem(toStorageKey(el, 'next'));
      var prevPos = localStorage.getItem(toStorageKey(el, 'prev'));
      if (nextPos && nextEl) {
        nextEl.style.flexGrow = nextPos;
      }
      if (prevPos && prevEl) {
{'fraction_non_alphanumeric': 0.1275827482447342, 'fraction_numerical': 0.0020060180541624875, 'mean_word_length': 2.8472222222222223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5595650', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1498, 'n_words': 364}