1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-17 05:15:21 +03:00

feat: migrate landing to modules

This commit is contained in:
Tomas Chmelevskij 2021-03-01 20:05:44 +01:00
parent 68b39643b7
commit d8be3dd5a2
3 changed files with 23 additions and 25 deletions

View file

@ -1,8 +1,5 @@
import { i18n } from './localization'; import { i18n } from './localization';
window.googleAnalytics = analytics;
window.analytics = null;
$(document).ready(function () { $(document).ready(function () {
useGlobalNodeFunctions(); useGlobalNodeFunctions();
@ -40,7 +37,6 @@ function appReady() {
}); });
}); });
} }
window.appReady = appReady;
function checkSetupAnalytics(callback) { function checkSetupAnalytics(callback) {
if (!analytics) { if (!analytics) {
@ -58,8 +54,6 @@ function checkSetupAnalytics(callback) {
} }
} }
window.checkSetupAnalytics = checkSetupAnalytics;
function getBuildType() { function getBuildType() {
return GUI.Mode; return GUI.Mode;
} }
@ -301,7 +295,7 @@ function startProcess() {
switch (tab) { switch (tab) {
case 'landing': case 'landing':
TABS.landing.initialize(content_ready); import('./tabs/landing').then(({ landing }) => landing.initialize(content_ready));
break; break;
case 'changelog': case 'changelog':
TABS.staticTab.initialize('changelog', content_ready); TABS.staticTab.initialize('changelog', content_ready);
@ -548,7 +542,6 @@ function setDarkTheme(enabled) {
}); });
} }
window.setDarkTheme = setDarkTheme;
function checkForConfiguratorUpdates() { function checkForConfiguratorUpdates() {
const releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases'); const releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases');
@ -556,8 +549,6 @@ function checkForConfiguratorUpdates() {
releaseChecker.loadReleaseData(notifyOutdatedVersion); releaseChecker.loadReleaseData(notifyOutdatedVersion);
} }
window.checkForConfiguratorUpdates = checkForConfiguratorUpdates;
function notifyOutdatedVersion(releaseData) { function notifyOutdatedVersion(releaseData) {
ConfigStorage.get('checkForConfiguratorUnstableVersions', function (result) { ConfigStorage.get('checkForConfiguratorUnstableVersions', function (result) {
let showUnstableReleases = false; let showUnstableReleases = false;
@ -611,8 +602,6 @@ function isExpertModeEnabled() {
return $('input[name="expertModeCheckbox"]').is(':checked'); return $('input[name="expertModeCheckbox"]').is(':checked');
} }
window.isExpertModeEnabled = isExpertModeEnabled;
function updateTabList(features) { function updateTabList(features) {
if (isExpertModeEnabled()) { if (isExpertModeEnabled()) {
@ -667,8 +656,6 @@ function updateTabList(features) {
} }
window.updateTabList = updateTabList;
function zeroPad(value, width) { function zeroPad(value, width) {
let valuePadded = String(value); let valuePadded = String(value);
@ -700,8 +687,6 @@ function generateFilename(prefix, suffix) {
return `${filename}.${suffix}`; return `${filename}.${suffix}`;
} }
window.generateFilename = generateFilename;
function showErrorDialog(message) { function showErrorDialog(message) {
const dialog = $('.dialogError')[0]; const dialog = $('.dialogError')[0];
@ -714,8 +699,6 @@ function showErrorDialog(message) {
dialog.showModal(); dialog.showModal();
} }
window.showErrorDialog = showErrorDialog;
function showDialogDynFiltersChange() { function showDialogDynFiltersChange() {
const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0]; const dialogDynFiltersChange = $('.dialogDynFiltersChange')[0];
@ -728,4 +711,16 @@ function showDialogDynFiltersChange() {
} }
} }
// TODO: all of these are used as globals in other parts.
// once moved to modules extract to own module.
window.showDialogDynFiltersChange = showDialogDynFiltersChange; window.showDialogDynFiltersChange = showDialogDynFiltersChange;
window.googleAnalytics = analytics;
window.analytics = null;
window.showErrorDialog = showErrorDialog;
window.generateFilename = generateFilename;
window.updateTabList = updateTabList;
window.isExpertModeEnabled = isExpertModeEnabled;
window.checkForConfiguratorUpdates = checkForConfiguratorUpdates;
window.setDarkTheme = setDarkTheme;
window.appReady = appReady;
window.checkSetupAnalytics = checkSetupAnalytics;

View file

@ -1,7 +1,5 @@
'use strict'; const landing = {};
landing.initialize = function (callback) {
TABS.landing = {};
TABS.landing.initialize = function (callback) {
if (GUI.active_tab != 'landing') { if (GUI.active_tab != 'landing') {
GUI.active_tab = 'landing'; GUI.active_tab = 'landing';
@ -49,6 +47,12 @@ TABS.landing.initialize = function (callback) {
}; };
TABS.landing.cleanup = function (callback) { landing.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };
// TODO: remove after all is using modules
window.TABS.landing = landing;
export {
landing
};

View file

@ -111,7 +111,6 @@
<script type="module" src="./js/main.js"></script> <script type="module" src="./js/main.js"></script>
<script type="text/javascript" src="./js/Clipboard.js"></script> <script type="text/javascript" src="./js/Clipboard.js"></script>
<script type="text/javascript" src="./js/tabs/static_tab.js"></script> <script type="text/javascript" src="./js/tabs/static_tab.js"></script>
<script type="text/javascript" src="./js/tabs/landing.js"></script>
<script type="text/javascript" src="./js/tabs/setup.js"></script> <script type="text/javascript" src="./js/tabs/setup.js"></script>
<script type="text/javascript" src="./js/tabs/setup_osd.js"></script> <script type="text/javascript" src="./js/tabs/setup_osd.js"></script>
<script type="text/javascript" src="./js/tabs/ports.js"></script> <script type="text/javascript" src="./js/tabs/ports.js"></script>
@ -121,7 +120,7 @@
<script type="text/javascript" src="./js/tabs/auxiliary.js"></script> <script type="text/javascript" src="./js/tabs/auxiliary.js"></script>
<script type="text/javascript" src="./js/tabs/adjustments.js"></script> <script type="text/javascript" src="./js/tabs/adjustments.js"></script>
<script type="text/javascript" src="./js/tabs/servos.js"></script> <script type="text/javascript" src="./js/tabs/servos.js"></script>
<script type="module" src="./js/tabs/gps.js"></script> <script type="text/javascript" src="./js/tabs/gps.js"></script>
<script type="text/javascript" src="./js/tabs/motors.js"></script> <script type="text/javascript" src="./js/tabs/motors.js"></script>
<script type="text/javascript" src="./js/tabs/led_strip.js"></script> <script type="text/javascript" src="./js/tabs/led_strip.js"></script>
<script type="text/javascript" src="./js/tabs/sensors.js"></script> <script type="text/javascript" src="./js/tabs/sensors.js"></script>