diff options
Diffstat (limited to 'juick-server')
-rw-r--r-- | juick-server/src/main/assets/scripts.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js index 5bbbe6f26..5a5fad6b5 100644 --- a/juick-server/src/main/assets/scripts.js +++ b/juick-server/src/main/assets/scripts.js @@ -677,6 +677,29 @@ ready(function () { } }); }); + postmsg.addEventListener('submit', e => { + e.preventDefault(); + let formData = new FormData(postmsg); + fetch('/api/post' + '?hash=' + document.getElementById('body').getAttribute('data-hash'), { + method: 'POST', + body: formData, + credentials: 'omit' + }).then(response => { + if (response.ok) { + response.json().then(result => { + if (result.newMessage) { + window.location = new URL(`/m/${result.newMessage.mid}`, window.location.href); + } else { + alert(result.text); + } + }); + } else { + alert('Something went wrong :('); + } + }).catch(error => { + alert(error.message); + }); + }); } document.querySelectorAll('.msg-menu').forEach(function (el) { |