source ⟩ hypertext ⟩ public ⟩ cosmetics ⟩ comments.js
function prepend(postId) {
$("#comments-form-comment").value += `@${postId}`;
}
function loadComments() {
$$(".comment-section").forEach(section => {
const form = section.$(".comments-form");
form.onsubmit = event => {
event.preventDefault();
fetch(form.action, {
method: "POST",
body: new URLSearchParams(new FormData(form))
})
.then(response => response.text())
.then(data => {
form.outerHTML = data;
});
};
});
}
window.on("DOMContentLoaded", loadComments);