From 672599e997c90e21b0341181baa1139461a64d06 Mon Sep 17 00:00:00 2001 From: Yo Mama Date: Wed, 20 Oct 2021 23:49:02 +0200 Subject: [PATCH] Maintain the original in html, but also adds a js that rewrites it to human-readable date --- files/templates/submission.html | 11 ++++++++++- files/templates/submission_listing.html | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/files/templates/submission.html b/files/templates/submission.html index 4340ddb9e..9e9358c56 100755 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -375,7 +375,7 @@ {% endfor %} {% endif %} {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} - {% if p.stickied %}{% endif %} + {% if p.stickied %}{% endif %} {% if p.is_pinned %}{% endif %} {% if p.distinguish_level %} {% endif %} {% if p.is_bot %} {% endif %} @@ -822,6 +822,15 @@ comments['{{p.id}}'] = { c: newTotal, t: Date.now() } window.localStorage.setItem("comment-counts", JSON.stringify(comments)) {% endif %} + + {% if p.stickied %} + const pinned_info = document.getElementById('pinned-{{p.id}}') + {% if p.stickied.startswith('t:') %} + pinned_info.setAttribute("data-bs-original-title", `Pinned until ${Date({{p.stickied[2:]}}).toString()}`) + {% else %} + pinned_info.setAttribute("data-bs-original-title", "Pinned by @{{p.stickied}}") + {%endif%} + {%endif%} })() diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 2e2b16afa..638821b9f 100755 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -80,6 +80,15 @@ {% if (not v or v.highlightcomments) %} showNewCommentCounts('{{p.id}}', {{p.comment_count}}) {% endif %} + + {% if p.stickied %} + const pinned_info = document.getElementById('pinned-{{p.id}}') + {% if p.stickied.startswith('t:') %} + pinned_info.setAttribute("data-bs-original-title", `Pinned until ${Date({{p.stickied[2:]}}).toString()}`) + {% else %} + pinned_info.setAttribute("data-bs-original-title", "Pinned by @{{p.stickied}}") + {%endif%} + {%endif%} })() @@ -174,7 +183,7 @@ {% endfor %} {% endif %} {% if v and v.admin_level==6 and p.author.shadowbanned %}{% endif %} - {% if p.stickied %}{% endif %} + {% if p.stickied %}{% endif %} {% if p.distinguish_level %}{% endif %} {% if p.is_pinned and request.path.startswith('/@') %}{% endif %} {% if p.over_18 %}+18{% endif %}