Skip to content

Commit

Permalink
fix file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexLynd committed Nov 28, 2023
1 parent d9e1810 commit f610770
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 45 deletions.
42 changes: 16 additions & 26 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ <h1>DevKitty Web Flasher</h1>

<div style="display: inline-block" class="ms-3">
<span class="form-check form-switch" style="display: inline-block">
<input class="form-check-input" type="checkbox" role="switch" id="flexSwitchCheckChecked" checked>
<input class="form-check-input" type="checkbox" role="switch" id="autoscroll" checked>
<label class="form-check-label" for="flexSwitchCheckChecked">Autoscroll</label>
</span>
</div>
Expand All @@ -128,7 +128,7 @@ <h1>DevKitty Web Flasher</h1>


<div class="row">
<div class="col-md-12 col-lg-6 order-lg-2 px-3">
<div class="col-md-12 col-lg-6 order-lg-2 p-3">
<!-- Right Column -->

<div class="mb-5">
Expand Down Expand Up @@ -166,29 +166,18 @@ <h2>3. Flash </h2>
<kbd>v1.0</kbd> <a href="test">GitHub Link</a> -->

<div id="app" class="mb-3">
<div class="progress-bar hidden"><div></div></div>

<div id="commands">
<div class="upload">
<label
>Offset: 0x
<input class="offset" type="text" value="0" />
</label>
<label class="firmware">
<input type="file" accept=".bin" />
<svg
xmlns="http://www.w3.org/2000/svg"
width="20"
height="17"
viewbox="0 0 20 17"
>
<path
d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"
/>
</svg>
<span>Choose a file&hellip;</span>
</label>
<div class="progress-bar hidden"><div></div></div>
<label>Offset: 0x <input class="offset" type="text" value="0" /></label>
<div>
<label class="form-label"></label>
<input class="form-control" type="file" accept=".bin" />
</div>
<div class="upload">
</div>

<!-- <div class="upload">
<label
>Offset: 0x
<input class="offset" type="text" value="0" />
Expand All @@ -209,6 +198,7 @@ <h2>3. Flash </h2>
</label>
<div class="progress-bar hidden"><div></div></div>
</div>
<div class="upload">
<label
>Offset: 0x
Expand Down Expand Up @@ -250,7 +240,7 @@ <h2>3. Flash </h2>
<span>Choose a file&hellip;</span>
</label>
<div class="progress-bar hidden"><div></div></div>
</div>
</div> -->

</div>
</div>
Expand All @@ -266,7 +256,7 @@ <h2>3. Flash </h2>

</div>
</div>
<div class="col-md-12 col-lg-6 order-lg-1 px-3">
<div class="col-md-12 col-lg-6 order-lg-1 p-3">
<!-- Left Column -->
<div>
<div id="log">
Expand All @@ -285,7 +275,7 @@ <h2>3. Flash </h2>
</div>
</div>

<span style="display:inline-block">
<!-- <span style="display:inline-block">
<label for="autoscroll">Autoscroll </label>
<span class="onoffswitch">
<input
Expand All @@ -299,7 +289,7 @@ <h2>3. Flash </h2>
<span class="onoffswitch-switch"></span>
</label>
</span>
</span>
</span> -->

<div class="container-fluid">
<div class="my-5" style="text-align: center;">
Expand Down
38 changes: 19 additions & 19 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,10 @@ async function clickProgram() {
baudRate.disabled = true;
butErase.disabled = true;
butProgram.disabled = true;
for (let i = 0; i < 4; i++) {
firmware[i].disabled = true;
offsets[i].disabled = true;
}
// for (let i = 0; i < 4; i++) {
firmware[0].disabled = true;
offsets[0].disabled = true;
// }
for (let file of getValidFiles()) {
progress[file].classList.remove("hidden");
let binfile = firmware[file].files[0];
Expand All @@ -285,12 +285,12 @@ async function clickProgram() {
errorMsg(e);
}
}
for (let i = 0; i < 4; i++) {
firmware[i].disabled = false;
offsets[i].disabled = false;
progress[i].classList.add("hidden");
progress[i].querySelector("div").style.width = "0";
}
// for (let i = 0; i < 4; i++) {
firmware[0].disabled = false;
offsets[0].disabled = false;
progress[0].classList.add("hidden");
progress[0].querySelector("div").style.width = "0";
// }
butErase.disabled = false;
baudRate.disabled = false;
butProgram.disabled = getValidFiles().length == 0;
Expand All @@ -303,13 +303,13 @@ function getValidFiles() {
// and will also return a list of files to program
let validFiles = [];
let offsetVals = [];
for (let i = 0; i < 4; i++) {
let offs = parseInt(offsets[i].value, 16);
if (firmware[i].files.length > 0 && !offsetVals.includes(offs)) {
validFiles.push(i);
// for (let i = 0; i < 4; i++) {
let offs = parseInt(offsets[0].value, 16);
if (firmware[0].files.length > 0 && !offsetVals.includes(offs)) {
validFiles.push(0);
offsetVals.push(offs);
}
}
// }
return validFiles;
}

Expand Down Expand Up @@ -363,10 +363,10 @@ function convertJSON(chunk) {

function toggleUIToolbar(show) {
isConnected = show;
for (let i = 0; i < 4; i++) {
progress[i].classList.add("hidden");
progress[i].querySelector("div").style.width = "0";
}
// for (let i = 0; i < 4; i++) {
progress[0].classList.add("hidden");
progress[0].querySelector("div").style.width = "0";
// }
if (show) {
appDiv.classList.add("connected");
} else {
Expand Down

0 comments on commit f610770

Please sign in to comment.