Skip to content

Commit ae0f9fe

Browse files
committed
reply button
1 parent b9cc7f7 commit ae0f9fe

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

public/topic.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ document.addEventListener("DOMContentLoaded", () => {
88
element.querySelector(".post-user-role").innerText = data.hatchTeam === true ? "Hatch Team" : "Hatchling";
99
});
1010
});
11+
1112
Array.from(document.getElementsByClassName("post-content")).forEach(element => {
1213
element.innerHTML = marked.parse(element.innerText
1314
.replace(/&/g, "&")
@@ -40,6 +41,13 @@ document.addEventListener("DOMContentLoaded", () => {
4041
});
4142
});
4243

44+
Array.from(document.getElementsByClassName("post-reply-button")).forEach(element => {
45+
element.addEventListener("click", () => {
46+
document.querySelector("#new_post_content").value = `${document.querySelector("#new_post_content").value}[quote=${element.parentElement.parentElement.dataset.author}]\n${element.dataset.postcontent}\n[/quote]`;
47+
document.querySelector("#new_post_content").focus();
48+
});
49+
});
50+
4351
const mod_actions_bar = document.querySelector("#mod-actions");
4452
const post_deletion_buttons = document.querySelectorAll(".post-deletion-button");
4553

views/topic.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#<%= i+1 %> <span class="post-date"><%= ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.getMonth()] %> <%= date.getDate() %> <%= date.getFullYear() %> <%= date.getHours() %>:<%= date.getMinutes().toString().length === 1 ? "0" : "" %><%= date.getMinutes() %>:<%= date.getSeconds().toString().length === 1 ? "0" : "" %><%= date.getSeconds() %></span>
3333
<a class="post-action-button" title="Report" href="/report/<%= posts[i].id %>">🚩</a>
3434
<a class="post-action-button post-deletion-button" title="Delete" href="/admin/delete/post/<%= posts[i].id %>">Delete</a>
35+
<a class="post-action-button post-reply-button" title="Reply" data-postcontent="<%= posts[i].content %>">Reply</a>
3536
</div>
3637
<div class="post-stuff">
3738
<section>

0 commit comments

Comments
 (0)