From 05dc78255f26af9227dc2219e60c6c565d69e9ba Mon Sep 17 00:00:00 2001 From: Elijah Bansley Date: Thu, 17 May 2018 08:40:52 -0500 Subject: [PATCH] Update main.js --- main.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/main.js b/main.js index 36827f8..1a470b3 100644 --- a/main.js +++ b/main.js @@ -109,13 +109,21 @@ document.getElementById("goButton").addEventListener("click", async () => { var debugCheckbox = document.getElementById("shouldDebug"); const payloadType = document.forms.mainForm.payload.value; if(debugCheckbox.checked) { - if (payloadType === "uploaded") { - const file = document.getElementById("payloadUpload").files[0]; - file = new Uint8Array(await readFileAsArrayBuffer(file)); - } else if (payloadType === "fusee.bin") { - const file = fusee; + let payload; + if (payloadType === "fusee.bin") { + payload = fusee; + } else if (payloadType === "uploaded") { + const file = document.getElementById("payloadUpload").files[0]; + if (!file) { + alert("You need to upload a file, to use an uploaded file."); + return; } - logOutput(readFileAsArrayBuffer(file)); + payload = new Uint8Array(await readFileAsArrayBuffer(file)); + } else { + logOutput("You're trying to load a payload type that doesn't exist."); + return; + } + logOutput(payload); } logOutput("Requesting access to device..."); device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x0955 }] });