aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/assets
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-25 15:48:11 +0300
committerGravatar Vitaly Takmazov2018-09-25 15:48:11 +0300
commitf3acdb00caaef60bd5ddfa128699f8a255261543 (patch)
tree3fdad6be0f520686317ad8ac4183a0ae751e4d8d /juick-server/src/main/assets
parentf30602aae3a581b9c9d1940c8cba99c35cebd31f (diff)
scripts: comments over api
Diffstat (limited to 'juick-server/src/main/assets')
-rw-r--r--juick-server/src/main/assets/scripts.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js
index 289ccb43..19383e94 100644
--- a/juick-server/src/main/assets/scripts.js
+++ b/juick-server/src/main/assets/scripts.js
@@ -342,6 +342,22 @@ function showCommentForm(mid, rid) {
return false;
}
submitButton.disabled = true;
+ e.preventDefault();
+ let formData = new FormData(form);
+ fetch('/api/comment' + '?hash=' + document.getElementById('body').getAttribute('data-hash'), {
+ method: 'POST',
+ body: formData,
+ credentials: 'omit'
+ }).then(response => {
+ if (response.ok) {
+ return response.json();
+ }
+ }).then(reply => {
+ window.location.href = new URL(`${mid}#${reply.rid}`, window.location.href);
+ window.location.reload(true);
+ }).catch(error => {
+ alert(error.message);
+ })
});
}
reply.querySelector('.msg-comment textarea').focus();