diff options
author | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-04-17 16:01:28 +0300 |
commit | 106c53cce6725591337773d412c0fb74eaf81ed8 (patch) | |
tree | fe07a0136c63787d6e5f53349af16541faebaf89 /src/main/assets/scripts.js | |
parent | cf3a5d8c979b114fceef43b35541b941bcbd62a1 (diff) |
Add/remove from whitelist on web
Diffstat (limited to 'src/main/assets/scripts.js')
-rw-r--r-- | src/main/assets/scripts.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/assets/scripts.js b/src/main/assets/scripts.js index 6c5e987b..4422fdb3 100644 --- a/src/main/assets/scripts.js +++ b/src/main/assets/scripts.js @@ -492,6 +492,23 @@ function setPrivacy(e, mid) { .catch(console.err); return false; } +function toggleWL(e, name) { + fetch('/api/users/wl?name=' + name + + '&hash=' + document.getElementById('body').getAttribute('data-hash'), { + credentials: 'same-origin', + method: 'POST' + }) + .then(handleErrors) + .then(function(response) { + if (response.ok) { + window.location.reload(); + } else { + alert('Something went wrong :('); + } + }) + .catch(console.err); + return false; +} function getTags() { fetch('/api/tags?hash=' + document.getElementById('body').getAttribute('data-hash'), { @@ -714,6 +731,14 @@ ready(() => { e.preventDefault(); }); }); + Array.from(document.querySelectorAll('.a-vip')).forEach(function(e) { + e.addEventListener('click', function(e) { + toggleWL( + e.target, + e.target.closest('[data-name]').getAttribute('data-name')); + e.preventDefault(); + }); + }); Array.from(document.querySelectorAll('.ir a[data-fname], .msg-media a[data-fname]')).forEach(function(el) { el.addEventListener('click', function(e) { let fname = /** @type {HTMLElement} */ (e.target).closest('[data-fname]').getAttribute('data-fname'); |