summaryrefslogtreecommitdiff
path: root/public/assets/js/util/format.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/util/format.js')
-rw-r--r--public/assets/js/util/format.js18
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: &#8209;
var date = d + '&nbsp;' + short_months[date.getMonth()] + '&nbsp;' + 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 + "&nbsp;kv."] }
else { return ["new", txt + "&nbsp;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 + "&nbsp;t."] }
+ else if (n < 25) { return ["old", txt + "&nbsp;t."] }
+ else if (n < 50) { return ["med", txt + "&nbsp;t."] }
+ else if (no_bold || n < 100) { return ["recent", txt + "&nbsp;t."] }
+ else { return ["new", txt + "&nbsp;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
+}