diff --git a/src/js/main.js b/src/js/main.js
index 3241d15b..76530a9f 100644
--- a/src/js/main.js
+++ b/src/js/main.js
@@ -1,8 +1,5 @@
import { i18n } from './localization';
-window.googleAnalytics = analytics;
-window.analytics = null;
-
$(document).ready(function () {
useGlobalNodeFunctions();
@@ -40,7 +37,6 @@ function appReady() {
});
});
}
-window.appReady = appReady;
function checkSetupAnalytics(callback) {
if (!analytics) {
@@ -58,8 +54,6 @@ function checkSetupAnalytics(callback) {
}
}
-window.checkSetupAnalytics = checkSetupAnalytics;
-
function getBuildType() {
return GUI.Mode;
}
@@ -301,7 +295,7 @@ function startProcess() {
switch (tab) {
case 'landing':
- TABS.landing.initialize(content_ready);
+ import('./tabs/landing').then(({ landing }) => landing.initialize(content_ready));
break;
case 'changelog':
TABS.staticTab.initialize('changelog', content_ready);
@@ -548,7 +542,6 @@ function setDarkTheme(enabled) {
});
}
-window.setDarkTheme = setDarkTheme;
function checkForConfiguratorUpdates() {
const releaseChecker = new ReleaseChecker('configurator', 'https://api.github.com/repos/betaflight/betaflight-configurator/releases');
@@ -556,8 +549,6 @@ function checkForConfiguratorUpdates() {
releaseChecker.loadReleaseData(notifyOutdatedVersion);
}
-window.checkForConfiguratorUpdates = checkForConfiguratorUpdates;
-
function notifyOutdatedVersion(releaseData) {
ConfigStorage.get('checkForConfiguratorUnstableVersions', function (result) {
let showUnstableReleases = false;
@@ -611,8 +602,6 @@ function isExpertModeEnabled() {
return $('input[name="expertModeCheckbox"]').is(':checked');
}
-window.isExpertModeEnabled = isExpertModeEnabled;
-
function updateTabList(features) {
if (isExpertModeEnabled()) {
@@ -667,8 +656,6 @@ function updateTabList(features) {
}
-window.updateTabList = updateTabList;
-
function zeroPad(value, width) {
let valuePadded = String(value);
@@ -700,8 +687,6 @@ function generateFilename(prefix, suffix) {
return `${filename}.${suffix}`;
}
-window.generateFilename = generateFilename;
-
function showErrorDialog(message) {
const dialog = $('.dialogError')[0];
@@ -714,8 +699,6 @@ function showErrorDialog(message) {
dialog.showModal();
}
-window.showErrorDialog = showErrorDialog;
-
function showDialogDynFiltersChange() {
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.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;
diff --git a/src/js/tabs/landing.js b/src/js/tabs/landing.js
index 27716299..5d9912a8 100644
--- a/src/js/tabs/landing.js
+++ b/src/js/tabs/landing.js
@@ -1,7 +1,5 @@
-'use strict';
-
-TABS.landing = {};
-TABS.landing.initialize = function (callback) {
+const landing = {};
+landing.initialize = function (callback) {
if (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();
};
+
+// TODO: remove after all is using modules
+window.TABS.landing = landing;
+export {
+ landing
+};
diff --git a/src/main.html b/src/main.html
index d2342c68..e1961b36 100644
--- a/src/main.html
+++ b/src/main.html
@@ -111,7 +111,6 @@
-
@@ -121,7 +120,7 @@
-
+