Skip to content

Commit

Permalink
Only notify in the title or make a sound when a message happens in th…
Browse files Browse the repository at this point in the history
…e channel we're in
  • Loading branch information
sgrove committed Apr 13, 2012
1 parent cef9e87 commit 880fc6d
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions app/assets/javascripts/backbone/helpers/utils.js.coffee
Expand Up @@ -3,20 +3,12 @@ class Kandan.Helpers.Utils

@browserTabFocused: true

@notifyInTitleIfRequired: ->
if @browserTabFocused != true
@playAudioNotice()
@notifyInTitleIfRequired: (activityAttributes) ->
if Kandan.Data.Channels.activeChannelId() == activityAttributes.channel_id and activityAttributes.action == "message" and @browserTabFocused != true
Kandan.Plugins.MusicPlayer.playAudioNotice()
@unreadActivities += 1
$(document).attr('title', "(#{@unreadActivities}) Kandan")

@playAudioNotice: ->
url = @localFileUrl('ding.wav')
player = $('.audio_private')[0]
player.setAttribute('src', url)
player.play()

@localFileUrl: (fileName) ->
return "http://#{ window.location.hostname }:#{ window.location.port }/sounds/#{ fileName }"

@months: [
"January"
Expand Down

0 comments on commit 880fc6d

Please sign in to comment.