Update main.js

This commit is contained in:
Elijah Bansley 2018-05-17 08:40:52 -05:00 committed by GitHub
parent d2167a4e34
commit 05dc78255f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

20
main.js
View File

@ -109,13 +109,21 @@ document.getElementById("goButton").addEventListener("click", async () => {
var debugCheckbox = document.getElementById("shouldDebug"); var debugCheckbox = document.getElementById("shouldDebug");
const payloadType = document.forms.mainForm.payload.value; const payloadType = document.forms.mainForm.payload.value;
if(debugCheckbox.checked) { if(debugCheckbox.checked) {
if (payloadType === "uploaded") { let payload;
const file = document.getElementById("payloadUpload").files[0]; if (payloadType === "fusee.bin") {
file = new Uint8Array(await readFileAsArrayBuffer(file)); payload = fusee;
} else if (payloadType === "fusee.bin") { } else if (payloadType === "uploaded") {
const file = fusee; 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..."); logOutput("Requesting access to device...");
device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x0955 }] }); device = await navigator.usb.requestDevice({ filters: [{ vendorId: 0x0955 }] });