From 289b5992339420757859432593cf8b31827b9978 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Feb 2016 22:32:22 +0100 Subject: [PATCH] gluon-status-page: unify prefix list of prettyBytes and prettyBits --- package/gluon-status-page/src/js/lib/gui/statistics.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/package/gluon-status-page/src/js/lib/gui/statistics.js b/package/gluon-status-page/src/js/lib/gui/statistics.js index 3dcf5a52..af984e6e 100644 --- a/package/gluon-status-page/src/js/lib/gui/statistics.js +++ b/package/gluon-status-page/src/js/lib/gui/statistics.js @@ -178,7 +178,7 @@ define(["lib/helper"], function (Helper) { function prettyPrefix(prefixes, step, d) { var prefix = 0 - while (d > step && prefix < 4) { + while (d > step && prefix < prefixes.length - 1) { d /= step prefix++ } @@ -187,12 +187,16 @@ define(["lib/helper"], function (Helper) { return d + " " + prefixes[prefix] } + function prettySize(d) { + return prettyPrefix([ "", "k", "M", "G", "T" ], 1024, d) + } + function prettyBits(d) { - return prettyPrefix([ "bps", "kbps", "Mbps", "Gbps" ], 1024, d * 8) + return prettySize(d * 8) + "bps" } function prettyBytes(d) { - return prettyPrefix([ "B", "kB", "MB", "GB", "TB" ], 1024, d) + return prettySize(d) + "B" } function prettyUptime(seconds) {