working UGC content upload with multi-upload support

This commit is contained in:
2026-08-03 21:05:12 -05:00
parent 473b3c811b
commit 87b0d46232
18 changed files with 563 additions and 490 deletions
@@ -135,6 +135,29 @@
document.getElementById('tab-' + btn.dataset.tab).classList.add('active');
});
});
// Gallery deletion without a page reload, behind a confirmation dialog.
document.querySelectorAll('.gallery-delete').forEach(link => {
link.addEventListener('click', (e) => {
e.preventDefault();
if (!confirm('Delete this media? This cannot be undone.')) return;
const xhr = new XMLHttpRequest();
xhr.open('POST', link.getAttribute('href'));
xhr.setRequestHeader('X-CSRFToken', getCookie('csrftoken'));
xhr.onload = function () {
if (xhr.status === 200) {
const figure = link.closest('figure.gallery-item');
if (figure) figure.remove();
} else {
alert('Could not delete media.');
}
};
xhr.onerror = function () {
alert('Network error while deleting media.');
};
xhr.send();
});
});
})();
</script>
{% endblock %}