improve Ox.formatValue

This commit is contained in:
rlx 2012-03-24 10:39:21 +00:00
parent 211abb10ab
commit 7818d4deb6
2 changed files with 5 additions and 5 deletions

View file

@ -82,8 +82,8 @@ Ox.PATH = Ox.makeArray(
).reverse().filter(function(element) { ).reverse().filter(function(element) {
return /Ox\.js$/.test(element.src); return /Ox\.js$/.test(element.src);
})[0].src.replace(/Ox\.js$/, ''); })[0].src.replace(/Ox\.js$/, '');
//@ Ox.PREFIXES <[str]> <code>['K', 'M', 'G', 'T', 'P']</code> //@ Ox.PREFIXES <[str]> <code>['', 'K', 'M', 'G', 'T', 'P']</code>
Ox.PREFIXES = ['K', 'M', 'G', 'T', 'P']; Ox.PREFIXES = ['', 'K', 'M', 'G', 'T', 'P'];
//@ Ox.SEASONS <[str]> Names of the seasons of the year //@ Ox.SEASONS <[str]> Names of the seasons of the year
Ox.SEASONS = ['Winter', 'Spring', 'Summer', 'Fall']; Ox.SEASONS = ['Winter', 'Spring', 'Summer', 'Fall'];
//@ Ox.SYMBOLS <obj> Unicode characters for symbols //@ Ox.SYMBOLS <obj> Unicode characters for symbols

View file

@ -545,9 +545,9 @@ Ox.formatValue = function(num, str, bin) {
len = Ox.PREFIXES.length, len = Ox.PREFIXES.length,
val; val;
Ox.forEach(Ox.PREFIXES, function(chr, i) { Ox.forEach(Ox.PREFIXES, function(chr, i) {
if (num < Math.pow(base, i + 2) || i == len - 1) { if (num < Math.pow(base, i + 1) || i == len - 1) {
val = Ox.formatNumber(num / Math.pow(base, i + 1), i) + val = Ox.formatNumber(num / Math.pow(base, i), i) +
' ' + chr + (bin ? 'i' : '') + str; ' ' + chr + (chr && bin ? 'i' : '') + str;
return false; return false;
} }
}); });