From: Jerome Jutteau Date: Mon, 23 Mar 2015 11:08:59 +0000 (+0100) Subject: lib/function.js: limit refresh of upload speed X-Git-Tag: 1.1~134 X-Git-Url: https://git.p6c8.net/jirafeau.git/commitdiff_plain/9f0a00e60a7554b51393d139ba5e2f71b11d326a lib/function.js: limit refresh of upload speed --- 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 - +