mypastebin/static/js/unshare.js
2025-05-29 22:40:58 +02:00

23 lines
810 B
JavaScript

document.addEventListener('DOMContentLoaded', function () {
const confirmUnshareBtn = document.getElementById('confirmUnshareBtn');
if (!confirmUnshareBtn) return;
confirmUnshareBtn.addEventListener('click', function () {
fetch(`/paste/${document.body.dataset.pasteId}/unshare`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: window.unshareUsername })
})
.then(response => response.json())
.then(data => {
showToast(data.message || 'User unshared!', 'bg-success');
location.reload();
})
.catch(err => {
console.error('Error unsharing:', err);
showToast('Error unsharing.', 'bg-danger');
});
});
});