feat: enhance upload handling and logging improvements

This commit is contained in:
2026-01-16 15:17:57 +01:00
parent e0d1f263dd
commit c7c5c5f135
4 changed files with 21 additions and 7 deletions

View File

@@ -62,6 +62,7 @@
<script>
let currentContentData = null;
let uploadCompleted = false;
const fileInput = document.getElementById("fileInput");
const uploadZone = document.getElementById("uploadZone");
const uploadContainer = document.querySelector(".upload-container");
@@ -165,6 +166,9 @@
return;
}
// Mark upload as completed to prevent further pastes
uploadCompleted = true;
// Hide duration controls and buttons
document.querySelector('label[for="durationSlider"]').style.display =
"none";
@@ -220,6 +224,7 @@
// Reset to initial state
resetBtn.addEventListener("click", function () {
currentContentData = null;
uploadCompleted = false;
uploadZone.innerHTML =
"<p>Click to select file, paste image data, or drag & drop</p>";
uploadContainer.style.height = "180px";
@@ -302,6 +307,7 @@
// Open file picker on container click (ONLY IF EMPTY)
uploadContainer.addEventListener("click", function (e) {
if (
!uploadCompleted &&
uploadContainer.style.pointerEvents !== "none" &&
!uploadZone.querySelector(".text-content") &&
!uploadZone.querySelector("img")
@@ -311,6 +317,7 @@
});
fileInput.addEventListener("change", function (e) {
if (uploadCompleted) return;
const file = e.target.files[0];
if (file) {
const reader = new FileReader();
@@ -323,6 +330,10 @@
// Handle paste from clipboard
uploadZone.addEventListener("paste", function (e) {
if (uploadCompleted) {
e.preventDefault();
return;
}
e.preventDefault();
const items = e.clipboardData.items;
@@ -350,6 +361,7 @@
function handleDrop(e) {
e.preventDefault();
if (uploadCompleted) return;
const file = e.dataTransfer.files[0];
if (file && file.type.startsWith("image/")) {
const reader = new FileReader();
@@ -436,4 +448,4 @@
</script>
</body>
</html>
</html>