diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:11:26 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:11:26 +0100 |
| commit | fa4ed0f3b1ce5decfc6ee59d38e63e78a7793de4 (patch) | |
| tree | 74658c754cbdff432aa8dc8b4f3521c993993c45 /public/assets/js/util/format.js | |
| parent | 1a67f6f262364ee4fed0c1538ef2f41d772bf1b1 (diff) | |
new keyword form
Diffstat (limited to 'public/assets/js/util/format.js')
| -rw-r--r-- | public/assets/js/util/format.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index bc114b9..36a3d37 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -5,6 +5,8 @@ var is_mobile = is_iphone || is_ipad || is_android var is_desktop = ! is_mobile; document.body.classList.add(is_desktop ? 'desktop' : 'mobile'); +function choice(a){ return a[randint(a.length)] } + function csrf() { return $("[name=_csrf]").attr("value") } @@ -58,11 +60,11 @@ function verbose_date (date, no_pad_hours) { if (d < 10) d = "0" + d if (m < 10) m = "0" + m if (! no_pad_hours && h < 10) h = "0" + h - + // non-breaking hyphen: ‑ var date = d + ' ' + short_months[date.getMonth()] + ' ' + date.getFullYear() var time = h + ':' + m + meridian - + return [date, time] } function carbon_date (date, no_bold) { @@ -94,6 +96,16 @@ function hush_views (n, bias, no_bold) { else if (no_bold || n < 10000) { return ["recent", txt + " kv."] } else { return ["new", txt + " kv."] } } +function hush_threads (n, bias, no_bold) { + var txt = commatize(n, 1000) + bias = bias || 1 + n = n || 0 + if (n < 10) { return["quiet", n + " t."] } + else if (n < 25) { return ["old", txt + " t."] } + else if (n < 50) { return ["med", txt + " t."] } + else if (no_bold || n < 100) { return ["recent", txt + " t."] } + else { return ["new", txt + " t."] } +} function hush_size (n, bias, no_bold) { var txt = commatize(Math.floor(n / 1024)) @@ -243,4 +255,4 @@ function metadata(thread){ .replace(/{{active}}/g, age + " ago") .replace(/{{views}}/g, thread.viewed + " view" + courtesy_s(thread.viewed)) return t -}
\ No newline at end of file +} |
