From e33570625f5e619200d6d3202b6909b120251c42 Mon Sep 17 00:00:00 2001 From: ngosang Date: Sun, 26 Jul 2015 14:30:35 +0200 Subject: [PATCH] [Web UI] Fix friendlyUnit() implementation. Related to #2719 --- src/webui/www/public/scripts/misc.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/webui/www/public/scripts/misc.js b/src/webui/www/public/scripts/misc.js index 29fb5c713..73740cf61 100644 --- a/src/webui/www/public/scripts/misc.js +++ b/src/webui/www/public/scripts/misc.js @@ -12,12 +12,19 @@ function friendlyUnit(value, isSpeed) { if (value < 0) return "QBT_TR(Unknown)QBT_TR"; + var i = 0; - while (value >= 1024. && i++ < 6) + while (value >= 1024. && i < 4) { value /= 1024.; + ++i; + } var ret; - ret = (Math.floor(10 * value) / 10).toFixed(1) //Don't round up + if (i == 0) + ret = value + " " + units[i]; + else + ret = (Math.floor(10 * value) / 10).toFixed(1) //Don't round up + " " + units[i]; + if (isSpeed) ret += "QBT_TR(/s)QBT_TR"; return ret;