aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/assets
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-27 22:56:43 +0300
committerGravatar Vitaly Takmazov2018-09-27 22:56:43 +0300
commit563966d66e812829779ff7184ff9b5d372e4b3aa (patch)
tree464d6eb600fa1af51631a5557d369a1a3b5665d7 /juick-server/src/main/assets
parented9f1256cf2bfd93b749b6e2ef22114d7fcd89bc (diff)
scripts: pm over api
Diffstat (limited to 'juick-server/src/main/assets')
-rw-r--r--juick-server/src/main/assets/scripts.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js
index 5a5fad6b..2f86ea69 100644
--- a/juick-server/src/main/assets/scripts.js
+++ b/juick-server/src/main/assets/scripts.js
@@ -701,6 +701,32 @@ ready(function () {
});
});
}
+ var pmmsg = document.getElementById('pmmsg');
+ if (pmmsg) {
+ pmmsg.addEventListener('submit', e => {
+ e.preventDefault();
+ let formData = new FormData(pmmsg);
+ fetch('/api/pm' + '?hash=' + document.getElementById('body').getAttribute('data-hash'), {
+ method: 'POST',
+ body: formData,
+ credentials: 'omit'
+ }).then(response => {
+ if (response.ok) {
+ response.json().then(result => {
+ if (result.to) {
+ window.location = new URL('/pm/sent', window.location.href);
+ } else {
+ alert('Something went wrong :(');
+ }
+ });
+ } else {
+ alert('Something went wrong :(');
+ }
+ }).catch(error => {
+ alert(error.message);
+ });
+ });
+ }
document.querySelectorAll('.msg-menu').forEach(function (el) {
el.addEventListener('click', function (e) {