diff options
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 +} |
