mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 08:15:22 +03:00
Change mixer
This commit is contained in:
parent
6f3b50d7eb
commit
54820d43c6
3 changed files with 35 additions and 30 deletions
|
@ -32,11 +32,8 @@ export function bytesToSize(bytes) {
|
|||
|
||||
export function checkChromeRuntimeError() {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(
|
||||
`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${
|
||||
new Error().stack
|
||||
}`
|
||||
);
|
||||
console.error(`Chrome API Error: ${chrome.runtime.lastError.message}.\n Traced ${new Error().stack}`);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -54,9 +51,7 @@ const majorFirmwareVersions = {
|
|||
};
|
||||
|
||||
export function generateVirtualApiVersions() {
|
||||
const firmwareVersionDropdown = document.getElementById(
|
||||
"firmware-version-dropdown"
|
||||
);
|
||||
const firmwareVersionDropdown = document.getElementById("firmware-version-dropdown");
|
||||
const max = semver.minor(CONFIGURATOR.API_VERSION_MAX_SUPPORTED);
|
||||
|
||||
for (let i = max; i > 0; i--) {
|
||||
|
@ -94,6 +89,21 @@ export function getTextWidth(text) {
|
|||
return Math.ceil(context.measureText(text).width);
|
||||
}
|
||||
|
||||
export function sortElement(element, keepDown = "DISABLED") {
|
||||
const list = document.querySelector(element);
|
||||
[...list.children]
|
||||
.sort((a, b) => {
|
||||
if (a.innerText === keepDown) {
|
||||
return 1;
|
||||
} else if (b.innerText === keepDown) {
|
||||
return -1;
|
||||
} else {
|
||||
return a.innerText > b.innerText ? 1 : -1;
|
||||
}
|
||||
})
|
||||
.forEach(node => list.appendChild(node));
|
||||
}
|
||||
|
||||
// TODO: these are temp binding while transition to module happens
|
||||
window.degToRad = degToRad;
|
||||
window.bytesToSize = bytesToSize;
|
||||
|
@ -101,3 +111,4 @@ window.checkChromeRuntimeError = checkChromeRuntimeError;
|
|||
window.generateVirtualApiVersions = generateVirtualApiVersions;
|
||||
window.getMixerImageSrc = getMixerImageSrc;
|
||||
window.getTextWidth = getTextWidth;
|
||||
window.sortElement = sortElement;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue