36 lines
1.4 KiB
JavaScript
36 lines
1.4 KiB
JavaScript
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
const fileUploadInput = document.getElementById('fileUpload');
|
|
const printOptionsModal = new bootstrap.Modal(document.getElementById('printOptionsModal'));
|
|
const uploadForm = document.getElementById('uploadForm');
|
|
const fileNameSpan = document.getElementById('fileName');
|
|
const filePreview = document.getElementById('filePreview');
|
|
|
|
fileUploadInput.addEventListener('change', function () {
|
|
if (this.files && this.files[0]) {
|
|
const file = this.files[0];
|
|
fileNameSpan.textContent = file.name;
|
|
|
|
// Simple preview for images
|
|
if (file.type.startsWith('image/')) {
|
|
const reader = new FileReader();
|
|
reader.onload = function (e) {
|
|
filePreview.innerHTML = `<img src="${e.target.result}" class="img-fluid" alt="File preview">`;
|
|
};
|
|
reader.readAsDataURL(file);
|
|
} else {
|
|
// Placeholder for non-image files
|
|
filePreview.innerHTML = '<i class="bi bi-file-earmark-text display-1 text-muted"></i>';
|
|
}
|
|
|
|
printOptionsModal.show();
|
|
}
|
|
});
|
|
|
|
// Optional: If you want the form to submit from the modal button
|
|
// const confirmPrintBtn = document.getElementById('confirmPrintBtn');
|
|
// confirmPrintBtn.addEventListener('click', function () {
|
|
// uploadForm.submit();
|
|
// });
|
|
});
|