diff --git a/src/js/main.js b/src/js/main.js index 8e4ae170..bc89bd70 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -321,7 +321,9 @@ function startProcess() { ); break; case 'firmware_flasher': - TABS.firmware_flasher.initialize(content_ready); + import("./tabs/firmware_flasher").then(({ firmware_flasher }) => + firmware_flasher.initialize(content_ready) + ); break; case 'help': import('./tabs/help').then(({ help }) => help.initialize(content_ready)); diff --git a/src/js/tabs/firmware_flasher.js b/src/js/tabs/firmware_flasher.js index 3bba0799..965abc00 100644 --- a/src/js/tabs/firmware_flasher.js +++ b/src/js/tabs/firmware_flasher.js @@ -1,6 +1,6 @@ -'use strict'; +import { i18n } from '../localization'; -TABS.firmware_flasher = { +const firmware_flasher = { releases: null, releaseChecker: new ReleaseChecker('firmware', 'https://api.github.com/repos/betaflight/betaflight/releases'), jenkinsLoader: new JenkinsLoader('https://ci.betaflight.tech'), @@ -14,7 +14,7 @@ TABS.firmware_flasher = { developmentFirmwareLoaded: false, // Is the firmware to be flashed from the development branch? }; -TABS.firmware_flasher.initialize = function (callback) { +firmware_flasher.initialize = function (callback) { var self = this; if (GUI.active_tab != 'firmware_flasher') { @@ -1224,7 +1224,7 @@ TABS.firmware_flasher.initialize = function (callback) { }); }; -TABS.firmware_flasher.cleanup = function (callback) { +firmware_flasher.cleanup = function (callback) { PortHandler.flush_callbacks(); FirmwareCache.unload(); @@ -1241,9 +1241,7 @@ TABS.firmware_flasher.cleanup = function (callback) { if (callback) callback(); }; -TABS.firmware_flasher.enableFlashing = function (enabled) { - var self = this; - +firmware_flasher.enableFlashing = function (enabled) { if (enabled) { $('a.flash_firmware').removeClass('disabled'); } else { @@ -1251,12 +1249,12 @@ TABS.firmware_flasher.enableFlashing = function (enabled) { } }; -TABS.firmware_flasher.FLASH_MESSAGE_TYPES = {NEUTRAL : 'NEUTRAL', +firmware_flasher.FLASH_MESSAGE_TYPES = {NEUTRAL : 'NEUTRAL', VALID : 'VALID', INVALID : 'INVALID', ACTION : 'ACTION'}; -TABS.firmware_flasher.flashingMessage = function(message, type) { +firmware_flasher.flashingMessage = function(message, type) { let self = this; let progressLabel_e = $('span.progressLabel'); @@ -1285,13 +1283,13 @@ TABS.firmware_flasher.flashingMessage = function(message, type) { return self; }; -TABS.firmware_flasher.flashProgress = function(value) { +firmware_flasher.flashProgress = function(value) { $('.progress').val(value); return this; }; -TABS.firmware_flasher.injectTargetInfo = function (targetConfig, targetName, manufacturerId, commitInfo) { +firmware_flasher.injectTargetInfo = function (targetConfig, targetName, manufacturerId, commitInfo) { const targetInfoLineRegex = /^# config: manufacturer_id: .*, board_name: .*, version: .*$, date: .*\n/gm; const config = targetConfig.replace(targetInfoLineRegex, ''); @@ -1302,3 +1300,9 @@ TABS.firmware_flasher.injectTargetInfo = function (targetConfig, targetName, man lines.splice(1, 0, targetInfo); return lines.join('\n'); }; + +TABS.firmware_flasher = firmware_flasher; + +export { + firmware_flasher, +}; diff --git a/src/main.html b/src/main.html index dd3cfb38..a83fb2b7 100644 --- a/src/main.html +++ b/src/main.html @@ -128,7 +128,6 @@ -