diff options
Diffstat (limited to 'juick-server/src/main/assets')
-rw-r--r-- | juick-server/src/main/assets/scripts.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/juick-server/src/main/assets/scripts.js b/juick-server/src/main/assets/scripts.js index 21e3fdee..1c090256 100644 --- a/juick-server/src/main/assets/scripts.js +++ b/juick-server/src/main/assets/scripts.js @@ -562,6 +562,26 @@ function likeMessage(e, mid) { return false; } +function subscribeMessage(e, mid) { + fetch('/api/subscribe?mid=' + mid + + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { + method: 'POST', + mode: 'cors', + credentials: 'omit' + }) + .then(function (response) { + if (response.ok) { + window.location.reload(true); + } else { + alert('Something went wrong :('); + } + }) + .catch(error => { + alert(error.message); + }); + return false; +} + /******************************************************************************/ function setPopular(e, mid, popular) { @@ -774,6 +794,14 @@ ready(function () { e.preventDefault(); }); }); + document.querySelectorAll('.l .a-sub').forEach(function (e) { + e.addEventListener('click', function (e) { + subscribeMessage( + e.target, + e.target.closest('article').getAttribute('data-mid')); + e.preventDefault(); + }); + }); document.querySelectorAll('.a-login').forEach(function (el) { el.addEventListener('click', function (e) { openDialogLogin(); |