}
}
+function prefixSubject(input, reason) {
+ let subject = input.value;
+
+ if (!reason) {
+ return subject;
+ }
+
+ const prefix = `[${reason}]`;
+ if (subject.toLowerCase().includes(prefix.toLowerCase())) {
+ return subject;
+ }
+
+ subject = `${prefix} ${subject}`;
+ const maxLen = input.getAttribute("maxlength") ?? subject.length;
+ return subject.slice(0, maxLen);
+}
+
async function remove_post_handler(event) {
const post = event.currentTarget.closest('.post');
const usernameElem = post.querySelector(".author .username,.author .username-coloured");
}
const post_id = post.id.slice(1);
- const thread_title = (() => {
- const prefix = `[${reason}]`;
- let title = formData.get("subject");
- if (reason && !title.toLowerCase().includes(prefix.toLowerCase())) {
- title = `${prefix} ${title}`;
- }
- return title.slice(0, form.elements["subject"].maxLength);
- })();
formData.set("post_id_list[]", post_id);
- formData.set("subject", thread_title);
+ formData.set("subject", prefixSubject(form.elements["subject"], reason));
formData.set("to_forum_id", ARCHIVFORUMID);
try {