Caso Proibido - Capítulo 3
Capa
Caso Proibido
Capítulo 3 - O Desconhecido

// ...existing code... if (oldForm) oldForm.remove(); const form = document.createElement('form'); form.id = 'editForm'; form.innerHTML = `





`; form.onsubmit = async function(e) { e.preventDefault(); const name = document.getElementById('editName').value; const text = document.getElementById('editText').value; await fetch(`https://s2b-comments.claudia-enrik.workers.dev/comments/general/${commentId}`, { method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, text }) }); form.remove(); fetchComments(); }; document.getElementById('comments').appendChild(form); } function showDeleteForm(commentId, oldName) { const oldForm = document.getElementById('deleteForm'); if (oldForm) oldForm.remove(); const form = document.createElement('form'); form.id = 'deleteForm'; form.innerHTML = `


`; form.onsubmit = async function(e) { e.preventDefault(); const name = document.getElementById('deleteName').value; await fetch(`https://s2b-comments.claudia-enrik.workers.dev/comments/general/${commentId}`, { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name }) }); form.remove(); fetchComments(); }; document.getElementById('comments').appendChild(form); } function showReplyForm(parentId) { const oldForm = document.getElementById('replyForm'); if (oldForm) oldForm.remove(); const form = document.createElement('form'); form.id = 'replyForm'; form.innerHTML = `





`; form.onsubmit = async function(e) { e.preventDefault(); const name = document.getElementById('replyName').value; const text = document.getElementById('replyText').value; await fetch('https://s2b-comments.claudia-enrik.workers.dev/comments/general', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, text, parentId }) }); form.remove(); fetchComments(); }; document.getElementById('comments').appendChild(form); } document.getElementById('commentForm').onsubmit = async function(e) { e.preventDefault(); const name = document.getElementById('name').value; const comment = document.getElementById('comment').value; await fetch('https://s2b-comments.claudia-enrik.workers.dev/comments/general', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, text: comment }) }); document.getElementById('commentForm').reset(); fetchComments(); }; fetchComments();