From: Marcin Haba Date: Sun, 13 Dec 2015 11:57:06 +0000 (+0100) Subject: baculum: Improve size formatter precision X-Git-Tag: Release-7.4.0~137 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=31eced04928ce9d5d0dda334ca35319cec6c3adf;p=bacula%2Fbacula baculum: Improve size formatter precision --- 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; }