diff --git a/board/static/board/post.js b/board/static/board/post.js
index 959a93a..a6d51a8 100644
--- a/board/static/board/post.js
+++ b/board/static/board/post.js
@@ -346,12 +346,12 @@ $(window).on("load", () => {
}
});
- $(".post_link").on("mouseover", (e) => {
+ $(document).on("mouseover", ".post_link", (e) => {
let postId = $(e.target).attr("data-post-id");
$("#p" + postId + ".post").addClass("post_highlight");
});
- $(".post_link").on("mouseout", (e) => {
+ $(document).on("mouseout", ".post_link", (e) => {
let postId = $(e.target).attr("data-post-id");
$("#p" + postId + ".post").removeClass("post_highlight");
});
@@ -376,6 +376,49 @@ $(window).on("load", () => {
fullEnt.find(".youtube_embed_container").append(embed);
}
});
+
+ // Add "replies to this post" links
+ $(".post_link").each((_index, postLink) => {
+ let replyToId = $(postLink).attr("data-post-id");
+ let replyTo = $("#p" + replyToId);
+ let replyFrom = $(postLink).parents(".post");
+ let replyFromId = replyFrom.attr("id").substring(1);
+ let replyFromUrl = replyFrom.find(".post_permalink").attr("href");
+
+ // Couldn't find the reply-to post
+ if (replyTo.length === 0) {
+ return;
+ }
+
+ let repliesContainer = replyTo.find(".post_replies");
+ // replies container doesn't exist, create it
+ if (repliesContainer.length === 0) {
+ repliesContainer = $("
").addClass("post_replies").text("Replies: ");
+ // put this after post_title element
+ replyTo.find(".post_title").after(repliesContainer);
+ } else {
+ // Make sure that reply doesn't already exist in this list
+ let containsReply = false;
+ repliesContainer.find(".post_reply").each((_index, reply) => {
+ if ($(reply).attr("href") === replyFromUrl) {
+ // this reply is contained, return
+ containsReply = true;
+ return;
+ }
+ });
+ if (containsReply) {
+ return;
+ }
+ }
+ repliesContainer.append(
+ $("
")
+ .addClass("post_reply")
+ .addClass("post_link")
+ .attr("data-post-id", replyFromId)
+ .attr("href", replyFromUrl)
+ .text(">>" + replyFromId)
+ );
+ });
});
// Load event that actually does stuff
diff --git a/board/static/board/style.css b/board/static/board/style.css
index 06b2b1e..76c98be 100644
--- a/board/static/board/style.css
+++ b/board/static/board/style.css
@@ -1,6 +1,6 @@
:root {
--body: #ededed;
- --highlight: #aaa;
+ --highlight: #c7c7c7;
--link: #555;
--border-color: #555;
--name: #060;
@@ -72,6 +72,10 @@ th {
/*******************************************************************************
Posts
********************************************************************************/
+.post {
+ display: table;
+}
+
.post_body {
overflow-wrap: break-word;
}
@@ -86,6 +90,12 @@ th {
padding-right: 5px;
}
+
+.post_replies {
+ font-size: smaller;
+ margin-left: 4px;
+}
+
.post_content:after {
content: "";
display: table;
diff --git a/board/templates/board/post_snippet.html b/board/templates/board/post_snippet.html
index b4e11fe..01bdaa8 100644
--- a/board/templates/board/post_snippet.html
+++ b/board/templates/board/post_snippet.html
@@ -19,7 +19,7 @@
{% endif %}
{# Post ID, status icons, username, time, admin info #}
- #.
+
#.
{{post.id}}
{% if post.subject %}
{{post.subject}}