mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 20:35:19 +03:00
experimental storage of last used port in GUI
This commit is contained in:
parent
fa90fbcbc4
commit
2b4e5642b3
3 changed files with 27 additions and 1 deletions
|
@ -145,6 +145,18 @@ $(document).ready(function() {
|
||||||
text: port
|
text: port
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
chrome.storage.local.get('last_used_port', function(result) {
|
||||||
|
// if last_used_port was set, we try to select it
|
||||||
|
if (typeof result.last_used_port != 'undefined') {
|
||||||
|
// check if same port exists, if it does, select it
|
||||||
|
ports.forEach(function(port) {
|
||||||
|
if (port == result.last_used_port) {
|
||||||
|
$(port_picker).val(result.last_used_port);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$(port_picker).append($("<option/>", {
|
$(port_picker).append($("<option/>", {
|
||||||
value: 0,
|
value: 0,
|
||||||
|
@ -218,6 +230,19 @@ function onOpen(openInfo) {
|
||||||
if (connectionId != -1) {
|
if (connectionId != -1) {
|
||||||
console.log('Connection was opened with ID: ' + connectionId);
|
console.log('Connection was opened with ID: ' + connectionId);
|
||||||
|
|
||||||
|
// save selected port with chrome.storage if the port differs
|
||||||
|
chrome.storage.local.get('last_used_port', function(result) {
|
||||||
|
if (typeof result.last_used_port != 'undefined') {
|
||||||
|
if (result.last_used_port != selected_port) {
|
||||||
|
// last used port doesn't match the one found in local db, we will store the new one
|
||||||
|
chrome.storage.local.set({'last_used_port': selected_port}, function() {
|
||||||
|
// Debug message is currently disabled (we dont need to spam the console log with that)
|
||||||
|
// console.log('Last selected port was saved in chrome.storage.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
connection_delay = setTimeout(function() {
|
connection_delay = setTimeout(function() {
|
||||||
// start polling
|
// start polling
|
||||||
serial_poll = setInterval(readPoll, 10);
|
serial_poll = setInterval(readPoll, 10);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"serial",
|
"serial",
|
||||||
|
"storage",
|
||||||
"fileSystem",
|
"fileSystem",
|
||||||
"fileSystem.write"
|
"fileSystem.write"
|
||||||
],
|
],
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<a class="backup" href="#">Backup</a>
|
<a class="backup" href="#">Backup</a>
|
||||||
<a class="restore" href="#">Restore</a>
|
<a class="restore" href="#">Restore</a>
|
||||||
<p>
|
<p>
|
||||||
<strong>Backup</strong> your configuration in case of an accident.
|
<strong>Backup</strong> your configuration in case of an accident. (<strong>CLI</strong> settings <strong style="color: red;">not</strong> included)
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div id="interactive_block">
|
<div id="interactive_block">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue