diff --git a/demo/soudan.js b/demo/soudan.js index a58f7a0..90d5652 100644 --- a/demo/soudan.js +++ b/demo/soudan.js @@ -12,7 +12,9 @@ function commentForm(parent) { function commentDisplay(comment, replies) { return `
${typeof replies === "string" ? `` : ""}${comment.author ? comment.author : "Anonymous"} commented ${moment(new Date(comment.timestamp * 1000)).fromNow()}:
${md.render(comment.text)}
${typeof replies === "string" ? `
${replies ? replies : ""}
` : ""}
`; } -document.getElementById("soudan").innerHTML = `

Make a comment

+const container = document.getElementById("soudan"); +container.style.display = "none"; +container.innerHTML = `

Make a comment

${commentForm()}

Comments

`; @@ -41,11 +43,12 @@ function submitForm(form, e) { }) .then(response => { if (!response.ok) { - return; + Promsise.reject(); } form.querySelector("textarea").value = ""; reloadComments(); }) + .catch(error => alert("Something went wrong posting your comment!")) e.preventDefault(); } @@ -81,6 +84,7 @@ function reloadComments(jump) { }); } commentContainer.innerHTML = html; + soudan.style.display = ""; if (jump && window.location.hash) { const target = document.getElementById(window.location.hash.substring(1)); if (target) { @@ -88,7 +92,7 @@ function reloadComments(jump) { target.classList.add("soudan-highlighted"); } } - }); + }) } function reply(id) {