From 89bcd89cb3b6361288cea19fa8e3cae40477351d Mon Sep 17 00:00:00 2001 From: celestora Date: Sun, 16 Jan 2022 13:50:52 +0200 Subject: [PATCH] Improve "Reply..." button Now it can be used after textarea initialization (fixes #391) and is capable of replacing pervious mention (if it is located at the start of le string, otherwise it prepends mention) --- Web/static/js/al_comments.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Web/static/js/al_comments.js b/Web/static/js/al_comments.js index 21acd797..6f36730b 100644 --- a/Web/static/js/al_comments.js +++ b/Web/static/js/al_comments.js @@ -5,7 +5,9 @@ u(".comment-reply").on("click", function(e) { let fromGroup = Boolean(comment.data("from-group")); let postId = comment.data("post-id"); let inputbox = postId == null ? u("#write textarea") : u("#wall-post-input" + (postId || "")); + let mention = ("[" + (fromGroup ? "club" : "id") + authorId + "|" + authorNm + "], "); - inputbox.text("[" + (fromGroup ? "club" : "id") + authorId + "|" + authorNm + "], "); + // Substitute pervious mention if present, prepend otherwise + inputbox.nodes[0].value = s.nodes[0].value.replace(/(^\[([A-Za-z0-9]+)\|([\p{L} 0-9@]+)\], |^)/u, mention); inputbox.trigger("focusin"); });