post quoting changes and improvements for JS users

merge-requests/208/head
fatchan 5 years ago
parent 9bd6aa4339
commit 8741e1d7f6
  1. 1
      gulp/res/css/style.css
  2. 8
      gulp/res/js/post.js
  3. 21
      gulp/res/js/quote.js

@ -92,6 +92,7 @@ pre {
background: var(--darken);
padding: 2px;
font-family: monospace;
max-width: max-content;
}
.text-center {
text-align: center;

@ -11,9 +11,9 @@ pug_html = pug_html + "\u003Cdiv class=\"reports post-container\"\u003E\u003Cinp
};
pug_mixins["post"] = pug_interp = function(post, truncate, manage=false, globalmanage=false, ban=false){
var block = (this && this.block), attributes = (this && this.attributes) || {};
pug_html = pug_html + "\u003Cdiv" + (" class=\"anchor\""+pug_attr("id", post.postId, true, false)) + "\u003E\u003C\u002Fdiv\u003E\u003Carticle" + (pug_attr("class", pug_classes([`post-container ${post.thread || ban === true ? '' : 'op'}`], [true]), false, false)) + "\u003E";
pug_html = pug_html + "\u003Cdiv" + (" class=\"anchor\""+pug_attr("id", post.postId, true, false)) + "\u003E\u003C\u002Fdiv\u003E\u003Cdiv" + (pug_attr("class", pug_classes([`post-container ${post.thread || ban === true ? '' : 'op'}`], [true]), false, false)) + "\u003E";
const postURL = `/${post.board}/thread/${post.thread || post.postId}.html`;
pug_html = pug_html + "\u003Cheader class=\"post-info\"\u003E\u003Clabel\u003E";
pug_html = pug_html + "\u003Cdiv class=\"post-info\"\u003E\u003Clabel\u003E";
if (globalmanage) {
pug_html = pug_html + "\u003Cinput" + (" class=\"post-check\""+" type=\"checkbox\" name=\"globalcheckedposts\""+pug_attr("value", post._id, true, false)) + "\u002F\u003E";
}
@ -64,7 +64,7 @@ pug_html = pug_html + "\u003C\u002Flabel\u003E\u003Cspan class=\"post-links\"\u0
if (!post.thread) {
pug_html = pug_html + " \u003Cspan\u003E\u003Ca" + (pug_attr("href", `${postURL}#postform`, true, false)) + "\u003E[Reply]\u003C\u002Fa\u003E\u003C\u002Fspan\u003E";
}
pug_html = pug_html + "\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E\u003C\u002Fheader\u003E\u003Cdiv class=\"post-data\"\u003E";
pug_html = pug_html + "\u003C\u002Fspan\u003E\u003C\u002Fspan\u003E\u003C\u002Fdiv\u003E\u003Cdiv class=\"post-data\"\u003E";
if (post.files.length > 0) {
pug_html = pug_html + "\u003Cdiv class=\"post-files\"\u003E";
// iterate post.files
@ -199,7 +199,7 @@ pug_html = pug_html + "\u003Ca" + (" class=\"quote\""+pug_attr("href", `/${post.
pug_html = pug_html + "\u003C\u002Fdiv\u003E";
}
pug_html = pug_html + "\u003C\u002Fdiv\u003E\u003C\u002Farticle\u003E";
pug_html = pug_html + "\u003C\u002Fdiv\u003E\u003C\u002Fdiv\u003E";
if (manage === true) {
// iterate post.reports
;(function(){

@ -1,18 +1,37 @@
window.addEventListener('DOMContentLoaded', (event) => {
const isThread = /\/\w+\/thread\/\d+.html/.test(window.location.pathname);
const links = document.getElementsByClassName('post-quoters');
const messageBox = document.getElementById('message');
const addQuote = function(number) {
window.location.hash = 'postform'; //open postform
messageBox.value += `>>${number}\n`;
messageBox.scrollTop = messageBox.scrollHeight;
messageBox.focus();
messageBox.setSelectionRange(messageBox.value.length, messageBox.value.length);
}
const quote = function(e) {
e.preventDefault();
const quoteNum = this.textContent.replace('[Reply]', '').split(' ')[0].trim();
addQuote(quoteNum);
if (isThread) {
addQuote(quoteNum);
} else {
localStorage.setItem('clickedQuote', quoteNum);
window.location = this.firstChild.href.replace(/#postform$/, '#'+quoteNum);
}
};
//on loading page after clicking quote
if (isThread) {
const quoteNum = localStorage.getItem('clickedQuote');
if (quoteNum != null) {
addQuote(quoteNum);
}
localStorage.removeItem('clickedQuote');
}
for (let i = 0; i < links.length; i++) {
links[i].addEventListener('click', quote, false);
}

Loading…
Cancel
Save