summaryrefslogtreecommitdiff
path: root/plugins/Realtime/realtimeupdate.js
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2009-11-17 00:28:56 +0000
committerSarven Capadisli <csarven@status.net>2009-11-17 00:28:56 +0000
commita6399ce73a7459a8ee7bc18f6b8c449e0b45b5fb (patch)
tree0a60768982afe75330f691fc2f0c1db0abaab4e6 /plugins/Realtime/realtimeupdate.js
parentca31504dd91560496c55bf9a781e2d72e3fb367a (diff)
Showing counter for new notices only if the window is on blur
Diffstat (limited to 'plugins/Realtime/realtimeupdate.js')
-rw-r--r--plugins/Realtime/realtimeupdate.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/plugins/Realtime/realtimeupdate.js b/plugins/Realtime/realtimeupdate.js
index 132f79abb..fa0fefed4 100644
--- a/plugins/Realtime/realtimeupdate.js
+++ b/plugins/Realtime/realtimeupdate.js
@@ -36,6 +36,7 @@ RealtimeUpdate = {
_updatecounter: 0,
_updatedelay: 500,
_maxnotices: 50,
+ _windowhasfocus: false,
init: function(userid, replyurl, favorurl, deleteurl)
{
@@ -46,7 +47,9 @@ RealtimeUpdate = {
DT = document.title;
- $(window).blur(function() {
+ $(window).bind('focus', function(){ RealtimeUpdate._windowhasfocus = true; });
+
+ $(window).bind('blur', function() {
$('#notices_primary .notice').css({
'border-top-color':$('#notices_primary .notice:last').css('border-top-color'),
'border-top-style':'dotted'
@@ -59,6 +62,7 @@ RealtimeUpdate = {
RealtimeUpdate._updatecounter = 0;
document.title = DT;
+ RealtimeUpdate._windowhasfocus = false;
return false;
});
@@ -89,8 +93,10 @@ RealtimeUpdate = {
NoticeFavors();
NoticeReply();
- RealtimeUpdate._updatecounter += 1;
- document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
+ if (RealtimeUpdate._windowhasfocus === false) {
+ RealtimeUpdate._updatecounter += 1;
+ document.title = '('+RealtimeUpdate._updatecounter+') ' + DT;
+ }
}, RealtimeUpdate._updatedelay);
},