<commit_before># Notifications using jquery.noty

# Default options for noty
defaultOpts =
  closable: true
  timeout: true
  force: false
  modal: false
  timeout: 6000
  speed: 200
  textAlign: 'center'
  layout: 'topCenter'
  closeButton: true

class mconf.Notification

  @bind: ->
    $("div[name='error'], div[name='alert']", "#notification-flashs").each ->
      opts = $.extend {}, defaultOpts,
        text: $(this).text()
        type: 'error'
        force: true
        timeout: false
      noty opts
    $("#notification-flashs > div[name='success']").each ->
      opts = $.extend {}, defaultOpts,
        text: $(this).text()
        type: 'success'
      noty opts
    $("#notification-flashs > div[name='notice']").each ->
      opts = $.extend {}, defaultOpts,
        text: $(this).text()
        type: 'alert'
      noty opts

$ ->
  mconf.Notification.bind()
<commit_msg>Prevent notifications for being shown more than once, refs #966<commit_after># Notifications using jquery.noty

# Default options for noty
defaultOpts =
  closable: true
  timeout: true
  force: false
  modal: false
  timeout: 6000
  speed: 200
  textAlign: 'center'
  layout: 'topCenter'
  closeButton: true

class mconf.Notification

  @bind: ->
    $("div[name='error'], div[name='alert']", "#notification-flashs").each ->
      showNotification(this, "error")
    $("#notification-flashs > div[name='success']").each ->
      showNotification(this, "success")
    $("#notification-flashs > div[name='notice']").each ->
      showNotification(this, "notice")

showNotification = (target, type) ->
  $target = $(target)

  unless $target.attr("data-notification-shown") is "1"
    $target.attr("data-notification-shown", "1")

    opts = {}
    switch type
      when "success"
        opts = $.extend {}, defaultOpts,
          text: $target.text()
          type: 'success'
      when "error"
        opts = $.extend {}, defaultOpts,
          text: $target.text()
          type: 'error'
          force: true
          timeout: false
      else
        opts = $.extend {}, defaultOpts,
          text: $target.text()
          type: 'alert'

    noty(opts)

$ ->
  mconf.Notification.bind()

{'fraction_non_alphanumeric': 0.1525810872544541, 'fraction_numerical': 0.00867976244860667, 'mean_word_length': 2.686868686868687, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2141637', 'n_tokens_mistral': 679, 'n_tokens_neox': 667, 'n_words': 167}