<commit_before>define [
  'i18n!react_files'
  'jquery'
  'compiled/models/Progress'
  'compiled/models/Folder'
], (I18n, $, Progress, Folder) ->

  downloadStuffAsAZip = (filesAndFolders, {contextType, contextId}) ->
    files = []
    folders = []
    for item in filesAndFolders
      if item instanceof Folder
        folders.push(item.id)
      else
        files.push(item.id)

    url = "/api/v1/#{contextType}/#{contextId}/content_exports"

    # TODO: handle progress events with nicer UI
    $progressIndicator = $('<div style="position: fixed; top: 4px; left: 50%; margin-left: -120px; width: 240px; z-index: 11; text-align: center; box-sizing: border-box; padding: 8px;" class="alert alert-info">')
    onProgress = (progessAPIResponse) ->
      message = I18n.t('progress_message', 'Preparing download: %{percent}% complete', {percent: progessAPIResponse.completion})
      $progressIndicator.appendTo('body').text(message)
      $.screenReaderFlashMessage(message)

    data =
      export_type: 'zip'
      select:<commit_msg>Makes file download progress be indicated exclusively<commit_after>define [
  'underscore'
  'i18n!react_files'
  'jquery'
  'compiled/models/Progress'
  'compiled/models/Folder'
], (_, I18n, $, Progress, Folder) ->

  downloadStuffAsAZip = (filesAndFolders, {contextType, contextId}) ->
    files = []
    folders = []
    for item in filesAndFolders
      if item instanceof Folder
        folders.push(item.id)
      else
        files.push(item.id)

    url = "/api/v1/#{contextType}/#{contextId}/content_exports"

    # This gives at least 2.5 seconds between updates of the status for screenreaders,
    # this should allow them to get the full message before it triggers another
    # reading of the message.  Technically, if the screenreader read speed is set
    # such that this is slower it won't work as intended.  But, most experienced
    # SR users set it much higher speed (300 wpm according to http://webaim.org/techniques/screenreader/)
    # This works well for the default read speed which is around 180 wpm.
    screenreaderMessageWaitTimeMS = 2500
    throttledSRMessage = _.throttle($.screenReaderFlashMessageExclusive, screenreaderMessageWaitTimeMS, leading: false)

    # TODO: handle progress events with nicer UI
    $progressIndicator = $('<div style="position: fixed; top: 4px; left: 50%; margin-left: -120px; width: 240px; z-index: 11; text-align: center; box-sizing: border-box; padding: 8px;" class="alert alert-info">')
    onProgress = (progessAPIResponse) ->
      message = I18n.t('progress_message', 'Preparing download: %{percent}% complete', {percent: progessAPIResponse.completion})
      $progressIndicator.appendTo('body').text(message)
      throttledSRMessage(message)

    data =
      export_type: 'zip'
      select:
{'fraction_non_alphanumeric': 0.11840228245363767, 'fraction_numerical': 0.01783166904422254, 'mean_word_length': 3.770408163265306, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4554104', 'n_tokens_mistral': 905, 'n_tokens_neox': 837, 'n_words': 233}