Revision: 2690
https://sourceforge.net/p/mrbs/code/2690/
Author: cimorrison
Date: 2013-02-10 13:30:56 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
Fixed a bug causing multiple timers to be fired when the page is hidden and
then unhidden
Modified Paths:
--------------
mrbs/trunk/web/js/refresh.js.php
Modified: mrbs/trunk/web/js/refresh.js.php
===================================================================
--- mrbs/trunk/web/js/refresh.js.php 2013-02-10 12:33:02 UTC (rev 2689)
+++ mrbs/trunk/web/js/refresh.js.php 2013-02-10 13:30:56 UTC (rev 2690)
@@ -14,7 +14,11 @@
{
echo "'use strict';\n";
}
+?>
+var intervalId;
+
+<?php
// refreshPage will be defined later as a function, once we know
// the page data, which won't be until init().
?>
@@ -41,30 +45,26 @@
?>
var refreshVisChanged = function refreshVisChanged() {
- var hidden = isHidden();
-
- <?php
- // If the page is hidden stop the timer, if any; if it is now visible
- // then refresh the page, which will also start a timer; if we
- // don't know the status then don't do anything. We clear the interval
- // and refresh the page rather than just disabling/enabling the page
- // refresh because we want the latest data to be displayed immediately
the
- // page becomes visible again. (It might have been hidden for a while
- // with lots of changes in the meantime).
- ?>
- switch (hidden)
+ var pageHidden = isHidden();
+
+ if (pageHidden !== null)
{
- case true:
- if (typeof intervalId !== 'undefined')
- {
- window.clearInterval(intervalId);
- }
- break;
- case false:
+ <?php
+ // Stop the interval timer. If the page is now visible then refresh
+ // the page, which will also start a new timer. We clear the interval
+ // and refresh the page rather than just disabling/enabling the page
+ // refresh because we want the latest data to be displayed immediately
the
+ // page becomes visible again. (It might have been hidden for a while
+ // with lots of changes in the meantime).
+ ?>
+ if (typeof intervalId !== 'undefined')
+ {
+ window.clearInterval(intervalId);
+ }
+ if (!pageHidden)
+ {
refreshPage();
- break;
- default:
- break;
+ }
}
};
@@ -117,7 +117,7 @@
<?php
// Set an interval timer to refresh the page.
?>
- var intervalId = setInterval(refreshPage, <?php echo $refresh_rate * 1000
?>);
+ intervalId = setInterval(refreshPage, <?php echo $refresh_rate * 1000 ?>);
<?php
------------------------------------------------------------------------------
Free Next-Gen Firewall Hardware Offer
Buy your Sophos next-gen firewall before the end March 2013
and get the hardware for free! Learn more.
http://p.sf.net/sfu/sophos-d2d-feb
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits