From: Sarven Capadisli <csarven@status.net>
Date: Wed, 18 Nov 2009 10:53:48 +0000 (+0000)
Subject: Added check to see whether window has focus
X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0c81f39bee37e288ad6d56091884da61b96637c5;p=quix0rs-gnu-social.git

Added check to see whether window has focus
---

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