<commit_before>$ = jQuery.sub()

class App.Com
  _instance = undefined # Must be declared here to force the closure on the class
  @ajax: (args) -> # Must be a static method
    if _instance == undefined
      _instance ?= new _Singleton

    _instance.ajax(args)
    _instance

# The actual Singleton class
class _Singleton
  defaults:
    contentType: 'application/json'
    dataType: 'json'
    processData: false
    headers: {'X-Requested-With': 'XMLHttpRequest'}
    cache: false
    async: true

  queue_list: {}
  count: 0

  constructor: (@args) ->

    # bindings
    $('body').bind( 'ajaxSend', =>
      @_show_spinner()
    ).bind( 'ajaxComplete', =>
      @_hide_spinner()
    )

    # show error messages
    $('body').bind( 'ajaxError', ( e, jqxhr, settings, exception ) ->
      status = jqxhr.status
      detail = jqxhr.responseText
      if !status && !detail
        detail = 'General communication error, maybe internet is not available!'

      # do not show any error message on wrong login
      return if status is 422

      # show human readable message
      if status is 401
        status = 'Access denied.'
        detail = ''

      # show error message
      new App.ErrorModal(
        message: 'StatusCode: ' + status
        detail:  detail
        close:   true
      )
    )<commit_msg>Do not show aborded ajax requests.<commit_after>$ = jQuery.sub()

class App.Com
  _instance = undefined # Must be declared here to force the closure on the class
  @ajax: (args) -> # Must be a static method
    if _instance == undefined
      _instance ?= new _Singleton

    _instance.ajax(args)
    _instance

# The actual Singleton class
class _Singleton
  defaults:
    contentType: 'application/json'
    dataType: 'json'
    processData: false
    headers: {'X-Requested-With': 'XMLHttpRequest'}
    cache: false
    async: true

  queue_list: {}
  count: 0

  constructor: (@args) ->

    # bindings
    $('body').bind( 'ajaxSend', =>
      @_show_spinner()
    ).bind( 'ajaxComplete', =>
      @_hide_spinner()
    )

    # show error messages
    $('body').bind( 'ajaxError', ( e, jqxhr, settings, exception ) ->
      status = jqxhr.status
      detail = jqxhr.responseText
      if !status && !detail
        detail = 'General communication error, maybe internet is not available!'

      # do not show aborded requests
      return if status is 0

      # do not show any error message on wrong login
      return if status is 422

      # show human readable message
      if status is 401
        status = 'Access denied.'
        detail = ''

      # show error message
      new App.ErrorModal(
        message: 'StatusCode: ' + status
        detail:  detail
        close:   true
      )
    )
{'fraction_non_alphanumeric': 0.10091407678244972, 'fraction_numerical': 0.005484460694698354, 'mean_word_length': 2.3819530284301607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '931838', 'n_tokens_mistral': 824, 'n_tokens_neox': 785, 'n_words': 269}