diff --git a/tildes/static/js/behaviors/comment-reply-button.js b/tildes/static/js/behaviors/comment-reply-button.js index 0f94ad4..e0af3fb 100644 --- a/tildes/static/js/behaviors/comment-reply-button.js +++ b/tildes/static/js/behaviors/comment-reply-button.js @@ -79,6 +79,23 @@ $.onmount("[data-js-comment-reply-button]", function() { } } + var parentCommentTimestamp = new Date( + $parentComment + .find(".comment-posted-time") + .first() + .attr("datetime") + ); + + // add a warning if the comment being replied to is over a week old + if (Date.now() - parentCommentTimestamp > 1000 * 3600 * 24 * 7) { + var warningDiv = document.createElement("div"); + warningDiv.classList.add("toast", "toast-minor", "toast-warning"); + warningDiv.innerHTML = + "
(Replying to old comments is fine, just making sure it's intentional)
"; + clone.querySelector("form").prepend(warningDiv); + } + // update Intercooler so it knows about this new form Intercooler.processNodes(clone); diff --git a/tildes/tildes/templates/topic.jinja2 b/tildes/tildes/templates/topic.jinja2 index 73c4697..985a8c6 100644 --- a/tildes/tildes/templates/topic.jinja2 +++ b/tildes/tildes/templates/topic.jinja2 @@ -213,6 +213,12 @@ data-js-prevent-double-submit data-js-confirm-leave-page-unsaved > + {% if old_topic_warning %} +(Replying to old topics is fine, just making sure it's intentional)
+