<commit_before>"use strict"

app = angular.module('cloudStorm.alertService', [])

# ===== SERVICE ===============================================================

app.service 'csAlertService', ['csSettings', (csSettings) ->

  @i18n = csSettings.settings['i18n-engine']
  @sequence = 0
  @alerts = []

  @getAlerts = () ->
    if @alerts
      @alerts
    else
      []

  @timeoutForAlert = (alert) ->
    switch alert.type
      when 'success' then 3500
      when 'info'    then 3500
      when 'warning' then 3500
      when 'danger'  then 3500

  @addAlert = (message, type = 'warning') ->
    unless @alerts
      @alerts = []
    @alerts.push {id:@sequence, message: message, type: type}
    @sequence++

  @success = (msgType) ->
    @addAlert(@getText(msgType), 'success')

  @info = (msgType) ->
    @addAlert(@getText(msgType), 'info')

  @warning = (msgType) ->
    @addAlert(@getText(msgType), 'warning')

  @getText = (type) ->
    @i18n.t('alert.' + type) || 'translation missing'

  @dismissAlert = (idToDismiss) ->
    @alerts = _.without @alerts, _.findWhere(@alerts, {id: idToDismiss})

  # For debug purposes
  window.csAlerts = this
]<commit_msg>added danger function<commit_after>"use strict"

app = angular.module('cloudStorm.alertService', [])

# ===== SERVICE ===============================================================

app.service 'csAlertService', ['csSettings', (csSettings) ->

  @i18n = csSettings.settings['i18n-engine']
  @sequence = 0
  @alerts = []

  @getAlerts = () ->
    if @alerts
      @alerts
    else
      []

  @timeoutForAlert = (alert) ->
    switch alert.type
      when 'success' then 3500
      when 'info'    then 3500
      when 'warning' then 3500
      when 'danger'  then 3500

  @addAlert = (message, type = 'warning') ->
    unless @alerts
      @alerts = []
    @alerts.push {id:@sequence, message: message, type: type}
    @sequence++

  @success = (msgType) ->
    @addAlert(@getText(msgType), 'success')

  @info = (msgType) ->
    @addAlert(@getText(msgType), 'info')

  @warning = (msgType) ->
    @addAlert(@getText(msgType), 'warning')

  @danger = (msgType) ->
    @addAlert(customMessage || @getText(msgType), 'danger')

  @getText = (type) ->
    @i18n.t('alert.' + type) || 'translation missing'

  @dismissAlert = (idToDismiss) ->
    @alerts = _.without @alerts, _.findWhere(@alerts, {id: idToDismiss})

  # For debug purposes
  window.csAlerts = this
]
{'fraction_non_alphanumeric': 0.21210873146622736, 'fraction_numerical': 0.018945634266886325, 'mean_word_length': 3.3452593917710196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '6882847', 'n_tokens_mistral': 855, 'n_tokens_neox': 791, 'n_words': 175}