Work on NMEA2000 device list
This commit is contained in:
27
web/index.js
27
web/index.js
@@ -973,6 +973,14 @@
|
||||
})
|
||||
.catch(function (err) { alert("unable to load config: " + err) })
|
||||
}
|
||||
function loadDeviceList() {
|
||||
getJson("api/devices")
|
||||
.then(function(devices) {
|
||||
let deviceForm = document.getElementById('devicePage');
|
||||
console.log("Device form called");
|
||||
})
|
||||
.catch(function (err) { alert("unable to load devicelist: " + err) })
|
||||
}
|
||||
// New hash function by SubtleCrypto Browser API
|
||||
async function hashString(str) {
|
||||
const enc = new TextEncoder();
|
||||
@@ -1089,6 +1097,9 @@
|
||||
showOverlay(text, true);
|
||||
});
|
||||
}
|
||||
buttonHandlers.reloadDevices=function() {
|
||||
console.log("Button reload devices");
|
||||
}
|
||||
function handleTab(el) {
|
||||
let activeName = el.getAttribute('data-page');
|
||||
if (!activeName) {
|
||||
@@ -1394,7 +1405,23 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
// calculate MD5 hash of firmware to upload
|
||||
let md5hash;
|
||||
const fwreader = new FileReader();
|
||||
fwreader.addEventListener('load', function (e) {
|
||||
const content = new Uint8Array(e.target.result);
|
||||
let binary = "";
|
||||
const chunkSize = 0x8000;
|
||||
for (let i = 0; i < content.length; i += chunkSize) {
|
||||
binary += String.fromCharCode.apply(null, content.subarray(i, i + chunkSize));
|
||||
}
|
||||
md5hash = MD5(binary).toLowerCase();
|
||||
});
|
||||
fwreader.readAsArrayBuffer(file);
|
||||
console.log("MD5:", md5hash);
|
||||
|
||||
let formData = new FormData();
|
||||
formData.append("md5", md5hash)
|
||||
formData.append("file1", el.files[0]);
|
||||
req.open("POST", apiPrefix + '/api/update?_hash=' + encodeURIComponent(hash));
|
||||
req.send(formData);
|
||||
|
||||
Reference in New Issue
Block a user