From ec3f144b4ee788a59a14827da065a3eafab09517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 24 May 2025 01:07:58 +0300 Subject: [PATCH] add reply button functionality --- js/thread.js | 8 ++++++++ views/threads/post.etlua | 4 +++- views/threads/thread.etlua | 14 +++++++++++--- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 js/thread.js diff --git a/js/thread.js b/js/thread.js new file mode 100644 index 0000000..84b17f0 --- /dev/null +++ b/js/thread.js @@ -0,0 +1,8 @@ +const ta = document.getElementById("post_content"); + +for (let button of document.querySelectorAll(".reply-button")) { + button.addEventListener("click", (e) => { + ta.value += button.value; + ta.scrollIntoView() + }) +} diff --git a/views/threads/post.etlua b/views/threads/post.etlua index fc99a2f..609015a 100644 --- a/views/threads/post.etlua +++ b/views/threads/post.etlua @@ -43,8 +43,10 @@ show_reply = false end if show_reply then + local d = post.created_at < post.edited_at and post.edited_at or post.created_at + local reply_text = ("On %s, %s said:\n%s\n\n---\n\n"):format(os.date("%c", d), post.username, post.original_markup) %> - + <% end %> diff --git a/views/threads/thread.etlua b/views/threads/thread.etlua index 5248981..f98146e 100644 --- a/views/threads/thread.etlua +++ b/views/threads/thread.etlua @@ -1,4 +1,11 @@ -<% local is_locked = ntob(thread.is_locked) %> +<% + local is_locked = ntob(thread.is_locked) + local can_post = (not is_locked and not me:is_guest()) or me:is_mod() + -- not locked, not guest, not mod = not false and not false or false = true and true or false = true + -- locked, not guest, not mod = not true and not false or false = false and true or false = false + -- not locked, guest, not mod = not false and not true or false = true and false or false = false + -- not locked, not guest, mod = not false and not false or true = true and true and true +%>