Fix for firmware flasher checkboxes not restoring saved state issue #274.

10.3.x-maintenance
Kristjan Vaga 2015-11-17 00:53:40 +02:00
parent 4e8fc955b0
commit 168b412089
2 changed files with 52 additions and 47 deletions

View File

@ -24,14 +24,14 @@ var GUI_control = function () {
'configuration',
'gps',
'led_strip',
'logging',
'logging',
'dataflash',
'modes',
'motors',
'pid_tuning',
'ports',
'receiver',
'sensors',
'sensors',
'servos',
'setup'
];
@ -238,39 +238,42 @@ GUI_control.prototype.tab_switch_cleanup = function (callback) {
};
GUI_control.prototype.content_ready = function (callback) {
$('.togglesmall').each(function(index, html) {
var switchery = new Switchery(html,
{
$('.togglesmall').each(function(index, elem) {
var switchery = new Switchery(elem, {
size: 'small',
color: '#59aa29',
secondaryColor: '#c4c4c4'
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('togglesmall');
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('togglesmall');
});
$('.toggle').each(function(index, html) {
var switchery = new Switchery(html,
{
color: '#59aa29',
secondaryColor: '#c4c4c4'
$('.toggle').each(function(index, elem) {
var switchery = new Switchery(elem, {
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('toggle');
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('toggle');
});
$('.togglemedium').each(function(index, html) {
var switchery = new Switchery(html,
{
$('.togglemedium').each(function(index, elem) {
var switchery = new Switchery(elem, {
className: 'switcherymid',
color: '#59aa29',
secondaryColor: '#c4c4c4'
color: '#59aa29',
secondaryColor: '#c4c4c4'
});
$(html).removeClass('togglemedium');
$(elem).on("change", function (evt) {
switchery.setPosition();
});
$(elem).removeClass('togglemedium');
});
// Build link to in-use CF version documentation
var documentationButton = $('div#content #button-documentation');
documentationButton.html("Documentation for "+CONFIG.flightControllerVersion);
@ -279,12 +282,12 @@ GUI_control.prototype.content_ready = function (callback) {
// loading tooltip
jQuery(document).ready(function($) {
$('cf_tip').each(function() { // Grab all ".cf_tip" elements, and for each...
log(this); // ...print out "this", which now refers to each ".cf_tip" DOM element
log(this); // ...print out "this", which now refers to each ".cf_tip" DOM element
});
$('.cf_tip').each(function() {
$('.cf_tip').each(function() {
$(this).jBox('Tooltip', {
content: $(this).children('.cf_tooltiptext'),
content: $(this).children('.cf_tooltiptext'),
delayOpen: 100,
delayClose: 100,
position: {

View File

@ -8,11 +8,11 @@ TABS.firmware_flasher.initialize = function (callback) {
GUI.active_tab = 'firmware_flasher';
googleAnalytics.sendAppView('Firmware Flasher');
}
var intel_hex = false, // standard intel hex in string format
parsed_hex = false; // parsed raw hex in array format
$('#content').load("./tabs/firmware_flasher.html", function () {
// translate to user-selected language
localize();
@ -137,7 +137,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$.get('https://api.github.com/repos/cleanflight/cleanflight/releases', function (releases){
processReleases(releases);
TABS.firmware_flasher.releases = releases;
// bind events
$('select[name="release"]').change(function() {
if (!GUI.connect_lock) {
@ -155,7 +155,7 @@ TABS.firmware_flasher.initialize = function (callback) {
}
$('select[name="release"]').empty().append('<option value="0">Offline</option>');
});
// UI Hooks
$('a.load_file').click(function () {
@ -221,7 +221,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$("a.load_remote_file").removeClass('disabled');
}
});
$('a.load_remote_file').click(function (evt) {
if ($('select[name="release"]').val() == "0") {
@ -249,34 +249,34 @@ TABS.firmware_flasher.initialize = function (callback) {
d = new Date(data.commit.author.date),
offset = d.getTimezoneOffset() / 60,
date;
date = d.getFullYear() + '.' + ('0' + (d.getMonth() + 1)).slice(-2) + '.' + ('0' + (d.getDate())).slice(-2);
date += ' @ ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);
date += (offset > 0) ? ' GMT+' + offset : ' GMT' + offset;
$('div.git_info .committer').text(data.commit.author.name);
$('div.git_info .date').text(date);
$('div.git_info .hash').text(data.sha.slice(0, 7)).prop('href', 'https://github.com/cleanflight/cleanflight/commit/' + data.sha);
$('div.git_info .message').text(data.commit.message);
$('div.git_info').slideDown();
});
}
$('div.release_info .target').text(summary.target);
var status_e = $('div.release_info .status');
if (summary.status == 'release-candidate') {
$('div.release_info .status').html(chrome.i18n.getMessage('firmwareFlasherReleaseStatusReleaseCandidate')).show();
} else {
status_e.hide();
}
$('div.release_info .name').text(summary.name).prop('href', summary.releaseUrl);
$('div.release_info .date').text(summary.date);
$('div.release_info .file').text(summary.file).prop('href', summary.url);
var formattedNotes = summary.notes.trim('\r').replace(/\r/g, '<br />');
$('div.release_info .notes').html(formattedNotes);
@ -303,7 +303,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
}
});
$('a.flash_firmware').click(function () {
if (!$(this).hasClass('disabled')) {
if (!GUI.connect_lock) { // button disabled while flashing is in progress
@ -424,6 +424,8 @@ TABS.firmware_flasher.initialize = function (callback) {
chrome.storage.local.set({'no_reboot_sequence': status});
});
$('input.updating').change();
});
chrome.storage.local.get('flash_manual_baud', function (result) {
@ -436,22 +438,21 @@ TABS.firmware_flasher.initialize = function (callback) {
// bind UI hook so the status is saved on change
$('input.flash_manual_baud').change(function() {
var status = $(this).is(':checked');
chrome.storage.local.set({'flash_manual_baud': status});
});
$('input.flash_manual_baud').change();
});
chrome.storage.local.get('flash_manual_baud_rate', function (result) {
$('#flash_manual_baud_rate').val(result.flash_manual_baud_rate);
// bind UI hook so the status is saved on change
$('#flash_manual_baud_rate').change(function() {
var baud = parseInt($('#flash_manual_baud_rate').val());
chrome.storage.local.set({'flash_manual_baud_rate': baud});
});
$('input.flash_manual_baud_rate').change();
});
@ -507,6 +508,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$('input.erase_chip').change(function () {
chrome.storage.local.set({'erase_chip': $(this).is(':checked')});
});
});
$(document).keypress(function (e) {