Created
January 11, 2011 19:43
-
-
Save garyharan/774985 to your computer and use it in GitHub Desktop.
TalkerApp.com plugin to receive audio ring when you are mentioned in a message.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugin.command = 'togglementionsound'; | |
plugin.usage = '/togglementionsound'; | |
plugin.onCommand = function(talkerEvent) { | |
if (talkerEvent.command == plugin.command) { | |
$.cookie('ReceivedMentionSound', ($.cookie('ReceivedMentionSound') == 'false' ? 'true': 'false'), { | |
expires: (function() { | |
var d = new Date(); | |
d.setTime(new Date().getTime() + 10 * 365 * 24 * 60 * 60 * 1000); | |
return d | |
})() | |
}); | |
Talker.getMessageBox().val(''); | |
alert($.cookie('ReceivedMentionSound')); | |
return false; | |
} | |
} | |
plugin.onLoaded = function() { | |
if ($.cookie('ReceivedMentionSound') != 'false') { | |
$.cookie('ReceivedMentionSound', 'true', { | |
expires: (function() { | |
var d = new Date(); | |
d.setTime(new Date().getTime() + 10 * 365 * 24 * 60 * 60 * 1000); | |
return d | |
})() | |
}); | |
} | |
plugin.loaded = true; | |
$(document.body).append($('<audio/>').attr('src', '/sounds/borealis/message_received.wav')); // preload | |
} | |
plugin.onBlur = function() { | |
plugin.onMessageReceived = function(talkerEvent) { | |
if (talkerEvent.content.toLowerCase().indexOf(Talker.getCurrentUser().name.toLowerCase()) == -1) return; | |
if (plugin.loaded && talkerEvent.user.id != Talker.currentUser.id && $.cookie('ReceivedMentionSound') == 'true') { | |
$(document.body).append($('<audio/>').attr('src', '/sounds/borealis/message_received.wav').attr('autoplay', 'true').bind('ended', function() { $(this).remove() })); | |
} | |
} | |
} | |
plugin.onFocus = function() { | |
plugin.onMessageReceived = function() {}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment