Add validations and alert message div
This commit is contained in:
parent
47b8c219ff
commit
e822fb7c3d
@ -14,6 +14,7 @@
|
||||
<script src="node_modules/xterm/lib/xterm.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.0.3/pako.js"></script>
|
||||
<script src="node_modules/crypto-js/crypto-js.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
@ -36,6 +37,12 @@
|
||||
<input class="btn btn-warning btn-sm" type="button" id="disconnectButton" value="Disconnect" />
|
||||
<input class="btn btn-danger btn-sm" type="button" id="eraseButton" value="Erase Flash" />
|
||||
<br><br>
|
||||
|
||||
<div class="alert alert-danger alert-dismissible" id="alertDiv" style="display:none">
|
||||
<a href="#" class="close" aria-label="close" onclick="$('.alert').hide()">×</a>
|
||||
<span id="alertmsg"></span>
|
||||
</div>
|
||||
|
||||
<div id="files">
|
||||
<table class="table table-striped" id="fileTable">
|
||||
<thead class="thead-light">
|
||||
|
16
index.js
16
index.js
@ -14,6 +14,7 @@ const lblBaudrate = document.getElementById("lblBaudrate");
|
||||
const lblConnTo = document.getElementById("lblConnTo");
|
||||
const tableBody = document.getElementById("tableBody");
|
||||
const table = document.getElementById('fileTable');
|
||||
const alertDiv = document.getElementById('alertDiv');
|
||||
|
||||
//import { Transport } from './cp210x-webusb.js'
|
||||
import { Transport } from './webserial.js'
|
||||
@ -54,18 +55,16 @@ function convertBinaryStringToUint8Array(bStr) {
|
||||
|
||||
function handleFileSelect(evt) {
|
||||
var file = evt.target.files[0];
|
||||
console.log(file);
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = (function(theFile) {
|
||||
return function(e) {
|
||||
file1 = e.target.result;
|
||||
|
||||
evt.target.data = file1;
|
||||
};
|
||||
})(file);
|
||||
|
||||
reader.readAsBinaryString(file);
|
||||
evt.target.data = file1;
|
||||
}
|
||||
|
||||
|
||||
@ -185,6 +184,7 @@ disconnectButton.onclick = async () => {
|
||||
eraseButton.style.display = "none";
|
||||
lblConnTo.style.display = "none";
|
||||
filesDiv.style.display = "none";
|
||||
alertDiv.style.display = "none";
|
||||
consoleDiv.style.display = "initial";
|
||||
};
|
||||
|
||||
@ -256,8 +256,12 @@ function validate_program_inputs() {
|
||||
|
||||
programButton.onclick = async () => {
|
||||
var err = validate_program_inputs();
|
||||
if (err != "success")
|
||||
alert(err);
|
||||
if (err != "success") {
|
||||
const alertMsg = document.getElementById("alertmsg");
|
||||
alertMsg.innerHTML = "<strong>" + err + "</strong>";
|
||||
alertDiv.style.display = "block";
|
||||
return;
|
||||
}
|
||||
|
||||
let fileArr = [];
|
||||
let offset = 0x1000;
|
||||
@ -272,6 +276,6 @@ programButton.onclick = async () => {
|
||||
|
||||
fileArr.push({data:fileObj.data, address:offset});
|
||||
}
|
||||
esploader.write_flash({fileArray: fileArr, flash_size: 'keep'});
|
||||
|
||||
await esploader.write_flash({fileArray: fileArr, flash_size: 'keep'});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user