mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-19 14:25:13 +03:00
Fix local firmware loader after NW version increase
This commit is contained in:
parent
4fcef09216
commit
05af37a8af
1 changed files with 24 additions and 39 deletions
|
@ -1,3 +1,4 @@
|
|||
/*global $,nwdialog*/
|
||||
'use strict';
|
||||
|
||||
TABS.firmware_flasher = {};
|
||||
|
@ -184,39 +185,26 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
$('select[name="release"]').empty().append('<option value="0">Offline</option>');
|
||||
});
|
||||
|
||||
// UI Hooks
|
||||
$('a.load_file').click(function () {
|
||||
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(chrome.runtime.lastError.message);
|
||||
$('a.load_file').on('click', function () {
|
||||
|
||||
nwdialog.setContext(document);
|
||||
nwdialog.openFileDialog('.hex', function(filename) {
|
||||
const fs = require('fs');
|
||||
|
||||
$('div.git_info').slideUp();
|
||||
|
||||
console.log('Loading file from: ' + filename);
|
||||
|
||||
fs.readFile(filename, (err, data) => {
|
||||
|
||||
if (err) {
|
||||
console.log("Error loading local file", err);
|
||||
return;
|
||||
}
|
||||
|
||||
// hide github info (if it exists)
|
||||
$('div.git_info').slideUp();
|
||||
|
||||
chrome.fileSystem.getDisplayPath(fileEntry, function (path) {
|
||||
console.log('Loading file from: ' + path);
|
||||
|
||||
fileEntry.file(function (file) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onprogress = function (e) {
|
||||
if (e.total > 104857600) { // 100 MB
|
||||
// dont allow reading files bigger then 100 MB
|
||||
console.log('File limit (100 MB) exceeded, aborting');
|
||||
reader.abort();
|
||||
}
|
||||
};
|
||||
|
||||
reader.onloadend = function(e) {
|
||||
if (e.total != 0 && e.total == e.loaded) {
|
||||
console.log('File loaded');
|
||||
|
||||
intel_hex = e.target.result;
|
||||
|
||||
parse_hex(intel_hex, function (data) {
|
||||
parse_hex(data.toString(), function (data) {
|
||||
parsed_hex = data;
|
||||
|
||||
if (parsed_hex) {
|
||||
|
@ -228,13 +216,10 @@ TABS.firmware_flasher.initialize = function (callback) {
|
|||
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
reader.readAsText(file);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue