<commit_before>var hiddenMediaRelation = {};

if (!DISABLE_JS) {

  var shownFiles = document.getElementsByClassName('uploadCell');

  for (var i = 0; i < shownFiles.length; i++) {
    processFileForHiding(shownFiles[i]);
  }

  var hiddenMedia = getHiddenMedia();

  for (i = 0; i < hiddenMedia.length; i++) {
    updateHiddenFiles(hiddenMedia[i], true);
  }

}

function getHiddenMedia() {

  var hiddenMedia = localStorage.hiddenMedia;

  if (hiddenMedia) {
    hiddenMedia = JSON.parse(hiddenMedia);
  } else {
    hiddenMedia = [];
  }

  return hiddenMedia;

}

function updateHiddenFiles(file, hiding) {

  var mediaObject = hiddenMediaRelation[file] || [];

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

    var element = mediaObject[i];

    element.button.innerHTML = hiding ? '(Show file)' : '(Hide file)';

    if (element.element.style.display === 'none' && hiding) {
      element.element.parentNode.getElementsByClassName('hideLink')[0]
          .onclick();
    }

    element.element.style.display = hiding ? 'none' : 'inline';
  }

}

function processFileForHiding(file) {

  var nameLink = file.getElementsByClassName('nameLink')[0];

  var hidingButton = document.createElement('span');
  hidingButton.innerHTML = '(Hide file)';
  hidingButton.setAttribute('class', 'hideFileButton');

  var fileName = nameLink.href.split('/');
  fileName = fileName[fileName.length - 1];

  var mediaObject = hiddenMediaRelation[fileName] || [];

  mediaObject.push({
    button : hidingButton,
    element : file.getElementsByClassName('imgLink')[0]
  });

  hiddenMediaRelation[fileName] = mediaObject;

  hidingButton.onclick = function() {

    var hiddenMedia = getHiddenMedia();

    var alreadyHidden = hiddenMedia.indexOf(fileName) > -1;

    if (alreadyHidden) {
      hiddenMedia.splice(hiddenMedia.indexOf(fileName), 1);
    } else {
      hiddenMedia.push(fileName);
    }

    localStorage.hiddenMedia = JSON.stringify(hiddenMedia);

    updateHiddenFiles(fileName, !alreadyHidden);

  };

  nameLink.parentNode.insertBefore(hidingButton, nameLink.nextSibling);

}<commit_msg>Fixed a bug with hidden files.<commit_after>var hiddenMediaRelation = {};

if (!DISABLE_JS) {

  var shownFiles = document.getElementsByClassName('uploadCell');

  for (var i = 0; i < shownFiles.length; i++) {
    processFileForHiding(shownFiles[i]);
  }

  var hiddenMedia = getHiddenMedia();

  for (i = 0; i < hiddenMedia.length; i++) {
    updateHiddenFiles(hiddenMedia[i], true);
  }

}

function getHiddenMedia() {

  var hiddenMedia = localStorage.hiddenMedia;

  if (hiddenMedia) {
    hiddenMedia = JSON.parse(hiddenMedia);
  } else {
    hiddenMedia = [];
  }

  return hiddenMedia;

}

function updateHiddenFiles(file, hiding) {

  var mediaObject = hiddenMediaRelation[file] || [];

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

    var element = mediaObject[i];

    element.button.innerHTML = hiding ? '(Show file)' : '(Hide file)';

    if (element.element.style.display === 'none' && hiding) {

      var hideLinkList = element.element.parentNode
          .getElementsByClassName('hideLink');

      if (hideLinkList.length) {
        hideLinkList[0].onclick();
      }
    }

    element.element.style.display = hiding ? 'none' : 'inline';
  }

}

function processFileForHiding(file) {

  var nameLink = file.getElementsByClassName('nameLink')[0];

  var hidingButton = document.createElement('span');
  hidingButton.innerHTML = '(Hide file)';
  hidingButton.setAttribute('class', 'hideFileButton');

  var fileName = nameLink.href.split('/');
  fileName = fileName[fileName.length - 1];

  var mediaObject = hiddenMediaRelation[fileName] || [];

  mediaObject.push({
    button : hidingButton,
    element : file.getElementsByClassName('imgLink')[0]
  });

  hiddenMediaRelation[fileName] = mediaObject;

  hidingButton.onclick = function() {

    var hiddenMedia = getHiddenMedia();

    var alreadyHidden = hiddenMedia.indexOf(fileName) > -1;

    if (alreadyHidden) {
      hiddenMedia.splice(hiddenMedia.indexOf(fileName), 1);
    } else {
      hiddenMedia.push(fileName);
    }

    localStorage.hiddenMedia = JSON.stringify(hiddenMedia);

    updateHiddenFiles(fileName, !alreadyHidden);

  };

  nameLink.parentNode.insertBefore(hidingButton, nameLink.nextSibling);

}
{'fraction_non_alphanumeric': 0.13777053758436117, 'fraction_numerical': 0.004188969048173144, 'mean_word_length': 3.906392694063927, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5686085', 'n_tokens_mistral': 1353, 'n_tokens_neox': 1315, 'n_words': 252}