diff --git a/doc/javascripts/upload.js b/doc/javascripts/upload.js index 8f6cba2..97ea5e6 100644 --- a/doc/javascripts/upload.js +++ b/doc/javascripts/upload.js @@ -1,24 +1,42 @@ let data; let fileUploaded = false; +// Map the fake upload button to the real (hidden) upload button +document.addEventListener("DOMContentLoaded", function() { + const uploadButton = document.getElementById("uploadButton"); + const fileInput = document.getElementById("fileInput"); + const filePathDisplay = document.getElementById("filePath"); + + uploadButton.addEventListener("click", function() { + fileInput.click(); + }); + + fileInput.addEventListener("change", function() { + const filePath = fileInput.value; // Get the file path from the file input + filePathDisplay.textContent = "Loaded " + filePath; // Display the file path + }); +}); + +// Update fileUploaded flag when a file gets uploaded document.getElementById('fileInput').addEventListener('change', function(event) { const file = event.target.files[0]; const reader = new FileReader(); reader.onload = function(e) { data = e.target.result; - fileUploaded = true; // Set the flag to indicate file upload completion + fileUploaded = true; }; reader.readAsText(file); }); +// Continuously poll to see if the file has been uploaded function runAfterUpload() { if (!fileUploaded) { setTimeout(runAfterUpload, 100); // Check again after 100ms return; } - // Your additional JavaScript code to run after file upload - WebTerminal(data); + // Additional JavaScript code to run after file upload + // WebTerminal(data); } -runAfterUpload(); // Start checking for file upload completion \ No newline at end of file +runAfterUpload(); \ No newline at end of file diff --git a/doc/javascripts/webTerminal.js b/doc/javascripts/webTerminal.js index 17cb7db..84201f0 100644 --- a/doc/javascripts/webTerminal.js +++ b/doc/javascripts/webTerminal.js @@ -1,4 +1,5 @@ document.getElementById('connectButton').addEventListener('click', selectPort); +document.getElementById('runButton').addEventListener('click', webTerminal); async function selectPort(){ await navigator.serial.requestPort(); @@ -19,11 +20,11 @@ serialWorker.onmessage = (e) => { }; // Main function for the Web Terminal -async function WebTerminal(data){ +async function webTerminal(){ let pyodide = await loadPyodide(); // Load Manta.yaml into pyodide's file system - pyodide.FS.writeFile("/manta.yaml", data, { encoding: "utf8" }); + // pyodide.FS.writeFile("/manta.yaml", data, { encoding: "utf8" }); // Load micropip, setuptools, manta await pyodide.loadPackage("micropip"); diff --git a/doc/web_terminal.md b/doc/web_terminal.md index dd6a9eb..161f461 100644 --- a/doc/web_terminal.md +++ b/doc/web_terminal.md @@ -1,5 +1,3 @@ - - ## Open Serial Port @@ -8,29 +6,15 @@
+## Run Main Thread + + - + - - - \ No newline at end of file + \ No newline at end of file