Created
February 1, 2011 17:28
-
-
Save trevorturk/806218 to your computer and use it in GitHub Desktop.
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
$(document).ready(function(){ | |
var focus = true; | |
var count = 0; | |
var title = document.title; | |
$(window).focus(function(){ | |
focus = true; | |
count = 0; | |
setTimeout(function(){ | |
document.title = title; | |
}, 500); | |
}); | |
$(window).blur(function(){ | |
focus = false; | |
}); | |
var pusher = new Pusher('your_api_key'); | |
var channel = pusher.subscribe('messages'); | |
channel.bind('messages', function(data){ | |
$('#messages').prepend(data); // specific to your app | |
if (focus == false) { | |
count++; | |
setTimeout(function(){ | |
document.title = '(' + count + ') ' + title; | |
}, 500); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment