<commit_before>
class window.WRNotificationCenter
  settings:
    disableNotification: false

  constructor: (@wireroom, @options) ->
    that = this
    ifSupport = (allowed) =>
      console.log "Notification is supported."
      # $("#window-notification").bind "change", (e) ->
      #   if e.target.value is "on"
      #     @enableNotification()
      #   else if e.target.value is "off"
      #     @disableNotification()
      @wireroom.socket.on "says", (message) =>
        console.log "notification", message
        return if new Date() - @wireroom.BootTime < 3000 or @settings.disableNotification or
          message.ident is @wireroom.Identifier
        @showNotification "/images/opmsg48x48.jpg", message.nickname + " says", message.message
    ifNotSupport = () ->
      # $("#notification-feature").remove()
    NotificationChecker.check ifSupport, ifNotSupport

  disableNotification: (cb) ->
    @settings.disableNotification = true
    cb()  if $.isFunction(cb)

  showNotification: (icon, title, text) ->
    return unless window.webkitNotifications
    
    # strip html tags
    text = text.replace(/<[^>]*>/, "")
    try
      if 0 is window.webkitNotifications.checkPermission()
        x = window.webkitNotifications.createNotification(icon, title, text)
        x.ondisplay = ->
          setTimeout (->
            x.cancel()
          ), 3000
        x.show()


window.NotificationCenter =
  create: ->
    that = this

  enableNotification: (cb) ->
    return unless window.webkitNotifications
    that = this
    permission = window.webkitNotifications.checkPermission()
    unless permission is 0
      window.webkitNotifications.requestPermission ->
        that.settings.disableNotification = false
        cb() if $.isFunction(cb)
    else
      that.settings.disableNotification = false
      cb()  if $.isFunction(cb)
    false
<commit_msg>clean up<commit_after>
class window.WRNotificationCenter
  settings:
    disableNotification: false

  constructor: (@wireroom, @options) ->
    ifSupport = (allowed) =>
      console.log "Notification is supported."
      # $("#window-notification").bind "change", (e) ->
      #   if e.target.value is "on"
      #     @enableNotification()
      #   else if e.target.value is "off"
      #     @disableNotification()
      @wireroom.socket.on "says", (message) =>
        return if new Date() - @wireroom.BootTime < 3000 or @settings.disableNotification or
          message.ident is @wireroom.Identifier
        @showNotification "/images/opmsg48x48.jpg", message.nickname + " says", message.message
    ifNotSupport = () ->
      # $("#notification-feature").remove()
    NotificationChecker.check ifSupport, ifNotSupport

  disableNotification: (cb) ->
    @settings.disableNotification = true
    cb()  if $.isFunction(cb)

  showNotification: (icon, title, text) ->
    return unless window.webkitNotifications
    
    # strip html tags
    text = text.replace(/<[^>]*>/, "")
    try
      if 0 is window.webkitNotifications.checkPermission()
        x = window.webkitNotifications.createNotification(icon, title, text)
        x.ondisplay = ->
          setTimeout (->
            x.cancel()
          ), 3000
        x.show()

  enableNotification: (cb) ->
    return unless window.webkitNotifications
    permission = window.webkitNotifications.checkPermission()
    unless permission is 0
      window.webkitNotifications.requestPermission =>
        @settings.disableNotification = false
        cb() if $.isFunction(cb)
    else
      @settings.disableNotification = false
      cb()  if $.isFunction(cb)
    false
{'fraction_non_alphanumeric': 0.11810368727474356, 'fraction_numerical': 0.007762683670640421, 'mean_word_length': 2.7157569515962923, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3861461', 'n_tokens_mistral': 1028, 'n_tokens_neox': 966, 'n_words': 234}