1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-24 16:55:22 +03:00

Convert to CommonJS Modules

This commit is contained in:
Andi Kanzler 2024-02-26 11:58:56 -03:00
parent 7df8253099
commit 91f1699659
100 changed files with 9685 additions and 3735 deletions

View file

@ -1,10 +1,13 @@
/*global mspHelper,$,GUI,MSP,chrome*/
'use strict';
var helper = helper || {};
const mspHelper = require('./msp/MSPHelper');
const features = require('./feature_framework');
const { mixer } = require('./model')
var savingDefaultsModal;
helper.defaultsDialog = (function () {
var defaultsDialog = (function () {
let publicScope = {},
privateScope = {};
@ -903,17 +906,17 @@ helper.defaultsDialog = (function () {
privateScope.setFeaturesBits = function (selectedDefaultPreset) {
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
helper.features.reset();
features.reset();
for (const feature of selectedDefaultPreset.features) {
if (feature.state) {
helper.features.set(feature.bit);
features.set(feature.bit);
} else {
helper.features.unset(feature.bit);
features.unset(feature.bit);
}
}
helper.features.execute(function () {
features.execute(function () {
privateScope.setSettings(selectedDefaultPreset);
});
} else {
@ -924,7 +927,7 @@ helper.defaultsDialog = (function () {
privateScope.finalize = function (selectedDefaultPreset) {
mspHelper.saveToEeprom(function () {
//noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved'));
GUI.log(i18n.getMessage('configurationEepromSaved'));
if (selectedDefaultPreset.reboot) {
GUI.tab_switch_cleanup(function () {
@ -933,7 +936,7 @@ helper.defaultsDialog = (function () {
if (typeof savingDefaultsModal !== 'undefined') {
savingDefaultsModal.close();
}
GUI.log(localization.getMessage('deviceRebooting'));
GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect();
});
});
@ -992,10 +995,10 @@ helper.defaultsDialog = (function () {
// Set Mixers
if (selectedDefaultPreset.mixerToApply) {
let currentMixerPreset = helper.mixer.getById(selectedDefaultPreset.mixerToApply);
let currentMixerPreset = mixer.getById(selectedDefaultPreset.mixerToApply);
helper.mixer.loadServoRules(currentMixerPreset);
helper.mixer.loadMotorRules(currentMixerPreset);
mixer.loadServoRules(currentMixerPreset);
mixer.loadMotorRules(currentMixerPreset);
MIXER_CONFIG.platformType = currentMixerPreset.platform;
MIXER_CONFIG.appliedMixerPreset = selectedDefaultPreset.mixerToApply;
@ -1073,7 +1076,7 @@ helper.defaultsDialog = (function () {
}
$element.find("a").html(preset.title);
$element.data("index", i).click(privateScope.onPresetClick)
$element.data("index", i).on('click', privateScope.onPresetClick)
$element.appendTo($place);
}
}
@ -1090,3 +1093,5 @@ helper.defaultsDialog = (function () {
return publicScope;
})();
module.exports = defaultsDialog;