From 32fc8941b87a89f90bc37bb9e4db0f90331020b0 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 8 Oct 2021 20:52:52 +0200 Subject: [PATCH] luci-base: cbi.js: use IEC 80000-13 units to format base 2 byte values Fixes: #5354 Signed-off-by: Jo-Philipp Wich (cherry picked from commit 0a31efc858b02cd5aa9f38c1b5b40a9a14a61c1a) --- modules/luci-base/htdocs/luci-static/resources/cbi.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 513256e4c9..b8446ec52f 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -646,7 +646,11 @@ String.prototype.format = function() for (i = 0; (i < units.length) && (val > mf); i++) val /= mf; - subst = (i ? val.toFixed(pr) : val) + units[i]; + if (i) + subst = val.toFixed(pr) + units[i] + (mf == 1024 ? 'i' : ''); + else + subst = val + ' '; + pMinLength = null; break; } -- 2.30.2