Added check to see whether window has focus

This commit is contained in:
Sarven Capadisli 2009-11-18 10:53:48 +00:00
parent 5e0fb1ddfc
commit 0c81f39bee

View File

@ -34,6 +34,7 @@ RealtimeUpdate = {
_favorurl: '', _favorurl: '',
_deleteurl: '', _deleteurl: '',
_updatecounter: 0, _updatecounter: 0,
_windowhasfocus: false,
init: function(userid, replyurl, favorurl, deleteurl) init: function(userid, replyurl, favorurl, deleteurl)
{ {
@ -44,6 +45,8 @@ RealtimeUpdate = {
DT = document.title; DT = document.title;
$(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; });
$(window).blur(function() { $(window).blur(function() {
$('#notices_primary .notice').removeClass('mark-top'); $('#notices_primary .notice').removeClass('mark-top');
@ -51,6 +54,7 @@ RealtimeUpdate = {
RealtimeUpdate._updatecounter = 0; RealtimeUpdate._updatecounter = 0;
document.title = DT; document.title = DT;
RealtimeUpdate._windowhasfocus = false;
return false; return false;
}); });
@ -72,8 +76,10 @@ RealtimeUpdate = {
SN.U.NoticeReply(); SN.U.NoticeReply();
SN.U.NoticeFavor(); SN.U.NoticeFavor();
RealtimeUpdate._updatecounter += 1; if (RealtimeUpdate._windowhasfocus === false) {
document.title = '('+RealtimeUpdate._updatecounter+') ' + DT; RealtimeUpdate._updatecounter += 1;
document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
}
}, },
makeNoticeItem: function(data) makeNoticeItem: function(data)