diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-15 06:52:54 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-15 06:52:54 +0100 |
| commit | a1b33089877660ba33331d76281e68790f35ae44 (patch) | |
| tree | 168692d34f8af123ef2bab505a3cdbe4d1d57229 /public/assets/js/util/format.js | |
| parent | 7ad469291c015b33a2d20587db26b9621ed82d00 (diff) | |
keywords list
Diffstat (limited to 'public/assets/js/util/format.js')
| -rw-r--r-- | public/assets/js/util/format.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index e58928e..5002899 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -8,10 +8,11 @@ document.body.classList.add(is_desktop ? 'desktop' : 'mobile'); function csrf() { return $("[name=_csrf]").attr("value") } -function commatize (n) { +function commatize (n, radix) { + radix = radix || 1024 var nums = [], i, counter = 0, r = Math.floor - if (n > 1024) { - n /= 1024 + if (n > radix) { + n /= radix nums.unshift(r((n * 10) % 10)) nums.unshift(".") } @@ -82,7 +83,7 @@ function carbon_date (date, no_bold) { } function hush_views (n, bias, no_bold) { - var txt = commatize(n) + var txt = commatize(n, 1000) bias = bias || 1 n = n || 0 if (n < 30) { return["quiet", n + " v."] } @@ -90,11 +91,11 @@ function hush_views (n, bias, no_bold) { else if (n < 500) { return ["quiet", txt + " v."] } else if (n < 1000) { return ["old", txt + " v."] } else if (n < 5000) { return ["med", txt + " kv."] } - else if (nobold || n < 10000) { return ["recent", txt + " kv."] } + else if (no_bold || n < 10000) { return ["recent", txt + " kv."] } else { return ["new", txt + " kv."] } } -function hush_size (n, bias, nobold) { +function hush_size (n, bias, no_bold) { var txt = commatize(Math.floor(n / 1024)) bias = 1 || bias n = n || 0 @@ -113,7 +114,7 @@ function hush_size (n, bias, nobold) { else if (n < (80000000/bias)) { return ["med", txt + " mb."] } - else if (nobold || n < (170000000/bias)) { + else if (no_bold || n < (170000000/bias)) { return ["recent", txt + " mb."] } else { |
