aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assets/css/default.css4
-rw-r--r--assets/js/index.js19
-rw-r--r--static/js/timeago.ts20
3 files changed, 23 insertions, 20 deletions
diff --git a/assets/css/default.css b/assets/css/default.css
index 0807056..02ae400 100644
--- a/assets/css/default.css
+++ b/assets/css/default.css
@@ -1743,10 +1743,6 @@ micro-author micro-header time {
color: var(--fade);
}
-web-ring time {
- font-variant: small-caps;
-}
-
web-ring p:not(:last-child) {
margin-bottom: 0;
}
diff --git a/assets/js/index.js b/assets/js/index.js
index 4ca5e4a..dc4fef1 100644
--- a/assets/js/index.js
+++ b/assets/js/index.js
@@ -574,6 +574,9 @@
const view = element.getBoundingClientRect();
return view.top >= -options.offset && view.left >= -options.offset && view.bottom <= (window.innerHeight || self.documentElement.clientHeight) + options.offset && view.right <= (window.innerWidth || self.documentElement.clientWidth) + options.offset;
}
+ function tiny(string, place) {
+ return string.split(" ").slice(0, place).join(" ") + string.split(" ")[place].charAt(0);
+ }
const date = function(update) {
const elements = document.querySelectorAll("time");
for(let i = 0; i < elements.length; ++i){
@@ -592,30 +595,30 @@
const future = Math.sign(seconds) === -1;
if (past) {
if (seconds <= 60) {
- return element.textContent = relative.format(-1 * seconds, "second");
+ return element.textContent = tiny(relative.format(-1 * seconds, "second"), 1);
}
if (minutes <= 120) {
- return element.textContent = relative.format(-1 * minutes, "minute");
+ return element.textContent = tiny(relative.format(-1 * minutes, "minute"), 1);
}
if (hours <= 48) {
- return element.textContent = relative.format(-1 * hours, "hour");
+ return element.textContent = tiny(relative.format(-1 * hours, "hour"), 1);
}
if (days <= 7) {
- return element.textContent = relative.format(-1 * days, "day");
+ return element.textContent = tiny(relative.format(-1 * days, "day"), 1);
}
}
if (future) {
if (-1 * days >= 4) {
- return element.textContent = relative.format(-1 * days, "day");
+ return element.textContent = tiny(relative.format(-1 * days, "day"), 2);
}
if (-1 * hours >= 3) {
- return element.textContent = relative.format(-1 * hours, "hour");
+ return element.textContent = tiny(relative.format(-1 * hours, "hour"), 2);
}
if (-1 * minutes >= 2) {
- return element.textContent = relative.format(-1 * minutes, "minute");
+ return element.textContent = tiny(relative.format(-1 * minutes, "minute"), 2);
}
if (-1 * seconds >= 1) {
- return element.textContent = relative.format(-1 * seconds, "second");
+ return element.textContent = tiny(relative.format(-1 * seconds, "second"), 2);
}
}
} catch (error) {
diff --git a/static/js/timeago.ts b/static/js/timeago.ts
index 55616f0..47f6b79 100644
--- a/static/js/timeago.ts
+++ b/static/js/timeago.ts
@@ -15,6 +15,10 @@
view.right <= (window.innerWidth || self.documentElement.clientWidth) + options.offset;
}
+ function tiny(string, place) {
+ return string.split(" ").slice(0, place).join(" ") + string.split(" ")[place].charAt(0);
+ }
+
const date = function (update) {
const elements = document.querySelectorAll("time");
for (let i = 0; i < elements.length; ++i) {
@@ -36,17 +40,17 @@
const future = Math.sign(seconds) === -1;
if (past) {
- if (seconds <= 60) { return element.textContent = relative.format(-1 * seconds, "second",); }
- if (minutes <= 120) { return element.textContent = relative.format(-1 * minutes, "minute",); }
- if (hours <= 48) { return element.textContent = relative.format(-1 * hours, "hour",); }
- if (days <= 7) { return element.textContent = relative.format(-1 * days, "day",); }
+ if (seconds <= 60) { return element.textContent = tiny(relative.format(-1 * seconds, "second",), 1); }
+ if (minutes <= 120) { return element.textContent = tiny(relative.format(-1 * minutes, "minute",), 1); }
+ if (hours <= 48) { return element.textContent = tiny(relative.format(-1 * hours, "hour",), 1); }
+ if (days <= 7) { return element.textContent = tiny(relative.format(-1 * days, "day",), 1); }
}
if (future) {
- if (-1 * days >= 4) { return element.textContent = relative.format(-1 * days, "day",); }
- if (-1 * hours >= 3) { return element.textContent = relative.format(-1 * hours, "hour",); }
- if (-1 * minutes >= 2) { return element.textContent = relative.format(-1 * minutes, "minute",); }
- if (-1 * seconds >= 1) { return element.textContent = relative.format(-1 * seconds, "second",); }
+ if (-1 * days >= 4) { return element.textContent = tiny(relative.format(-1 * days, "day",), 2); }
+ if (-1 * hours >= 3) { return element.textContent = tiny(relative.format(-1 * hours, "hour",), 2); }
+ if (-1 * minutes >= 2) { return element.textContent = tiny(relative.format(-1 * minutes, "minute",), 2); }
+ if (-1 * seconds >= 1) { return element.textContent = tiny(relative.format(-1 * seconds, "second",), 2); }
}
} catch (error) {
console.error(