<commit_before>function pretty(obj) {
  var objs = [], keys = [];

  return JSON.stringify(obj, function (k, v) {
    var seen;

    if (v instanceof Object) {
      if ( (seen = objs.indexOf(v)) == -1 ) {
        objs.push(v);
        keys.push(k || 'ROOT');

        return v;
      }

      return v + ' (ref to ' + keys[seen] + ')';
    }

    return v;
  }, 2);
}

function Konsole() {
  var _this = this;

  var _container = document.createElement('div'),
    _title = document.createElement('span'),
    _toggle = document.createElement('span'),
    _resize = document.createElement('span'),
    _clear = document.createElement('span'),
    _log = document.createElement('pre');

  var _minimized = false;

  var _resizeData = {
    initialHeight: 480,
    currentHeight: 480,
    dragY: null,
    dragDelta: 0
  };

  _container.setAttribute('class', 'konsole-container');
  _container.style.width = '97%';

  _title.setAttribute('class', 'konsole-control konsole-title');
  _title.innerHTML = 'Konsole';
  _title.addEventListener('click', function (ev) {
    if (_log.scrollTop === 0) {
      // if at the top of log, scroll to the bottom
      _log.scrollTop = _log.scrollHeight;
    } else {
      // when anywhere in log, scroll to the top
      _log.scrollTop = 0;
    }
  });

  _toggle.setAttribute('class', 'konsole-control konsole-toggle');
  _toggle.innerHTML = 'Minimize';
  _toggle.addEventListener('click', function (ev) {
    if (_log.style.display === 'none') {
      _this.show();
    } else {
      _this.minimize();
    }
  });

  _resize.setAttribute('class', 'konsole-control konsole-resize');
  _resize.innerHTML = 'Resize';
  // TODO: add pointing device support
  _resize.addEventListener('touchstart', function (ev) {
    _resizeData.dragY = null;
    _resizeData.dragDelta = 0;
  });
  _resize.addEventListener('touchmove', function (ev) {
    if (_resizeData.dragY) {
      _resizeData.dragDelta = _resizeData.dragY - ev.touches[0].clientY;
      _resizeData.currentHeight += _resizeData.dragDelta;
      _log.style.height = _resizeData.currentHeight + 'px';
    }

    _resizeData.dragY = ev.touches[0].clientY;

    ev.preventDefault();
  });

  _clear.setAttribute('class', 'konsole-control konsole-clear');
  _clear.innerHTML = 'Clear';
  _clear.addEventListener('click', function (ev) {
    _this.clear();
  });

  _log.setAttribute('class', 'konsole-log');
  _log.style.height = _resizeData.initialHeight + 'px';

  _container.appendChild(_title);<commit_msg>Tweak resize code in an effort to maybe support pointing devices<commit_after>function pretty(obj) {
  var objs = [], keys = [];

  return JSON.stringify(obj, function (k, v) {
    var seen;

    if (v instanceof Object) {
      if ( (seen = objs.indexOf(v)) == -1 ) {
        objs.push(v);
        keys.push(k || 'ROOT');

        return v;
      }

      return v + ' (ref to ' + keys[seen] + ')';
    }

    return v;
  }, 2);
}

function Konsole() {
  var _this = this;

  var _container = document.createElement('div'),
    _title = document.createElement('span'),
    _toggle = document.createElement('span'),
    _resize = document.createElement('span'),
    _clear = document.createElement('span'),
    _log = document.createElement('pre');

  var _minimized = false;

  var _resizeData = {
    initialHeight: 480,
    currentHeight: 480,
    dragY: 0,
    dragDelta: 0,
    resizing: false
  };

  _container.setAttribute('class', 'konsole-container');
  _container.style.width = '97%';

  _title.setAttribute('class', 'konsole-control konsole-title');
  _title.innerHTML = 'Konsole';
  _title.addEventListener('click', function (ev) {
    if (_log.scrollTop === 0) {
      // if at the top of log, scroll to the bottom
      _log.scrollTop = _log.scrollHeight;
    } else {
      // when anywhere in log, scroll to the top
      _log.scrollTop = 0;
    }
  });

  _toggle.setAttribute('class', 'konsole-control konsole-toggle');
  _toggle.innerHTML = 'Minimize';
  _toggle.addEventListener('click', function (ev) {
    if (_log.style.display === 'none') {
      _this.show();
    } else {
      _this.minimize();
    }
  });

  _resize.setAttribute('class', 'konsole-control konsole-resize');
  _resize.innerHTML = 'Resize';
  // TODO: add pointing device support
  _resize.addEventListener('touchstart', function (ev) {
    _resizeData.dragY = ev.touches[0].clientY;
    _resizeData.dragDelta = 0;
    _resizeData.resizing = true;

    //kpp(_resizeData, 'start'); // mmm, tasty dogfood
  });
  _resize.addEventListener('touchmove', function (ev) {
    if (!_resizeData.resizing) {
      return;
    }

    _resizeData.dragDelta = _resizeData.dragY - ev.touches[0].clientY;
    _resizeData.currentHeight += _resizeData.dragDelta;
    _log.style.height = _resizeData.currentHeight + 'px';
    _resizeData.dragY = ev.touches[0].clientY;

    //kpp(_resizeData, 'move');

    ev.preventDefault();
  });
  _resize.addEventListener('touchend', function (ev) {
    _resizeData.resizing = false;

    //kpp(_resizeData, 'end');
  });

  _clear.setAttribute('class', 'konsole-control konsole-clear');
  _clear.innerHTML = 'Clear';
  _clear.addEventListener('click', function (ev) {
    _this.clear();
  });

  _log.setAttribute('class', 'konsole-log');
  _log.style.height = _resizeData.initialHeight + 'px';

  _container.appendChild(_title);
{'fraction_non_alphanumeric': 0.1530402245088868, 'fraction_numerical': 0.006361085126286249, 'mean_word_length': 3.206136900078678, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5575819', 'n_tokens_mistral': 1762, 'n_tokens_neox': 1709, 'n_words': 356}