make relative time apply to more stuff like news and reports references #57

merge-requests/208/head
fatchan 5 years ago
parent 5784b4925f
commit adcfdabccc
  1. 6
      gulp/res/js/post.js
  2. 4
      gulp/res/js/time.js
  3. 3
      views/mixins/newspost.pug
  4. 2
      views/mixins/post.pug
  5. 8
      views/mixins/report.pug

@ -7,7 +7,9 @@ var pug_has_own_property=Object.prototype.hasOwnProperty;
var pug_match_html=/["&<>]/;
function pug_style(r){if(!r)return"";if("object"==typeof r){var t="";for(var e in r)pug_has_own_property.call(r,e)&&(t=t+e+":"+r[e]+";");return t}return r+""}function post(locals) {var pug_html = "", pug_mixins = {}, pug_interp;;var locals_for_with = (locals || {});(function (Date, encodeURIComponent, ipHashSub, post) {pug_mixins["report"] = pug_interp = function(r){
var block = (this && this.block), attributes = (this && this.attributes) || {};
pug_html = pug_html + "\u003Cdiv class=\"reports post-container\"\u003E\u003Cinput" + (" class=\"post-check\""+" type=\"checkbox\" name=\"checkedreports\""+pug_attr("value", r.id, true, false)) + "\u002F\u003E\t\u003Cspan\u003EDate: " + (pug_escape(null == (pug_interp = r.date.toLocaleString()) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E \u003Cspan\u003EReason: " + (pug_escape(null == (pug_interp = r.reason) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E";
pug_html = pug_html + "\u003Cdiv class=\"reports post-container\"\u003E\u003Cinput" + (" class=\"post-check\""+" type=\"checkbox\" name=\"checkedreports\""+pug_attr("value", r.id, true, false)) + "\u002F\u003E Date: ";
const reportDate = new Date(r.date);
pug_html = pug_html + "\u003Cspan" + (" class=\"reltime\""+pug_attr("datetime", reportDate.toISOString(), true, false)) + "\u003E" + (pug_escape(null == (pug_interp = reportDate.toLocaleString(undefined, { hour12:false })) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E Reason: " + (pug_escape(null == (pug_interp = r.reason) ? "" : pug_interp)) + "\u003C\u002Fdiv\u003E";
};
pug_mixins["post"] = pug_interp = function(post, truncate, manage=false, globalmanage=false, ban=false){
var block = (this && this.block), attributes = (this && this.attributes) || {};
@ -58,7 +60,7 @@ if (post.capcode) {
pug_html = pug_html + "\u003Cspan class=\"post-capcode\"\u003E" + (pug_escape(null == (pug_interp = post.capcode) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E ";
}
const postDate = new Date(post.date);
pug_html = pug_html + "\u003Ctime" + (" class=\"post-date\""+pug_attr("datetime", postDate.toISOString(), true, false)) + "\u003E" + (pug_escape(null == (pug_interp = postDate.toLocaleString("en-US", { hour12:false, timeZone: "America/New_York" })) ? "" : pug_interp)) + "\u003C\u002Ftime\u003E ";
pug_html = pug_html + "\u003Ctime" + (" class=\"post-date reltime\""+pug_attr("datetime", postDate.toISOString(), true, false)) + "\u003E" + (pug_escape(null == (pug_interp = postDate.toLocaleString(undefined, { hour12:false })) ? "" : pug_interp)) + "\u003C\u002Ftime\u003E ";
if (post.userId) {
pug_html = pug_html + "\u003Cspan" + (" class=\"user-id\""+pug_attr("style", pug_style(`background-color: #${post.userId}`), true, false)) + "\u003E" + (pug_escape(null == (pug_interp = post.userId) ? "" : pug_interp)) + "\u003C\u002Fspan\u003E ";
}

@ -5,7 +5,7 @@ let relativeTime = localStorage.getItem('relative') == 'true';
let hour24 = localStorage.getItem('24hour') == 'true';
let dates = [];
const dateElems = document.getElementsByClassName('post-date');
const dateElems = document.getElementsByClassName('reltime');
for (let i = 0; i < dateElems.length; i++) {
dates.push(dateElems[i]); //convert to array
}
@ -96,7 +96,7 @@ window.addEventListener('settingsReady', function(event) {
window.addEventListener('addPost', function(e) {
const date = e.detail.post.querySelector('.post-date');
const date = e.detail.post.querySelector('.reltime');
if (!e.detail.hover) {
dates.push(date);
}

@ -7,7 +7,8 @@ mixin newspost(post, globalmanage=false)
if globalmanage === true
input.left.post-check(type='checkbox', name='checkednews' value=post._id)
a.left(href=`#${post._id}`) #{post.title}
p.right.no-m-p #{post.date.toLocaleString(undefined, {hour12:false})}
- const newsDate = new Date(post.date);
time.right.reltime(datetime=newsDate.toISOString()) #{newsDate.toLocaleString(undefined, {hour12:false})}
tr
td
if globalmanage === true

@ -34,7 +34,7 @@ mixin post(post, truncate, manage=false, globalmanage=false, ban=false)
span.post-capcode #{post.capcode}
|
- const postDate = new Date(post.date);
time.post-date(datetime=postDate.toISOString()) #{postDate.toLocaleString("en-US", { hour12:false, timeZone: "America/New_York" })}
time.post-date.reltime(datetime=postDate.toISOString()) #{postDate.toLocaleString(undefined, { hour12:false })}
|
if post.userId
span.user-id(style=`background-color: #${post.userId}`) #{post.userId}

@ -1,7 +1,7 @@
mixin report(r)
.reports.post-container
input.post-check(type='checkbox', name='checkedreports' value=r.id)
|
span Date: #{r.date.toLocaleString()}
|
span Reason: #{r.reason}
| Date:
- const reportDate = new Date(r.date);
time.reltime(datetime=reportDate.toISOString()) #{reportDate.toLocaleString(undefined, { hour12:false })}
| Reason: #{r.reason}

Loading…
Cancel
Save