From 31eced04928ce9d5d0dda334ca35319cec6c3adf Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 13 Dec 2015 12:57:06 +0100 Subject: [PATCH] baculum: Improve size formatter precision --- gui/baculum/protected/JavaScript/misc.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gui/baculum/protected/JavaScript/misc.js b/gui/baculum/protected/JavaScript/misc.js index 7cadf6faf7..9995b5f8cb 100644 --- a/gui/baculum/protected/JavaScript/misc.js +++ b/gui/baculum/protected/JavaScript/misc.js @@ -1,15 +1,17 @@ var Units = { get_decimal_size: function(size) { + size = parseInt(size, 10); var size_unit = 'B'; var units = ['K', 'M', 'G', 'T', 'P']; var unit; var dec_size = size.toString() + ((size > 0 ) ? size_unit : ''); - while(size > 1000) { + while(size >= 1000) { size /= 1000; unit = units.shift(units); } if (unit) { - dec_size = size.toFixed(1) + unit + size_unit; + dec_size = (Math.floor(size * 10) / 10).toFixed(1); + dec_size += unit + size_unit; } return dec_size; } -- 2.39.5