Showing counter for new notices only if the window is on blur

This commit is contained in:
Sarven Capadisli 2009-11-17 00:28:56 +00:00
parent ca31504dd9
commit a6399ce73a

View File

@ -36,6 +36,7 @@ RealtimeUpdate = {
_updatecounter: 0, _updatecounter: 0,
_updatedelay: 500, _updatedelay: 500,
_maxnotices: 50, _maxnotices: 50,
_windowhasfocus: false,
init: function(userid, replyurl, favorurl, deleteurl) init: function(userid, replyurl, favorurl, deleteurl)
{ {
@ -46,7 +47,9 @@ RealtimeUpdate = {
DT = document.title; DT = document.title;
$(window).blur(function() { $(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; });
$(window).bind('blur', function() {
$('#notices_primary .notice').css({ $('#notices_primary .notice').css({
'border-top-color':$('#notices_primary .notice:last').css('border-top-color'), 'border-top-color':$('#notices_primary .notice:last').css('border-top-color'),
'border-top-style':'dotted' 'border-top-style':'dotted'
@ -59,6 +62,7 @@ RealtimeUpdate = {
RealtimeUpdate._updatecounter = 0; RealtimeUpdate._updatecounter = 0;
document.title = DT; document.title = DT;
RealtimeUpdate._windowhasfocus = false;
return false; return false;
}); });
@ -89,8 +93,10 @@ RealtimeUpdate = {
NoticeFavors(); NoticeFavors();
NoticeReply(); NoticeReply();
RealtimeUpdate._updatecounter += 1; if (RealtimeUpdate._windowhasfocus === false) {
document.title = '('+RealtimeUpdate._updatecounter+') ' + DT; RealtimeUpdate._updatecounter += 1;
document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
}
}, RealtimeUpdate._updatedelay); }, RealtimeUpdate._updatedelay);
}, },