web-hp-eprint-clone/web/assets/index.js
matu6968 dceb67b0aa 0
add new quality and page index selector setting
2024-11-01 19:45:12 +01:00

30 lines
871 B
JavaScript

const uploadForm = document.getElementById('uploadForm');
const uploadStatus = document.getElementById('uploadStatus');
const commandOutput = document.getElementById('commandOutput');
uploadForm.addEventListener('submit', async (e) => {
e.preventDefault();
uploadStatus.textContent = 'Uploading...';
commandOutput.textContent = '';
const formData = new FormData(uploadForm);
try {
const response = await fetch('/upload', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.error) {
throw new Error(result.error);
} else {
uploadStatus.textContent = result.message;
commandOutput.textContent = result.output;
}
} catch (error) {
uploadStatus.textContent = `Error: ${error.message}`;
}
});