This commit is contained in:
pika 2025-03-24 14:53:25 +01:00
parent 16e8490b30
commit 34afc48816

View file

@ -472,7 +472,7 @@ document.addEventListener('DOMContentLoaded', function () {
}
// File upload functionality
const uploadButton = document.getElementById('upload-button');
const uploadButton = document.getElementById('select-files-btn');
const uploadModal = document.querySelector('.upload-modal');
// Hide upload modal by default if it exists
@ -482,29 +482,32 @@ document.addEventListener('DOMContentLoaded', function () {
uploadModal.style.visibility = 'hidden';
}
// Setup upload button
// Setup upload button with proper existence checks
if (uploadButton && fileInput) {
uploadButton.addEventListener('click', function () {
uploadButton.addEventListener('click', function (e) {
e.preventDefault(); // Prevent default button behavior
fileInput.click();
});
fileInput.addEventListener('change', function () {
if (this.files.length > 0) {
if (this.files && this.files.length > 0) {
// Handle file upload
handleFileUpload(this.files);
}
});
}
// Close upload modal when close button is clicked
// Close upload modal when close button is clicked - with existence check
const closeButtons = document.querySelectorAll('.upload-modal .close-btn, .upload-modal .modal-close');
closeButtons.forEach(btn => {
btn.addEventListener('click', function () {
if (uploadModal) {
uploadModal.classList.remove('active');
}
if (closeButtons.length > 0) {
closeButtons.forEach(btn => {
btn.addEventListener('click', function () {
if (uploadModal) {
uploadModal.classList.remove('active');
}
});
});
});
}
// Handle file upload process
function handleFileUpload(files) {