<commit_before>(function () {
  var modalWrapper = null
  var dataModals = null
  var openModals = []

  function disableParentEvents () {
    for (var i = 0; i < dataModals.length; i++) {
      var modal = dataModals[i]

      // Disable closing the modal wrapper if modal gets clicked
      modal.addEventListener('click', function (event) {
        event.stopPropagation()
      })
    }
  }

  function closeModalsOnEsc () {
    window.addEventListener('keyup', function (event) {
      if (openModals.length && event.keyCode === 27) {
        api.closeCurrent()
      }
    })
  }

  function closeModalWrapper () {
    modalWrapper.classList.remove('visible')

    // Re-enable parent scrolling
    document.body.style.overflow = 'auto'
  }

  var api = {
    init: function () {
      modalWrapper = document.querySelector('.modal-wrapper')
      dataModals = document.querySelectorAll('[data-modal]')

      var triggers = document.querySelectorAll('[data-modaltrigger]')
      for (var i = 0; i < triggers.length; i++) {
        triggers[i].addEventListener('click', function (event) {
          var modalName = event.target.dataset.modaltrigger
          api.open(modalName)
        })
      }

      // Close all modals when clicking outside modal
      modalWrapper.addEventListener('click', function (event) {
        api.closeCurrent()
      })

      disableParentEvents()
      closeModalsOnEsc()
    },

    open: function (modalName, cb) {
      var modal = document.querySelectorAll(
        '[data-modal="' + modalName + '"]'
      )[0]

      // If modal is already open, don't do anything
      if (openModals.indexOf(modal) >= 0) return

      if (modal) {
        modal.classList.add('visible')
        modalWrapper.classList.add('visible')

        // Disable parent scrolling when modal is open
        document.body.style.overflow = 'hidden'

        openModals.push(modal)
      } else {
        console.error('Could not find modal with name "%s"', modalName)
      }

      if (typeof cb === 'function') {
        cb()
      }
    },

    closeCurrent: function (cb) {
      var modal = openModals.pop()
      modal.classList.remove('visible')

      if (openModals.length === 0) {
        closeModalWrapper()
      }

      if (typeof cb === 'function') {
        cb()
      }
    },

    closeAll: function (cb) {
      for (var i = 0; i < dataModals.length; i++) {
        dataModals[i].classList.remove('visible')
        closeModalWrapper()
      }

      if (typeof cb === 'function') {
        cb()
      }
    }
  }

  window.modal = api
})()<commit_msg>Make use of short if-statement<commit_after>(function () {
  var modalWrapper = null
  var dataModals = null
  var openModals = []

  function disableParentEvents () {
    for (var i = 0; i < dataModals.length; i++) {
      var modal = dataModals[i]

      // Disable closing the modal wrapper if modal gets clicked
      modal.addEventListener('click', function (event) {
        event.stopPropagation()
      })
    }
  }

  function closeModalsOnEsc () {
    window.addEventListener('keyup', function (event) {
      if (openModals.length && event.keyCode === 27) {
        api.closeCurrent()
      }
    })
  }

  function closeModalWrapper () {
    modalWrapper.classList.remove('visible')

    // Re-enable parent scrolling
    document.body.style.overflow = 'auto'
  }

  var api = {
    init: function () {
      modalWrapper = document.querySelector('.modal-wrapper')
      dataModals = document.querySelectorAll('[data-modal]')

      var triggers = document.querySelectorAll('[data-modaltrigger]')
      for (var i = 0; i < triggers.length; i++) {
        triggers[i].addEventListener('click', function (event) {
          var modalName = event.target.dataset.modaltrigger
          api.open(modalName)
        })
      }

      // Close all modals when clicking outside modal
      modalWrapper.addEventListener('click', function (event) {
        api.closeCurrent()
      })

      disableParentEvents()
      closeModalsOnEsc()
    },

    open: function (modalName, cb) {
      var modal = document.querySelectorAll(
        '[data-modal="' + modalName + '"]'
      )[0]

      // If modal is already open, don't do anything
      if (openModals.indexOf(modal) >= 0) return

      if (modal) {
        modal.classList.add('visible')
        modalWrapper.classList.add('visible')

        // Disable parent scrolling when modal is open
        document.body.style.overflow = 'hidden'

        openModals.push(modal)
      } else {
        console.error('Could not find modal with name "%s"', modalName)
      }

      if (typeof cb === 'function') cb()
    },

    closeCurrent: function (cb) {
      var modal = openModals.pop()
      modal.classList.remove('visible')

      if (openModals.length === 0) {
        closeModalWrapper()
      }

      if (typeof cb === 'function') cb()
    },

    closeAll: function (cb) {
      for (var i = 0; i < dataModals.length; i++) {
        dataModals[i].classList.remove('visible')
        closeModalWrapper()
      }

      if (typeof cb === 'function') cb()
    }
  }

  window.modal = api
})()
{'fraction_non_alphanumeric': 0.13158406219630708, 'fraction_numerical': 0.003109815354713314, 'mean_word_length': 2.3114543114543116, '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': '449677', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1476, 'n_words': 354}