Skip to content

Instantly share code, notes, and snippets.

@garyharan
Created January 11, 2011 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garyharan/774985 to your computer and use it in GitHub Desktop.
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.
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