Changeset:
        26efe3bc4f8e
        
https://sourceforge.net/p/mrbs/hg-code/ci/26efe3bc4f8e2ca5e02021f5c4d64149fae8beca
Author:
        Campbell Morrison <[email protected]>
Date:
        Fri Aug 26 15:56:01 2016 +0100
Log message:

Disabled page refresh if running over a metered network connection.

diffstat:

 web/js/functions.js.php |  31 +++++++++++++++++++++++++++++++
 web/js/refresh.js.php   |   4 +++-
 2 files changed, 34 insertions(+), 1 deletions(-)

diffs (54 lines):

diff -r 34ce794ea426 -r 26efe3bc4f8e web/js/functions.js.php
--- a/web/js/functions.js.php   Thu Aug 25 12:01:13 2016 +0100
+++ b/web/js/functions.js.php   Fri Aug 26 15:56:01 2016 +0100
@@ -112,4 +112,35 @@
       fn.apply(context, args);
     }
   };
+}
+
+<?php
+// Tries to determine if the network connection is metered and subject to
+// charges or throttling
+?>
+function isMeteredConnection()
+{
+  var connection = navigator.connection || 
+                   navigator.mozConnection || 
+                   navigator.webkitConnection ||
+                   navigator.msConnection ||
+                   null;
+  
+  if (connection === null)
+  {
+    return false;
+  }
+  
+  if ('type' in connection)
+  {
+    return (connection.type === 'cellular');
+  }
+  
+  <?php // The older version of the interface ?>
+  if ('metered' in connection)
+  {
+    return connection.metered;
+  }
+  
+  return false;
 }
\ No newline at end of file
diff -r 34ce794ea426 -r 26efe3bc4f8e web/js/refresh.js.php
--- a/web/js/refresh.js.php     Thu Aug 25 12:01:13 2016 +0100
+++ b/web/js/refresh.js.php     Fri Aug 26 15:56:01 2016 +0100
@@ -19,7 +19,9 @@
 var intervalId;
 
 var refreshPage = function refreshPage() {
-    if (!isHidden() && !refreshPage.disabled)
+    if (!isHidden() && 
+        !refreshPage.disabled &&
+        !isMeteredConnection())
     {
       var data = {ajax: 1, 
                   day: refreshPage.args.day,

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to