From 9f0a00e60a7554b51393d139ba5e2f71b11d326a Mon Sep 17 00:00:00 2001 From: Jerome Jutteau Date: Mon, 23 Mar 2015 12:08:59 +0100 Subject: [PATCH 1/1] lib/function.js: limit refresh of upload speed --- lib/{functions_v3.js => functions_v4.js} | 17 ++++++++++++++++- lib/template/header.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) rename lib/{functions_v3.js => functions_v4.js} (97%) diff --git a/lib/functions_v3.js b/lib/functions_v4.js similarity index 97% rename from lib/functions_v3.js rename to lib/functions_v4.js index 0947eb3..801489c 100644 --- a/lib/functions_v3.js +++ b/lib/functions_v4.js @@ -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; +} diff --git a/lib/template/header.php b/lib/template/header.php index 4495714..83cc6ba 100644 --- a/lib/template/header.php +++ b/lib/template/header.php @@ -35,6 +35,6 @@ else - +

-- 2.34.1