<commit_before>FactlinkApp.module "NotificationCenter", (NotificationCenter, MyApp, Backbone, Marionette, $, _) ->

  class NotificationCenter.AlertView extends Marionette.ItemView

    className: 'notification-center-alert-container'

    template:
      text: """
        <div class="notification-center-alert notification-center-alert-{{type}}">{{{message}}}
          <span class="notification-center-alert-close js-close">&times;</span>
        </div>
      """

    events:
      "click .js-close": '_destroy'

    onRender: ->
      @_autoHide()

    _autoHide: ->
      return unless @model.get('type') == 'success'

      setTimeout (=> @_destroy()), 1000

    _destroy: ->
      @$el.addClass 'notification-center-alert-container-hidden'

      transitionTime = 500 # Keep in sync with CSS
      setTimeout (=> @model.destroy()), transitionTime+100

  class NotificationCenter.AlertsView extends Marionette.CollectionView
    itemView: NotificationCenter.AlertView

  class NotificationCenter.Alert extends Backbone.Model
  class NotificationCenter.Alerts extends Backbone.Collection
  window.alerts = new NotificationCenter.Alerts []

  FactlinkApp.addRegions
    alertsRegion: ".js-notification-center-alerts"
  FactlinkApp.alertsRegion.show new NotificationCenter.AlertsView collection: alerts

  NotificationCenter.info    = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'info'
  NotificationCenter.success = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'success'
  NotificationCenter.error   = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'error'
<commit_msg>Made auto-hide time dependent on message length<commit_after>FactlinkApp.module "NotificationCenter", (NotificationCenter, MyApp, Backbone, Marionette, $, _) ->

  class NotificationCenter.AlertView extends Marionette.ItemView

    className: 'notification-center-alert-container'

    template:
      text: """
        <div class="notification-center-alert notification-center-alert-{{type}}">{{{message}}}
          <span class="notification-center-alert-close js-close">&times;</span>
        </div>
      """

    events:
      "click .js-close": '_destroy'

    onRender: ->
      @_autoHide()

    _autoHide: ->
      return unless @model.get('type') == 'success'

      setTimeout (=> @_destroy()), @_autoHideTime()

    _autoHideTime: -> 1000 + 50*@model.get('message').length

    _destroy: ->
      @$el.addClass 'notification-center-alert-container-hidden'

      transitionTime = 500 # Keep in sync with CSS
      setTimeout (=> @model.destroy()), transitionTime+100

  class NotificationCenter.AlertsView extends Marionette.CollectionView
    itemView: NotificationCenter.AlertView

  class NotificationCenter.Alert extends Backbone.Model
  class NotificationCenter.Alerts extends Backbone.Collection
  window.alerts = new NotificationCenter.Alerts []

  FactlinkApp.addRegions
    alertsRegion: ".js-notification-center-alerts"
  FactlinkApp.alertsRegion.show new NotificationCenter.AlertsView collection: alerts

  NotificationCenter.info    = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'info'
  NotificationCenter.success = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'success'
  NotificationCenter.error   = (message) -> alerts.add new NotificationCenter.Alert message: message, type: 'error'

{'fraction_non_alphanumeric': 0.11665699361578642, 'fraction_numerical': 0.006384213580963436, 'mean_word_length': 4.061674008810573, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 30, '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': '3013553', 'n_tokens_mistral': 990, 'n_tokens_neox': 901, 'n_words': 209}