2024-04-15 02:23:59 +02:00
|
|
|
let data;
|
|
|
|
|
let fileUploaded = false;
|
|
|
|
|
|
2024-04-17 07:50:40 +02:00
|
|
|
// 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
|
2024-04-15 02:23:59 +02:00
|
|
|
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;
|
2024-04-17 07:50:40 +02:00
|
|
|
fileUploaded = true;
|
2024-04-15 02:23:59 +02:00
|
|
|
};
|
|
|
|
|
reader.readAsText(file);
|
|
|
|
|
});
|
|
|
|
|
|
2024-04-17 07:50:40 +02:00
|
|
|
// Continuously poll to see if the file has been uploaded
|
2024-04-15 02:23:59 +02:00
|
|
|
function runAfterUpload() {
|
|
|
|
|
if (!fileUploaded) {
|
|
|
|
|
setTimeout(runAfterUpload, 100); // Check again after 100ms
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-17 07:50:40 +02:00
|
|
|
// Additional JavaScript code to run after file upload
|
|
|
|
|
// WebTerminal(data);
|
2024-04-15 02:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-17 07:50:40 +02:00
|
|
|
runAfterUpload();
|