<commit_before>/* globals $ django */
$(function () {
  var modalHTML = (
    '<div class="modal" tabindex="-1">' +
      '<div class="modal-dialog modal-lg" role="document">' +
        '<div class="modal-content">' +
          '<div class="modal-header"><h2 class="modal-title u-first-heading"></h2>' +
            '<button type="button" class="close" data-dismiss="modal" aria-label="' + django.gettext('Close') + '"><span aria-hidden="true">&times;</span></button>' +
          '</div>' +
          '<div class="modal-body"></div>' +
      '  </div>' +
      '</div>' +
    '</div>'
  )

  var extractScripts = function ($root, selector, attr) {
    var $existingValues = $('head').find(selector).map(function (i, e) {
      return $(e).attr(attr)
    })

    $root.find(selector).each(function (i, script) {
      var $script = $(script)
      var $matches = $existingValues.filter(function (i, v) {
        return v === $script.attr(attr)
      })
      if ($matches.length === 0) {
        $('head').append($script)
      }
    })
  }

  $(document).on('click', '[data-toggle="ajax-modal"]', function (e) {
    e.preventDefault()
    var target = this.href + ' ' + this.dataset.targetSelector
    var $newModal = $(modalHTML)

    $newModal.on('hidden.bs.modal', function () {
      $newModal.remove()
    })

    $newModal.find('.modal-body').load(target, function (html) {
      var $root = $('<div>').html(html)
      var title = $root.find('h1').text()
      $newModal.find('.modal-title').text(title)
      extractScripts($root, 'script[src]', 'src')
      extractScripts($root, 'link[rel="stylesheet"]', 'href')

      $newModal.appendTo('body')
      $newModal.modal()
    })
  })
})<commit_msg>Set model role to dialog and aria label to the encapsulated title<commit_after>/* globals $ django */
$(function () {
  var modalHTML = (
    '<div class="modal" tabindex="-1" role="dialog">' +
      '<div class="modal-dialog modal-lg" role="document">' +
        '<div class="modal-content">' +
          '<div class="modal-header"><h2 class="modal-title u-first-heading"></h2>' +
            '<button type="button" class="close" data-dismiss="modal" aria-label="' + django.gettext('Close') + '"><span aria-hidden="true">&times;</span></button>' +
          '</div>' +
          '<div class="modal-body"></div>' +
      '  </div>' +
      '</div>' +
    '</div>'
  )

  var extractScripts = function ($root, selector, attr) {
    var $existingValues = $('head').find(selector).map(function (i, e) {
      return $(e).attr(attr)
    })

    $root.find(selector).each(function (i, script) {
      var $script = $(script)
      var $matches = $existingValues.filter(function (i, v) {
        return v === $script.attr(attr)
      })
      if ($matches.length === 0) {
        $('head').append($script)
      }
    })
  }

  $(document).on('click', '[data-toggle="ajax-modal"]', function (e) {
    e.preventDefault()
    var target = this.href + ' ' + this.dataset.targetSelector
    var $newModal = $(modalHTML)

    $newModal.on('hidden.bs.modal', function () {
      $newModal.remove()
    })

    $newModal.find('.modal-body').load(target, function (html) {
      var $root = $('<div>').html(html)
      var title = $root.find('h1').text()
      $newModal.find('.modal-title').text(title)
      $newModal.attr('aria-label', title)
      extractScripts($root, 'script[src]', 'src')
      extractScripts($root, 'link[rel="stylesheet"]', 'href')

      $newModal.appendTo('body')
      $newModal.modal()
    })
  })
})
{'fraction_non_alphanumeric': 0.21538024971623154, 'fraction_numerical': 0.0028376844494892167, 'mean_word_length': 2.886438809261301, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '1880156', 'n_tokens_mistral': 1146, 'n_tokens_neox': 1143, 'n_words': 208}