2014-08-09 18:51:06 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-08-12 13:51:31 +00:00
|
|
|
TABS.firmware_flasher = {};
|
|
|
|
TABS.firmware_flasher.initialize = function (callback) {
|
2014-10-01 10:58:09 +00:00
|
|
|
var self = this;
|
|
|
|
|
2014-10-01 11:16:22 +00:00
|
|
|
if (GUI.active_tab != 'firmware_flasher') {
|
|
|
|
GUI.active_tab = 'firmware_flasher';
|
|
|
|
googleAnalytics.sendAppView('Firmware Flasher');
|
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-31 08:10:53 +00:00
|
|
|
var intel_hex = false, // standard intel hex in string format
|
|
|
|
parsed_hex = false; // parsed raw hex in array format
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
$('#content').load("./tabs/firmware_flasher.html", function () {
|
2014-05-06 14:48:46 +00:00
|
|
|
// translate to user-selected language
|
|
|
|
localize();
|
|
|
|
|
2014-10-19 02:18:05 +00:00
|
|
|
function parse_hex(str, callback) {
|
|
|
|
// parsing hex in different thread
|
|
|
|
var worker = new Worker('./js/workers/hex_parser.js');
|
|
|
|
|
|
|
|
// "callback"
|
|
|
|
worker.onmessage = function (event) {
|
|
|
|
callback(event.data);
|
|
|
|
};
|
|
|
|
|
|
|
|
// send data/string over for processing
|
|
|
|
worker.postMessage(str);
|
|
|
|
}
|
|
|
|
|
2014-11-10 20:33:32 +00:00
|
|
|
// Fetch Releases
|
|
|
|
$.get('http://firmware.baseflight.net/listing.json', function (data) {
|
|
|
|
var releases = [],
|
|
|
|
releases_e = $('select[name="release"]').empty(),
|
|
|
|
d, date, offset;
|
|
|
|
|
|
|
|
// filter out what we need
|
|
|
|
for (var i = 0; i < data.length; i++) {
|
|
|
|
if (data[i].target == 'NAZE') {
|
|
|
|
releases.push(data[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-15 01:18:04 +00:00
|
|
|
// reorder the array by time, TODO needs more testing
|
2014-11-10 20:33:32 +00:00
|
|
|
releases.sort(function (a, b) {
|
2014-11-15 01:18:04 +00:00
|
|
|
// stable releases always go first
|
|
|
|
if (a.release > b.release) {
|
|
|
|
return -1;
|
|
|
|
} else if (a.release < b.release) {
|
2014-11-10 20:33:32 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2014-11-15 01:18:04 +00:00
|
|
|
|
|
|
|
// sort by time
|
|
|
|
return b.time - a.time;
|
2014-11-10 20:33:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// populate select
|
|
|
|
for (var i = 0; i < releases.length; i++) {
|
|
|
|
d = new Date(releases[i].time * 1000);
|
2014-11-26 11:34:32 +00:00
|
|
|
date = ('0' + (d.getDate())).slice(-2) + '.' + ('0' + (d.getMonth() + 1)).slice(-2) + '.' + d.getFullYear();
|
2014-11-10 20:33:32 +00:00
|
|
|
date += ' - ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);
|
|
|
|
|
|
|
|
var element = $('<option value="' + i + '">' + (((releases[i].release) ? 'Stable' : 'Dev') + ' ' + date) + '</option>').data('obj', releases[i]);
|
|
|
|
releases_e.append(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind events
|
|
|
|
$('select[name="release"]').change(function() {
|
2014-11-11 10:59:12 +00:00
|
|
|
if (!GUI.connect_lock) {
|
|
|
|
$('.progress').val(0).removeClass('valid invalid');
|
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherLoadFirmwareFile'));
|
|
|
|
$('div.git_info').slideUp();
|
|
|
|
$('a.flash_firmware').addClass('locked');
|
|
|
|
}
|
2014-11-10 20:33:32 +00:00
|
|
|
});
|
|
|
|
}).fail(function () {
|
2014-11-11 10:59:12 +00:00
|
|
|
$('select[name="release"]').empty().append('<option value="0">Offline</option>')
|
2014-11-10 20:33:32 +00:00
|
|
|
});
|
|
|
|
|
2013-11-13 08:09:02 +00:00
|
|
|
// UI Hooks
|
2014-08-09 18:51:06 +00:00
|
|
|
$('a.load_file').click(function () {
|
|
|
|
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
2014-09-04 15:16:13 +00:00
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
console.error(chrome.runtime.lastError.message);
|
|
|
|
|
2013-11-13 08:09:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-02-27 17:56:12 +00:00
|
|
|
// hide github info (if it exists)
|
|
|
|
$('div.git_info').slideUp();
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
chrome.fileSystem.getDisplayPath(fileEntry, function (path) {
|
2013-11-13 08:09:02 +00:00
|
|
|
console.log('Loading file from: ' + path);
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
fileEntry.file(function (file) {
|
2013-11-13 08:09:02 +00:00
|
|
|
var reader = new FileReader();
|
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
reader.onprogress = function (e) {
|
2014-01-10 23:08:24 +00:00
|
|
|
if (e.total > 1048576) { // 1 MB
|
|
|
|
// dont allow reading files bigger then 1 MB
|
|
|
|
console.log('File limit (1 MB) exceeded, aborting');
|
|
|
|
reader.abort();
|
|
|
|
}
|
2013-11-13 08:09:02 +00:00
|
|
|
};
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2013-11-13 08:09:02 +00:00
|
|
|
reader.onloadend = function(e) {
|
2014-01-10 23:08:24 +00:00
|
|
|
if (e.total != 0 && e.total == e.loaded) {
|
|
|
|
console.log('File loaded');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-01-10 23:08:24 +00:00
|
|
|
intel_hex = e.target.result;
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
parse_hex(intel_hex, function (data) {
|
2014-01-10 23:08:24 +00:00
|
|
|
parsed_hex = data;
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-01-10 23:08:24 +00:00
|
|
|
if (parsed_hex) {
|
2014-07-16 10:59:12 +00:00
|
|
|
googleAnalytics.sendEvent('Flashing', 'Firmware', 'local');
|
2014-01-10 23:08:24 +00:00
|
|
|
$('a.flash_firmware').removeClass('locked');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-30 08:36:55 +00:00
|
|
|
$('span.progressLabel').text('Loaded Local Firmware: (' + parsed_hex.bytes_total + ' bytes)');
|
2014-01-10 23:08:24 +00:00
|
|
|
} else {
|
2014-08-30 08:30:28 +00:00
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
|
2014-01-10 23:08:24 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-11-13 08:09:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
reader.readAsText(file);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
$('a.load_remote_file').click(function () {
|
2014-11-10 20:33:32 +00:00
|
|
|
function process_hex(data, obj) {
|
2013-11-13 12:24:05 +00:00
|
|
|
intel_hex = data;
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
parse_hex(intel_hex, function (data) {
|
2013-11-16 09:01:29 +00:00
|
|
|
parsed_hex = data;
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2013-11-16 09:01:29 +00:00
|
|
|
if (parsed_hex) {
|
2014-10-24 13:36:19 +00:00
|
|
|
var url;
|
2014-09-04 15:16:13 +00:00
|
|
|
|
2014-10-24 13:36:19 +00:00
|
|
|
googleAnalytics.sendEvent('Flashing', 'Firmware', 'online');
|
|
|
|
$('span.progressLabel').html('<a class="save_firmware" href="#" title="Save Firmware">Loaded Online Firmware: (' + parsed_hex.bytes_total + ' bytes)</a>');
|
2014-09-04 15:16:13 +00:00
|
|
|
|
2013-11-16 09:01:29 +00:00
|
|
|
$('a.flash_firmware').removeClass('locked');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-11-10 20:33:32 +00:00
|
|
|
$.get('https://api.github.com/repos/multiwii/baseflight/commits/' + obj.commit, function (data) {
|
|
|
|
var data = data,
|
2014-08-31 08:10:53 +00:00
|
|
|
d = new Date(data.commit.author.date),
|
2014-10-11 14:45:19 +00:00
|
|
|
offset = d.getTimezoneOffset() / 60,
|
|
|
|
date;
|
2014-08-31 08:10:53 +00:00
|
|
|
|
2014-11-26 11:34:32 +00:00
|
|
|
date = ('0' + (d.getDate())).slice(-2) + '.' + ('0' + (d.getMonth() + 1)).slice(-2) + '.' + d.getFullYear();
|
2014-08-31 08:10:53 +00:00
|
|
|
date += ' @ ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);
|
2014-10-11 14:45:19 +00:00
|
|
|
date += (offset > 0) ? ' GMT+' + offset : ' GMT' + offset;
|
2014-08-31 08:10:53 +00:00
|
|
|
|
|
|
|
$('div.git_info .committer').text(data.commit.author.name);
|
|
|
|
$('div.git_info .date').text(date);
|
2014-11-11 10:59:12 +00:00
|
|
|
$('div.git_info .hash').text(data.sha.slice(0, 7)).prop('href', 'https://github.com/multiwii/baseflight/commit/' + data.sha);
|
2014-08-31 08:10:53 +00:00
|
|
|
$('div.git_info .message').text(data.commit.message);
|
|
|
|
|
|
|
|
$('div.git_info').slideDown();
|
|
|
|
});
|
2013-11-16 09:01:29 +00:00
|
|
|
} else {
|
2014-08-30 08:30:28 +00:00
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
|
2013-11-16 09:01:29 +00:00
|
|
|
}
|
|
|
|
});
|
2014-10-24 13:36:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function failed_to_load() {
|
2014-11-03 15:57:08 +00:00
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
|
2013-11-14 18:02:32 +00:00
|
|
|
$('a.flash_firmware').addClass('locked');
|
2014-10-24 13:36:19 +00:00
|
|
|
}
|
|
|
|
|
2014-11-10 20:33:32 +00:00
|
|
|
var obj = $('select[name="release"] option:selected').data('obj');
|
2014-11-11 10:59:12 +00:00
|
|
|
|
|
|
|
if (obj) { // undefined while list is loading or while running offline
|
|
|
|
$.get('http://firmware.baseflight.net/' + obj.file, function (data) {
|
|
|
|
process_hex(data, obj);
|
|
|
|
}).fail(failed_to_load);
|
|
|
|
} else {
|
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
|
|
|
|
}
|
2013-11-13 12:24:05 +00:00
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
$('a.flash_firmware').click(function () {
|
2013-11-14 18:02:32 +00:00
|
|
|
if (!$(this).hasClass('locked')) {
|
|
|
|
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
2014-03-08 05:25:15 +00:00
|
|
|
if (parsed_hex != false) {
|
2014-06-20 12:29:16 +00:00
|
|
|
if (String($('div#port-picker #port').val()) != 'DFU') {
|
2014-07-22 12:16:09 +00:00
|
|
|
if (String($('div#port-picker #port').val()) != '0') {
|
2014-08-30 06:59:21 +00:00
|
|
|
var options = {},
|
|
|
|
port = String($('div#port-picker #port').val()),
|
|
|
|
baud;
|
2014-07-22 12:16:09 +00:00
|
|
|
|
|
|
|
switch (GUI.operating_system) {
|
|
|
|
case 'Windows':
|
|
|
|
case 'MacOS':
|
|
|
|
case 'ChromeOS':
|
|
|
|
case 'Linux':
|
|
|
|
case 'UNIX':
|
|
|
|
baud = 921600;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
baud = 115200;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($('input.updating').is(':checked')) {
|
|
|
|
options.no_reboot = true;
|
|
|
|
} else {
|
|
|
|
options.reboot_baud = parseInt($('div#port-picker #baud').val());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($('input.erase_chip').is(':checked')) {
|
|
|
|
options.erase_chip = true;
|
|
|
|
}
|
|
|
|
|
2014-08-30 06:59:21 +00:00
|
|
|
if ($('input.flash_slowly').is(':checked')) {
|
|
|
|
options.flash_slowly = true;
|
|
|
|
}
|
|
|
|
|
2014-07-22 12:16:09 +00:00
|
|
|
STM32.connect(port, baud, parsed_hex, options);
|
|
|
|
} else {
|
|
|
|
console.log('Please select valid serial port');
|
|
|
|
GUI.log('<span style="color: red">Please select valid serial port</span>');
|
|
|
|
}
|
2014-06-08 18:10:07 +00:00
|
|
|
} else {
|
2014-07-22 12:16:09 +00:00
|
|
|
STM32DFU.connect(usbDevices.STM32DFU, parsed_hex);
|
2014-06-08 18:10:07 +00:00
|
|
|
}
|
2013-11-14 18:02:32 +00:00
|
|
|
} else {
|
2014-08-30 08:30:28 +00:00
|
|
|
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFirmwareNotLoaded'));
|
2013-11-14 18:02:32 +00:00
|
|
|
}
|
2013-11-14 06:39:39 +00:00
|
|
|
}
|
2013-11-13 08:32:33 +00:00
|
|
|
}
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-10-24 13:36:19 +00:00
|
|
|
$(document).on('click', 'span.progressLabel a.save_firmware', function () {
|
|
|
|
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: 'baseflight', accepts: [{extensions: ['hex']}]}, function (fileEntry) {
|
|
|
|
if (chrome.runtime.lastError) {
|
|
|
|
console.error(chrome.runtime.lastError.message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
chrome.fileSystem.getDisplayPath(fileEntry, function (path) {
|
|
|
|
console.log('Saving firmware to: ' + path);
|
|
|
|
|
|
|
|
// check if file is writable
|
|
|
|
chrome.fileSystem.isWritableEntry(fileEntry, function (isWritable) {
|
|
|
|
if (isWritable) {
|
|
|
|
var blob = new Blob([intel_hex], {type: 'text/plain'});
|
|
|
|
|
|
|
|
fileEntry.createWriter(function (writer) {
|
|
|
|
var truncated = false;
|
|
|
|
|
|
|
|
writer.onerror = function (e) {
|
|
|
|
console.error(e);
|
|
|
|
};
|
|
|
|
|
|
|
|
writer.onwriteend = function() {
|
|
|
|
if (!truncated) {
|
|
|
|
// onwriteend will be fired again when truncation is finished
|
|
|
|
truncated = true;
|
|
|
|
writer.truncate(blob.size);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
writer.write(blob);
|
|
|
|
}, function (e) {
|
|
|
|
console.error(e);
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
console.log('You don\'t have write permissions for this file, sorry.');
|
|
|
|
GUI.log('You don\'t have <span style="color: red">write permissions</span> for this file');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
chrome.storage.local.get('no_reboot_sequence', function (result) {
|
2014-05-08 12:56:25 +00:00
|
|
|
if (result.no_reboot_sequence) {
|
|
|
|
$('input.updating').prop('checked', true);
|
2014-10-24 14:55:42 +00:00
|
|
|
$('.flash_on_connect_wrapper').show();
|
2014-02-25 14:40:18 +00:00
|
|
|
} else {
|
2014-05-08 12:56:25 +00:00
|
|
|
$('input.updating').prop('checked', false);
|
2014-02-25 14:40:18 +00:00
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-02-25 14:40:18 +00:00
|
|
|
// bind UI hook so the status is saved on change
|
2014-02-26 06:09:53 +00:00
|
|
|
$('input.updating').change(function() {
|
|
|
|
var status = $(this).is(':checked');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-02-26 06:09:53 +00:00
|
|
|
if (status) {
|
2014-10-24 14:55:42 +00:00
|
|
|
$('.flash_on_connect_wrapper').show();
|
2014-02-26 06:09:53 +00:00
|
|
|
} else {
|
2014-02-26 07:32:57 +00:00
|
|
|
$('input.flash_on_connect').prop('checked', false).change();
|
2014-10-24 14:55:42 +00:00
|
|
|
$('.flash_on_connect_wrapper').hide();
|
2014-02-26 06:09:53 +00:00
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-05-07 02:08:52 +00:00
|
|
|
chrome.storage.local.set({'no_reboot_sequence': status});
|
2014-02-25 14:40:18 +00:00
|
|
|
});
|
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
chrome.storage.local.get('flash_on_connect', function (result) {
|
2014-05-08 12:56:25 +00:00
|
|
|
if (result.flash_on_connect) {
|
|
|
|
$('input.flash_on_connect').prop('checked', true);
|
2014-02-26 07:10:08 +00:00
|
|
|
} else {
|
2014-05-08 12:56:25 +00:00
|
|
|
$('input.flash_on_connect').prop('checked', false);
|
2014-02-26 07:10:08 +00:00
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
$('input.flash_on_connect').change(function () {
|
2014-02-26 07:20:30 +00:00
|
|
|
var status = $(this).is(':checked');
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-02-26 07:20:30 +00:00
|
|
|
if (status) {
|
2014-10-19 07:38:39 +00:00
|
|
|
var catch_new_port = function () {
|
|
|
|
PortHandler.port_detected('flash_detected_device', function (result) {
|
|
|
|
var port = result[0];
|
|
|
|
|
|
|
|
if (!GUI.connect_lock) {
|
|
|
|
GUI.log('Detected: <strong>' + port + '</strong> - triggering flash on connect');
|
|
|
|
console.log('Detected: ' + port + ' - triggering flash on connect');
|
|
|
|
|
|
|
|
// Trigger regular Flashing sequence
|
|
|
|
GUI.timeout_add('initialization_timeout', function () {
|
|
|
|
$('a.flash_firmware').click();
|
|
|
|
}, 100); // timeout so bus have time to initialize after being detected by the system
|
|
|
|
} else {
|
|
|
|
GUI.log('Detected <strong>' + port + '</strong> - previous device still flashing, please replug to try again');
|
2014-02-26 07:10:08 +00:00
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-10-19 07:38:39 +00:00
|
|
|
// Since current port_detected request was consumed, create new one
|
|
|
|
catch_new_port();
|
2014-02-26 07:20:30 +00:00
|
|
|
}, false, true);
|
2014-10-19 07:38:39 +00:00
|
|
|
};
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-10-19 07:38:39 +00:00
|
|
|
catch_new_port();
|
2014-02-26 07:20:30 +00:00
|
|
|
} else {
|
|
|
|
PortHandler.flush_callbacks();
|
|
|
|
}
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-05-07 02:08:52 +00:00
|
|
|
chrome.storage.local.set({'flash_on_connect': status});
|
2014-02-26 07:20:30 +00:00
|
|
|
}).change();
|
2014-02-26 07:10:08 +00:00
|
|
|
});
|
2014-03-08 05:25:15 +00:00
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
chrome.storage.local.get('erase_chip', function (result) {
|
2014-05-08 12:56:25 +00:00
|
|
|
if (result.erase_chip) {
|
|
|
|
$('input.erase_chip').prop('checked', true);
|
2014-05-07 06:07:49 +00:00
|
|
|
} else {
|
2014-05-08 12:56:25 +00:00
|
|
|
$('input.erase_chip').prop('checked', false);
|
2014-05-07 06:07:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// bind UI hook so the status is saved on change
|
2014-08-09 18:51:06 +00:00
|
|
|
$('input.erase_chip').change(function () {
|
2014-08-30 06:59:21 +00:00
|
|
|
chrome.storage.local.set({'erase_chip': $(this).is(':checked')});
|
|
|
|
});
|
|
|
|
});
|
2014-05-07 06:07:49 +00:00
|
|
|
|
2014-08-30 06:59:21 +00:00
|
|
|
chrome.storage.local.get('flash_slowly', function (result) {
|
|
|
|
if (result.flash_slowly) {
|
|
|
|
$('input.flash_slowly').prop('checked', true);
|
|
|
|
} else {
|
|
|
|
$('input.flash_slowly').prop('checked', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// bind UI hook so the status is saved on change
|
|
|
|
$('input.flash_slowly').change(function () {
|
|
|
|
chrome.storage.local.set({'flash_slowly': $(this).is(':checked')});
|
2014-05-07 06:07:49 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-08-09 18:51:06 +00:00
|
|
|
$(document).keypress(function (e) {
|
2014-04-11 19:21:48 +00:00
|
|
|
if (e.which == 13) { // enter
|
|
|
|
// Trigger regular Flashing sequence
|
|
|
|
$('a.flash_firmware').click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// back button
|
2014-08-09 18:51:06 +00:00
|
|
|
$('a.back').click(function () {
|
2014-02-26 07:10:08 +00:00
|
|
|
if (!GUI.connect_lock) { // button disabled while flashing is in progress
|
2014-08-09 18:51:06 +00:00
|
|
|
GUI.tab_switch_cleanup(function () {
|
2014-09-20 11:51:23 +00:00
|
|
|
TABS.landing.initialize();
|
2014-02-26 07:10:08 +00:00
|
|
|
});
|
2013-11-14 06:49:02 +00:00
|
|
|
} else {
|
2014-05-08 10:01:07 +00:00
|
|
|
GUI.log(chrome.i18n.getMessage('firmwareFlasherWaitForFinish'));
|
2013-11-14 06:49:02 +00:00
|
|
|
}
|
|
|
|
});
|
2014-07-10 16:41:11 +00:00
|
|
|
|
|
|
|
if (callback) callback();
|
2013-11-13 07:55:29 +00:00
|
|
|
});
|
2014-07-10 16:41:11 +00:00
|
|
|
};
|
|
|
|
|
2014-08-12 13:51:31 +00:00
|
|
|
TABS.firmware_flasher.cleanup = function (callback) {
|
2014-07-10 16:45:18 +00:00
|
|
|
PortHandler.flush_callbacks();
|
|
|
|
|
|
|
|
// unbind "global" events
|
|
|
|
$(document).unbind('keypress');
|
2014-10-24 13:36:19 +00:00
|
|
|
$(document).off('click', 'span.progressLabel a');
|
2014-07-10 16:45:18 +00:00
|
|
|
|
2014-07-10 16:41:11 +00:00
|
|
|
if (callback) callback();
|
2014-10-19 02:18:05 +00:00
|
|
|
};
|