defunk some of the option saving code

10.3.x-maintenance
cTn 2014-05-08 14:56:25 +02:00
parent ccee927c77
commit 21a0242d38
1 changed files with 15 additions and 30 deletions

View File

@ -112,17 +112,12 @@ function tab_initialize_firmware_flasher() {
}); });
chrome.storage.local.get('no_reboot_sequence', function(result) { chrome.storage.local.get('no_reboot_sequence', function(result) {
if (typeof result.no_reboot_sequence === 'undefined') {
// wasn't saved yet
$('input.updating').prop('checked', false);
} else {
if (result.no_reboot_sequence) { if (result.no_reboot_sequence) {
$('input.updating').prop('checked', true); $('input.updating').prop('checked', true);
$('label.flash_on_connect_wrapper').show(); $('label.flash_on_connect_wrapper').show();
} else { } else {
$('input.updating').prop('checked', false); $('input.updating').prop('checked', false);
} }
}
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('input.updating').change(function() { $('input.updating').change(function() {
@ -131,8 +126,8 @@ function tab_initialize_firmware_flasher() {
if (status) { if (status) {
$('label.flash_on_connect_wrapper').show(); $('label.flash_on_connect_wrapper').show();
} else { } else {
$('label.flash_on_connect_wrapper').hide();
$('input.flash_on_connect').prop('checked', false).change(); $('input.flash_on_connect').prop('checked', false).change();
$('label.flash_on_connect_wrapper').hide();
} }
chrome.storage.local.set({'no_reboot_sequence': status}); chrome.storage.local.set({'no_reboot_sequence': status});
@ -140,16 +135,11 @@ function tab_initialize_firmware_flasher() {
}); });
chrome.storage.local.get('flash_on_connect', function(result) { chrome.storage.local.get('flash_on_connect', function(result) {
if (typeof result.flash_on_connect === 'undefined') {
// wasn't saved yet
$('input.flash_on_connect').prop('checked', false);
} else {
if (result.flash_on_connect) { if (result.flash_on_connect) {
$('input.flash_on_connect').prop('checked', true); $('input.flash_on_connect').prop('checked', true);
} else { } else {
$('input.flash_on_connect').prop('checked', false); $('input.flash_on_connect').prop('checked', false);
} }
}
$('input.flash_on_connect').change(function() { $('input.flash_on_connect').change(function() {
var status = $(this).is(':checked'); var status = $(this).is(':checked');
@ -157,7 +147,7 @@ function tab_initialize_firmware_flasher() {
if (status) { if (status) {
var flashing_port; var flashing_port;
var start = function() { function start() {
PortHandler.port_detected('flash_next_device', function(result) { PortHandler.port_detected('flash_next_device', function(result) {
flashing_port = result[0]; flashing_port = result[0];
GUI.log('Detected: <strong>' + flashing_port + '</strong> - triggering flash on connect'); GUI.log('Detected: <strong>' + flashing_port + '</strong> - triggering flash on connect');
@ -169,9 +159,9 @@ function tab_initialize_firmware_flasher() {
// Detect port removal to create a new callback // Detect port removal to create a new callback
end(); end();
}, false, true); }, false, true);
}; }
var end = function() { function end() {
PortHandler.port_removed('flashed_device_removed', function(result) { PortHandler.port_removed('flashed_device_removed', function(result) {
for (var i = 0; i < result.length; i++) { for (var i = 0; i < result.length; i++) {
if (result[i] == flashing_port) { if (result[i] == flashing_port) {
@ -189,7 +179,7 @@ function tab_initialize_firmware_flasher() {
// different device removed, we need to retry // different device removed, we need to retry
end(); end();
}, false, true); }, false, true);
}; }
start(); start();
} else { } else {
@ -201,16 +191,11 @@ function tab_initialize_firmware_flasher() {
}); });
chrome.storage.local.get('erase_chip', function(result) { chrome.storage.local.get('erase_chip', function(result) {
if (typeof result.erase_chip === 'undefined') {
// wasn't saved yet
$('input.updating').prop('checked', false);
} else {
if (result.erase_chip) { if (result.erase_chip) {
$('input.erase_chip').prop('checked', true); $('input.erase_chip').prop('checked', true);
} else { } else {
$('input.erase_chip').prop('checked', false); $('input.erase_chip').prop('checked', false);
} }
}
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('input.erase_chip').change(function() { $('input.erase_chip').change(function() {