]> git.p6c8.net - jirafeau_mojo42.git/commitdiff
lib/function.js: limit refresh of upload speed
authorJerome Jutteau <mojo@couak.net>
Mon, 23 Mar 2015 11:08:59 +0000 (12:08 +0100)
committerJerome Jutteau <mojo@couak.net>
Mon, 23 Mar 2015 11:08:59 +0000 (12:08 +0100)
lib/functions_v4.js [moved from lib/functions_v3.js with 97% similarity]
lib/template/header.php

similarity index 97%
rename from lib/functions_v3.js
rename to lib/functions_v4.js
index 0947eb36a25b89fa7b6717fdb2fb3dce6a55784c..801489cf2baeae4e3b09a22b0428ff0a8ceb857e 100644 (file)
@@ -139,9 +139,10 @@ function upload_progress (e)
     upload_time_estimation_add(e.loaded);
     // Get speed string
     var speed_str = upload_time_estimation_speed_string();
+    speed_str = upload_speed_refresh_limiter(speed_str);
     // Get time string
     var time_str = chrono_update(upload_time_estimation_time());
-    
+
     show_upload_progression (p_str, speed_str, time_str);
 }
 
@@ -310,6 +311,7 @@ function async_upload_progress (e)
     upload_time_estimation_add(e.loaded + async_global_transfered);
     // Get speed string
     var speed_str = upload_time_estimation_speed_string();
+    speed_str = upload_speed_refresh_limiter(speed_str);
     // Get time string
     var time_str = chrono_update(upload_time_estimation_time());
 
@@ -558,3 +560,16 @@ function chrono_update(time_ms)
         time_str = milliseconds_to_time_string (chrono);
     return time_str;
 }
+
+var upload_speed_refresh_limiter_last_update = 0;
+var upload_speed_refresh_limiter_last_value = '';
+function upload_speed_refresh_limiter(speed_str)
+{
+    var d = new Date();
+    if (d.getTime() - upload_speed_refresh_limiter_last_update > 1500)
+    {
+        upload_speed_refresh_limiter_last_value = speed_str;
+        upload_speed_refresh_limiter_last_update = d.getTime();
+    }
+    return upload_speed_refresh_limiter_last_value;
+}
index 4495714c17c0fcc63dbdc900fec0f7f73daeb140..83cc6ba5796d8dde5f8d42ae9e17a58131521308 100644 (file)
@@ -35,6 +35,6 @@ else
   <link href="<?php echo $web_root . 'media/' . $style . '/style.css.php'; ?>" rel="stylesheet" type="text/css" />
 </head>
 <body>
-<script language="Javascript" src="lib/functions_v3.js"></script>
+<script language="Javascript" src="lib/functions_v4.js"></script>
 <div id="content">
 <h1><a href="<?php echo $web_root; ?>"><?php echo t('Jirafeau, your web file repository'); ?></a></h1>

patrick-canterino.de