1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

Merge pull request #2416 from chmelevskij/chore/utils-modules

chore: move css and CommonUtils to modules
This commit is contained in:
Michael Keller 2021-02-17 07:52:45 +13:00 committed by GitHub
commit d123e08180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 19 deletions

View file

@ -203,7 +203,7 @@ TABS.motors.initialize = function (callback) {
}
function update_model(mixer) {
const imgSrc = CommonUtils.GetMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir, FC.CONFIG.apiVersion);
const imgSrc = getMixerImageSrc(mixer, FC.MIXER_CONFIG.reverseMotorDir, FC.CONFIG.apiVersion);
$('.mixerPreview img').attr('src', imgSrc);
const motorOutputReorderConfig = new MotorOutputReorderConfig(100);

View file

@ -1,15 +0,0 @@
'use strict';
class CommonUtils
{
static GetMixerImageSrc(mixerIndex, reverseMotorDir, apiVersion)
{
let reverse = "";
if (semver.gte(apiVersion, API_VERSION_1_36)) {
reverse = reverseMotorDir ? "_reversed" : "";
}
return `./resources/motor_order/${mixerList[mixerIndex - 1].image}${reverse}.svg`;
}
}

View file

@ -74,10 +74,20 @@ export function generateVirtualApiVersions() {
firmwareVersionDropdown.appendChild(option);
}
}
export function getMixerImageSrc(mixerIndex, reverseMotorDir, apiVersion)
{
let reverse = "";
if (semver.gte(apiVersion, API_VERSION_1_36)) {
reverse = reverseMotorDir ? "_reversed" : "";
}
return `./resources/motor_order/${mixerList[mixerIndex - 1].image}${reverse}.svg`;
}
// TODO: these are temp binding while transition to module happens
window.degToRad = degToRad;
window.bytesToSize = bytesToSize;
window.checkChromeRuntimeError = checkChromeRuntimeError;
window.generateVirtualApiVersions = generateVirtualApiVersions;
window.millitime = millitime;
window.getMixerImageSrc = getMixerImageSrc;

View file

@ -47,3 +47,5 @@ CSSUtil.prototype.getColorForPercentage = function(percentage, colorTable = null
};
const cssUtil = new CSSUtil();
window.cssUtil = cssUtil;
export default cssUtil;