<commit_before>document.domain = 'literasee.io';
setTimeout(createMaximizeButtons, 5000);

function createMaximizeButtons () {
  document.querySelectorAll('iframe').forEach(i => {
    var doc = i.contentWindow.document;
    var id = parseQueryString(doc.location.search).childId;

    var b = document.createElement('button');
    b.setAttribute('id', 'maxBtn');
    b.innerText = 'maximize';
    b.onclick = function (e) {
      if (e.target.innerText === 'maximize') {
        max(id);
      } else {
        min(id);
      }
    }
    doc.body.appendChild(b);
  })
}

function parseQueryString (str) {
  str = str || window.location.search;
  if (str.substr(0, 1) === '?') str = str.substr(1);

  if (!str) return {};

  return str.split('&').reduce(function (prev, pair) {
    prev[pair.split('=')[0]] = pair.split('=')[1];
    return prev;
  }, {});
}

function max (id) {
  if (id.substr(0, 1) !== '#') id = '#' + id;

  var d = document.querySelector(id);
  d.style.setProperty('position', 'fixed');
  d.style.setProperty('top', 0);
  d.style.setProperty('right', 0);
  d.style.setProperty('bottom', 0);
  d.style.setProperty('left', 0);
  d.style.setProperty('margin', '0 2em');
  d.style.setProperty('display', 'flex');
  d.style.setProperty('flex-direction', 'column');
  d.style.setProperty('justify-content', 'center');

  var bg = document.createElement('div');
  bg.style.setProperty('position', 'absolute');
  bg.style.setProperty('background', 'white');
  bg.style.setProperty('opacity', 0.96);
  bg.style.setProperty('width', '100%');
  bg.style.setProperty('height', '100%');
  bg.onclick = min.bind(null, id);

  var i = d.querySelector('iframe');
  i.style.setProperty('position', 'relative');

  i.contentWindow.document.onkeyup = function (e) {
    if (e.keyCode === 27) min(id);
  }
  i.contentWindow.document.querySelector('#maxBtn').innerText = 'minimize';

  d.insertBefore(bg, i);
}

function min (id) {
  if (id.substr(0, 1) !== '#') id = '#' + id;

  var d = document.querySelector(id);
  d.style.removeProperty('position');
  d.style.removeProperty('top');
  d.style.removeProperty('right');
  d.style.removeProperty('bottom');
  d.style.removeProperty('left');
  d.style.removeProperty('margin');

  d.removeChild(d.querySelector('div'));

  var i = d.querySelector('iframe');
  i.style.removeProperty('position');
  i.contentWindow.document.onkeyup = null;
  i.contentWindow.document.querySelector('#maxBtn').innerText = 'maximize';
}
<commit_msg>Ensure modal is in front, fix padding/margin<commit_after>document.domain = 'literasee.io';
setTimeout(createMaximizeButtons, 5000);

function createMaximizeButtons () {
  document.querySelectorAll('iframe').forEach(i => {
    var doc = i.contentWindow.document;
    var id = parseQueryString(doc.location.search).childId;

    var b = document.createElement('button');
    b.setAttribute('id', 'maxBtn');
    b.innerText = 'maximize';
    b.onclick = function (e) {
      if (e.target.innerText === 'maximize') {
        max(id);
      } else {
        min(id);
      }
    }
    doc.body.appendChild(b);
  })
}

function parseQueryString (str) {
  str = str || window.location.search;
  if (str.substr(0, 1) === '?') str = str.substr(1);

  if (!str) return {};

  return str.split('&').reduce(function (prev, pair) {
    prev[pair.split('=')[0]] = pair.split('=')[1];
    return prev;
  }, {});
}

function max (id) {
  if (id.substr(0, 1) !== '#') id = '#' + id;

  var d = document.querySelector(id);
  d.style.setProperty('z-index', 3000);
  d.style.setProperty('position', 'fixed');
  d.style.setProperty('top', 0);
  d.style.setProperty('right', 0);
  d.style.setProperty('bottom', 0);
  d.style.setProperty('left', 0);
  d.style.setProperty('display', 'flex');
  d.style.setProperty('flex-direction', 'column');
  d.style.setProperty('justify-content', 'center');

  var bg = document.createElement('div');
  bg.style.setProperty('position', 'absolute');
  bg.style.setProperty('background', 'white');
  bg.style.setProperty('opacity', 0.96);
  bg.style.setProperty('width', '100%');
  bg.style.setProperty('height', '100%');
  bg.onclick = min.bind(null, id);

  var i = d.querySelector('iframe');
  i.style.setProperty('position', 'relative');
  i.style.setProperty('padding', '0 2em');

  i.contentWindow.document.onkeyup = function (e) {
    if (e.keyCode === 27) min(id);
  }
  i.contentWindow.document.querySelector('#maxBtn').innerText = 'minimize';

  d.insertBefore(bg, i);
}

function min (id) {
  if (id.substr(0, 1) !== '#') id = '#' + id;

  var d = document.querySelector(id);
  d.style.removeProperty('position');
  d.style.removeProperty('top');
  d.style.removeProperty('right');
  d.style.removeProperty('bottom');
  d.style.removeProperty('left');
  d.style.removeProperty('margin');

  d.removeChild(d.querySelector('div'));

  var i = d.querySelector('iframe');
  i.style.removeProperty('position');
  i.style.removeProperty('padding');
  i.contentWindow.document.onkeyup = null;
  i.contentWindow.document.querySelector('#maxBtn').innerText = 'maximize';
}

{'fraction_non_alphanumeric': 0.20130254588513913, 'fraction_numerical': 0.01263074797710677, 'mean_word_length': 4.192622950819672, 'pattern_counts': {'":': 0, '<': 3, '<?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': '194190', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1735, 'n_words': 289}