<commit_before>class Fustrate.GenericPage
  constructor: (@root) ->
    @_reloadUIElements()
    @addEventListeners()
    @initialize()

  include: (concern) =>
    instance = new concern

    for own key, value of instance.constructor
      continue if key in ['included', 'initialize', 'strings']

      @constructor[key] = value unless @constructor[key]

    # Assign properties to the prototype
    for key, value of concern.prototype
      continue if key in ['included', 'initialize', 'strings']

      @[key] = value.bind(@) unless @[key]

    instance.included?.apply(@)

    return unless instance.constructor.strings

    @constructor.strings ?= {}

    $.extend true, @constructor.strings, instance.constructor.strings

  addEventListeners: =>
    for name, func of @
      func.apply(@) if /^add.+EventListeners$/.test name

  # Once the interface is loaded and the event listeners are active, run any
  # other tasks.
  initialize: ->

  _reloadUIElements: =>
    @fields = {}
    @buttons = {}

    $('[data-field]', @root).not('.modal [data-field]').each (i, element) =>
      field = $ element
      @fields[field.data('field')] = field

    $('[data-button]', @root).not('.modal [data-button]').each (i, element) =>
      button = $ element
      @buttons[button.data('button')] = button<commit_msg>Edge bug<commit_after>class Fustrate.GenericPage
  constructor: (@root) ->
    @_reloadUIElements()
    @addEventListeners()
    @initialize()

  include: (concern) =>
    instance = new concern

    for own key, value of instance.constructor
      continue if key in ['included', 'initialize', 'strings']

      @constructor[key] = value unless @constructor[key]

    # Assign properties to the prototype
    for key, value of concern.prototype
      continue if key in ['included', 'initialize', 'strings']

      @[key] = value.bind(@) unless @[key]

    instance.included?.apply(@)

    return unless instance.constructor.strings

    @constructor.strings ?= {}

    $.extend true, @constructor.strings, instance.constructor.strings

  addEventListeners: =>
    for name, func of @
      # Edge returns true for /one.+two/.test('onetwo'), 2017-10-21
      func.apply(@) if /^add..*EventListeners$/.test name

  # Once the interface is loaded and the event listeners are active, run any
  # other tasks.
  initialize: ->

  _reloadUIElements: =>
    @fields = {}
    @buttons = {}

    $('[data-field]', @root).not('.modal [data-field]').each (i, element) =>
      field = $ element
      @fields[field.data('field')] = field

    $('[data-button]', @root).not('.modal [data-button]').each (i, element) =>
      button = $ element
      @buttons[button.data('button')] = button
{'fraction_non_alphanumeric': 0.15059347181008903, 'fraction_numerical': 0.002967359050445104, 'mean_word_length': 3.2140625, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1083017', 'n_tokens_mistral': 812, 'n_tokens_neox': 778, 'n_words': 216}