const addInputButton = document.getElementById("add-input-button"); const schematicInputSectionTemplate = document.getElementById("schematic-input-section").cloneNode(true); const schematicInputSectionContainer = document.getElementById("schematic-input-section").parentElement; addInputButton.onclick = () => { const newSection = schematicInputSectionTemplate.cloneNode(true); schematicInputSectionContainer.appendChild(newSection); }; const resultContainer = document.getElementById("result-container"); const form = document.getElementById("schematic-form"); form.onsubmit = async (e) => { e.preventDefault(); resultContainer.innerHTML = "
Uploading and extracting contents...
"; const data = new FormData(form); const processingTerminal = data.get("processing-terminal"); try { const response = await fetch("/extracts", { method: "POST", body: data }); if (response.status === 200) { const result = await response.json(); const extractId = result.extractId; const url = window.location.origin + "/extracts/" + extractId; resultContainer.innerHTML = `Copy this URL, and provide it to your computer extraction terminal: ${url}
`; form.reset(); } else { const message = await response.text(); resultContainer.innerHTML = `Submission failed: ${message}
`; } } catch (error) { console.error("Error: " + error); resultContainer.innerHTML = `An error occurred: ${error}
`; } };