From 61bb1c3598b17d9537c13a20acb4d4deffe064d6 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 25 May 2012 09:33:34 +0200 Subject: [PATCH] typo; fix a test --- source/Ox/js/Format.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source/Ox/js/Format.js b/source/Ox/js/Format.js index 4247a336..e04143e6 100644 --- a/source/Ox/js/Format.js +++ b/source/Ox/js/Format.js @@ -279,7 +279,7 @@ Ox.formatDateRange = function(start, end, utc) { if (i == precision[0] - 1 && parts[0][i] != parts[1][i] - 1) { isOneUnit = false; } - !isOneUnit && Ox.Break()(); + !isOneUnit && Ox.Break(); }); } if (isOneUnit) { @@ -561,10 +561,21 @@ Ox.formatString = function (str, obj) { }); }; +/*@ +Ox.formatUnit Formats a number with a unit + > Ox.formatUnit(0.333333, '%', 2, 100) + "33.33%" +@*/ +Ox.formatUnit = function(num, str, dec, factor) { + dec = Ox.isUndefined(dec) ? 3 : dec; + factor = Ox.isUndefined(factor) ? 1 : factor; + return Ox.formatNumber(num * factor, dec) + (str == '%' ? '' : ' ') + str; +}; + /*@ Ox.formatValue Formats a numerical value > Ox.formatValue(0, "B") - "0 KB" + "0 B" > Ox.formatValue(123456789, "B") "123.5 MB" > Ox.formatValue(1234567890, "B", true) @@ -577,25 +588,14 @@ Ox.formatValue = function(num, str, bin) { val; Ox.forEach(Ox.PREFIXES, function(chr, i) { if (num < Math.pow(base, i + 1) || i == len - 1) { - val = Ox.formatNumber(num / Math.pow(base, i), i ? i - 1 : 0) + - ' ' + chr + (chr && bin ? 'i' : '') + str; - Ox.Break()(); + val = Ox.formatNumber(num / Math.pow(base, i), i ? i - 1 : 0) + + ' ' + chr + (chr && bin ? 'i' : '') + str; + Ox.Break(); } }); return val; }; -/*@ -Ox.formatUnit Formats a number with a unit - > Ox.formatUnit(0.333333, '%', 2, 100) - "33.33%" -@*/ -Ox.formatUnit = function(num, str, dec, factor) { - dec = Ox.isUndefined(dec) ? 3 : dec; - factor = Ox.isUndefined(factor) ? 1 : factor; - return Ox.formatNumber(num * factor, dec) + (str == '%' ? '' : ' ') + str; -}; - /*@ Ox.parseDuration Takes a formatted duration, returns seconds > Ox.parseDuration('01:02:03')