same improvements to timeutils as in frontend, and remove old method of showing ban with document write

merge-requests/208/head
fatchan 5 years ago
parent a7a31c8c9e
commit 66e3f29f4f
  1. 9
      gulp/res/js/forms.js
  2. 4
      gulp/res/js/quote.js
  3. 10
      helpers/timeutils.js

@ -10,13 +10,6 @@ function doModal(data) {
document.getElementsByClassName('modal-bg')[0].onclick = removeModal;
}
function doTextResponse(text, url) {
window.history.pushState({}, null, url);
document.open('text/html', true);
document.write(text);
document.close();
}
const checkTypes = ['checkbox', 'radio'];
function isCheckBox(element) {
return checkTypes.includes(element.type)
@ -143,7 +136,7 @@ class formHandler {
if (json) {
doModal(json);
} else {
//for bans, post form to show
//for bans, post form to show TODO: make modal support bans json and send dynamicresponse from it
this.clearFiles(); //dont resubmit files
this.banned = true;
this.form.dispatchEvent(new Event('submit'));

@ -9,6 +9,10 @@ window.addEventListener('DOMContentLoaded', (event) => {
messageBox.scrollTop = messageBox.scrollHeight;
messageBox.focus();
messageBox.setSelectionRange(messageBox.value.length, messageBox.value.length);
const quotingPost = document.getElementById(number);
if (quotingPost) {
quotingPost.scrollIntoView();
}
}
const quote = function(e) {

@ -21,6 +21,11 @@ module.exports = {
const difference = now.getTime() - relativeTo.getTime();
let amount = 0;
let ret = '';
let isFuture = false;
if (difference < 0) {
difference = Math.abs(difference);
isFuture = true;
}
if (difference < MINUTE) {
return 'Now';
} else if (difference < MINUTE*59.5) {
@ -39,9 +44,10 @@ module.exports = {
amount = Math.round(difference / MONTH);
ret += `${amount} month`;
} else {
return 'More than a year ago';
amount = Math.round(difference / YEAR);
ret = `${amount} year`;
}
return `${ret}${amount > 1 ? 's' : ''} ago`;
return `${ret}${amount > 1 ? 's' : ''} ${isFuture ? 'from now' : 'ago'}`;
},
'relativeColor': (now, relativeTo) => {

Loading…
Cancel
Save