only request firmware info from github api when firmware is valid

10.3.x-maintenance
cTn 2014-08-31 10:10:53 +02:00
parent b1390b0b01
commit 911ddba278
1 changed files with 16 additions and 16 deletions

View File

@ -6,8 +6,8 @@ TABS.firmware_flasher.initialize = function (callback) {
GUI.active_tab = 'firmware_flasher'; GUI.active_tab = 'firmware_flasher';
googleAnalytics.sendAppView('Firmware Flasher'); googleAnalytics.sendAppView('Firmware Flasher');
var intel_hex = false; // standard intel hex in string format var intel_hex = false, // standard intel hex in string format
var parsed_hex = false; // parsed raw hex in array format parsed_hex = false; // parsed raw hex in array format
$('#content').load("./tabs/firmware_flasher.html", function () { $('#content').load("./tabs/firmware_flasher.html", function () {
// translate to user-selected language // translate to user-selected language
@ -75,9 +75,22 @@ TABS.firmware_flasher.initialize = function (callback) {
if (parsed_hex) { if (parsed_hex) {
googleAnalytics.sendEvent('Flashing', 'Firmware', 'online'); googleAnalytics.sendEvent('Flashing', 'Firmware', 'online');
$('span.progressLabel').text('Loaded Online Firmware: (' + parsed_hex.bytes_total + ' bytes)');
$('a.flash_firmware').removeClass('locked'); $('a.flash_firmware').removeClass('locked');
$('span.progressLabel').text('Loaded Online Firmware: (' + parsed_hex.bytes_total + ' bytes)'); $.get('https://api.github.com/repos/multiwii/baseflight/commits?page=1&per_page=1&path=obj/baseflight.hex', function (data) {
var data = data[0],
d = new Date(data.commit.author.date),
date = ('0' + (d.getMonth() + 1)).slice(-2) + '.' + ('0' + (d.getDate() + 1)).slice(-2) + '.' + d.getFullYear();
date += ' @ ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);
$('div.git_info .committer').text(data.commit.author.name);
$('div.git_info .date').text(date);
$('div.git_info .message').text(data.commit.message);
$('div.git_info').slideDown();
});
} else { } else {
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherHexCorrupted')); $('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherHexCorrupted'));
} }
@ -86,19 +99,6 @@ TABS.firmware_flasher.initialize = function (callback) {
$('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware')); $('span.progressLabel').text(chrome.i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
$('a.flash_firmware').addClass('locked'); $('a.flash_firmware').addClass('locked');
}); });
$.get('https://api.github.com/repos/multiwii/baseflight/commits?page=1&per_page=1&path=obj/baseflight.hex', function (data) {
var data = data[0];
var d = new Date(data.commit.author.date);
var date = ('0' + (d.getMonth() + 1)).slice(-2) + '.' + ('0' + (d.getDate() + 1)).slice(-2) + '.' + d.getFullYear();
date += ' @ ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2);
$('div.git_info .committer').text(data.commit.author.name);
$('div.git_info .date').text(date);
$('div.git_info .message').text(data.commit.message);
$('div.git_info').slideDown();
});
}); });
$('a.flash_firmware').click(function () { $('a.flash_firmware').click(function () {