diff --git a/src/js/DarkTheme.js b/src/js/DarkTheme.js index a96beb6e14..227b53ccea 100644 --- a/src/js/DarkTheme.js +++ b/src/js/DarkTheme.js @@ -1,7 +1,5 @@ import $ from "jquery"; -const css_dark = ["./css/dark-theme.css"]; - const DarkTheme = { configSetting: undefined, enabled: false, diff --git a/src/js/TuningSliders.js b/src/js/TuningSliders.js index 201a1ddd20..8849fc159b 100644 --- a/src/js/TuningSliders.js +++ b/src/js/TuningSliders.js @@ -47,8 +47,6 @@ const TuningSliders = { expertMode: false, }; -const D_MAX_RATIO = 0.85; - TuningSliders.initialize = function () { this.PID_DEFAULT = FC.getPidDefaults(); this.FILTER_DEFAULT = FC.getFilterDefaults(); @@ -441,7 +439,7 @@ TuningSliders.updateFormPids = function (updateSlidersOnly = false) { this.updateSlidersWarning(); }; -TuningSliders.calculateNewPids = function (updateSlidersOnly = false) { +TuningSliders.calculateNewPids = function () { // this is the main calculation for PID sliders, inputs are in form of slider position values // values get set both into forms and their respective variables FC.TUNING_SLIDERS.slider_pids_mode = this.sliderPidsMode; diff --git a/src/js/model.js b/src/js/model.js index 78a2bd9bba..e16c6882e8 100644 --- a/src/js/model.js +++ b/src/js/model.js @@ -159,7 +159,7 @@ Model.prototype.optimizeGeometryForCanvas = function (geometry) { const uniqueVertices = []; const updatedFaces = []; - geometry.vertices.forEach((vertex, index) => { + geometry.vertices.forEach((vertex) => { // Round coordinates with configurable tolerance const key = [ Math.round(vertex.x * tolerance) / tolerance, diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index dc02a10300..be31840a98 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -23,8 +23,6 @@ const ledDirectionLetters = ["n", "e", "s", "w", "u", "d"]; // in LSB bit order const ledBaseFunctionLetters = ["c", "f", "a", "l", "s", "g", "r", "p", "e", "u"]; // in LSB bit let ledOverlayLetters = ["t", "y", "o", "b", "v", "i", "w"]; // in LSB bit -const MAX_GYROS = 8; // maximum number of gyros supported by Betaflight - function MspHelper() { const self = this; diff --git a/src/js/msp/debug/msp_queue_monitor.js b/src/js/msp/debug/msp_queue_monitor.js index 28c5fa94c2..30d127de8c 100644 --- a/src/js/msp/debug/msp_queue_monitor.js +++ b/src/js/msp/debug/msp_queue_monitor.js @@ -123,8 +123,8 @@ export class MSPQueueMonitor { return true; }); if (isDuplicate) this.metrics.duplicates++; - } catch (_) { - // best-effort only + } catch { + // Ignore errors in duplicate detection } // Check for queue size peaks diff --git a/src/js/msp/debug/msp_stress_test.js b/src/js/msp/debug/msp_stress_test.js index 63e376b4f4..c99f247b00 100644 --- a/src/js/msp/debug/msp_stress_test.js +++ b/src/js/msp/debug/msp_stress_test.js @@ -276,7 +276,7 @@ export class MSPStressTest { try { await this.msp.promise(code, null); return { error: "Expected timeout but request succeeded" }; - } catch (error) { + } catch { const timeoutTime = performance.now() - startTime; // Test that new requests work after timeout diff --git a/src/js/protocols/WebSocket.js b/src/js/protocols/WebSocket.js index 17b4e8a9cb..3792b4bb5f 100644 --- a/src/js/protocols/WebSocket.js +++ b/src/js/protocols/WebSocket.js @@ -57,7 +57,7 @@ class Websocket extends EventTarget { return new Uint8Array(buffer); } - async connect(path, options) { + async connect(path) { this.address = path; console.log(`${this.logHead} Connecting to ${this.address}`); diff --git a/src/js/protocols/webusbdfu.js b/src/js/protocols/webusbdfu.js index 5aaaec3562..59eff063c7 100644 --- a/src/js/protocols/webusbdfu.js +++ b/src/js/protocols/webusbdfu.js @@ -471,7 +471,7 @@ class WEBUSBDFU_protocol extends EventTarget { }; return memory; }; - const chipInfo = descriptors.map(parseDescriptor).reduce((o, v, i) => { + const chipInfo = descriptors.map(parseDescriptor).reduce((o, v) => { o[v.type.toLowerCase().replace(" ", "_")] = v; return o; }, {}); @@ -500,7 +500,7 @@ class WEBUSBDFU_protocol extends EventTarget { } }) .catch((error) => { - console.log(`${this.logHead} USB controlTransfer IN failed for request: ${request}`); + console.log(`${this.logHead} USB controlTransfer IN failed for request: ${request} (${error})`); callback([], 1); }); } else { @@ -525,7 +525,7 @@ class WEBUSBDFU_protocol extends EventTarget { } }) .catch((error) => { - console.log(`${this.logHead} USB controlTransfer OUT failed for request: ${request}`); + console.log(`${this.logHead} USB controlTransfer OUT failed for request: ${request} (${error})`); }); } } @@ -900,7 +900,7 @@ class WEBUSBDFU_protocol extends EventTarget { const spans_page = hexData.address < page_start && end_address > page_end; if (starts_in_page || ends_in_page || spans_page) { - const idx = erase_pages.findIndex((element, index, array) => { + const idx = erase_pages.findIndex((element) => { return element.sector === i && element.page === j; }); if (idx === -1) { @@ -1161,31 +1161,23 @@ class WEBUSBDFU_protocol extends EventTarget { ? this.transferSize : this.hex.data[reading_block].bytes - bytes_verified; - this.controlTransfer( - "in", - this.request.UPLOAD, - wBlockNum++, - 0, - bytes_to_read, - 0, - (data, code) => { - for (const piece of data) { - this.verify_hex[reading_block].push(piece); - } + this.controlTransfer("in", this.request.UPLOAD, wBlockNum++, 0, bytes_to_read, 0, (data) => { + for (const piece of data) { + this.verify_hex[reading_block].push(piece); + } - address += bytes_to_read; - bytes_verified += bytes_to_read; - bytes_verified_total += bytes_to_read; + address += bytes_to_read; + bytes_verified += bytes_to_read; + bytes_verified_total += bytes_to_read; - // update progress bar - TABS.firmware_flasher.flashProgress( - ((this.hex.bytes_total + bytes_verified_total) / (this.hex.bytes_total * 2)) * 100, - ); + // update progress bar + TABS.firmware_flasher.flashProgress( + ((this.hex.bytes_total + bytes_verified_total) / (this.hex.bytes_total * 2)) * 100, + ); - // verify another page - read(); - }, - ); + // verify another page + read(); + }); } else { if (reading_block < blocks) { // move to another block @@ -1261,7 +1253,7 @@ class WEBUSBDFU_protocol extends EventTarget { this.loadAddress(address, () => { // 'downloading' 0 bytes to the program start address followed by a GETSTATUS is used to trigger DFU exit on STM32 this.controlTransfer("out", this.request.DNLOAD, 0, 0, 0, 0, () => { - this.controlTransfer("in", this.request.GETSTATUS, 0, 0, 6, 0, (data) => { + this.controlTransfer("in", this.request.GETSTATUS, 0, 0, 6, 0, () => { this.cleanup(); }); }); diff --git a/src/js/receiver_msp/receiver_msp.js b/src/js/receiver_msp/receiver_msp.js index 6e13c8b371..f70afe2bba 100644 --- a/src/js/receiver_msp/receiver_msp.js +++ b/src/js/receiver_msp/receiver_msp.js @@ -7,8 +7,6 @@ import $ from "jquery"; // It seems than when node opens a new window, the module "context" is different, so the i18n var is not initialized const i18n = opener.i18n; -const css_dark = ["/css/dark-theme.css"]; - const CHANNEL_MIN_VALUE = 1000; const CHANNEL_MID_VALUE = 1500; const CHANNEL_MAX_VALUE = 2000; @@ -191,7 +189,7 @@ $(".slider", sliderElems).each(function (sliderIndex) { /* * Mouseup handler needs to be bound to the window in order to receive mouseup if mouse leaves window. */ -$(window).on("mouseup", function (e) { +$(window).on("mouseup", function () { $(this).off("mousemove", handleGimbalMouseDrag); }); diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 3592b86af9..a737853e68 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -59,7 +59,7 @@ function disconnectHandler(event) { export function initializeSerialBackend() { $("a.connection_button__link").on("click", connectDisconnect); - EventBus.$on("port-handler:auto-select-serial-device", function (device) { + EventBus.$on("port-handler:auto-select-serial-device", function () { if ( !GUI.connected_to && !GUI.connecting_to && @@ -658,7 +658,7 @@ function onConnect() { // show only appropriate tabs $("#tabs ul.mode-connected li").hide(); $("#tabs ul.mode-connected li") - .filter(function (index) { + .filter(function () { const classes = $(this).attr("class").split(/\s+/); let found = false; diff --git a/src/js/tabs/cli.js b/src/js/tabs/cli.js index ea6ec1ab7c..fb7fe96ac0 100644 --- a/src/js/tabs/cli.js +++ b/src/js/tabs/cli.js @@ -146,7 +146,7 @@ cli.initialize = function (callback) { async function loadFile() { const previewArea = $("#snippetpreviewcontent textarea#preview"); - function executeSnippet(fileName) { + function executeSnippet() { const commands = previewArea.val(); executeCommands(commands); self.GUI.snippetPreviewWindow.close(); @@ -160,7 +160,7 @@ cli.initialize = function (callback) { "cliConfirmSnippetDialogTitle", { fileName: fileName }, ); - $("#snippetpreviewcontent a.confirm").click(() => executeSnippet(fileName)); + $("#snippetpreviewcontent a.confirm").on("click", executeSnippet); } previewArea.val(result); diff --git a/src/js/tabs/firmware_flasher.js b/src/js/tabs/firmware_flasher.js index 637dadfbee..c70565ea14 100644 --- a/src/js/tabs/firmware_flasher.js +++ b/src/js/tabs/firmware_flasher.js @@ -263,7 +263,7 @@ firmware_flasher.initialize = async function (callback) { Object.keys(targets) .sort((a, b) => a.target - b.target) - .forEach(function (target, i) { + .forEach(function (target) { const descriptor = targets[target]; const select_e = $(``); boards_e.append(select_e); @@ -779,11 +779,8 @@ firmware_flasher.initialize = async function (callback) { async function flashHexFirmware(firmware) { const options = {}; - let eraseAll = false; if ($("input.erase_chip").is(":checked") || expertMode_e.is(":not(:checked)")) { options.erase_chip = true; - - eraseAll = true; } const port = PortHandler.portPicker.selectedPort; @@ -992,7 +989,7 @@ firmware_flasher.initialize = async function (callback) { selectFirmware($("option:selected", evt.target).val()); }); - $("a.cloud_build_cancel").on("click", function (evt) { + $("a.cloud_build_cancel").on("click", function () { $("a.cloud_build_cancel").toggleClass("disabled", true); self.cancelBuild = true; }); @@ -1021,7 +1018,7 @@ firmware_flasher.initialize = async function (callback) { } } - $("a.load_remote_file").on("click", async function (evt) { + $("a.load_remote_file").on("click", async function () { if (!self.selectedBoard) { return; } diff --git a/src/js/tabs/landing.js b/src/js/tabs/landing.js index bec13f00fc..e687ae5fae 100644 --- a/src/js/tabs/landing.js +++ b/src/js/tabs/landing.js @@ -17,7 +17,7 @@ landing.initialize = function (callback) { $("#content").load("./tabs/landing.html", () => { function showLang(newLang) { bottomSection = $(".languageSwitcher"); - bottomSection.find("a").each(function (index) { + bottomSection.find("a").each(function () { const element = $(this); const languageSelected = element.attr("lang"); if (newLang == languageSelected) { diff --git a/src/js/tabs/led_strip.js b/src/js/tabs/led_strip.js index ad32f9e410..df53a81eee 100644 --- a/src/js/tabs/led_strip.js +++ b/src/js/tabs/led_strip.js @@ -13,7 +13,7 @@ const led_strip = { directions: ["n", "e", "s", "w", "u", "d"], }; -led_strip.initialize = function (callback, scrollPosition) { +led_strip.initialize = function (callback) { let selectedColorIndex = null; let selectedModeColor = null; const functionTag = ".function-"; @@ -226,7 +226,7 @@ led_strip.initialize = function (callback, scrollPosition) { const colorDefineSliders = $(".colorDefineSliders"); // Color Buttons - $(".colors").on("click", "button", function (e) { + $(".colors").on("click", "button", function () { const that = this; const colorButtons = $(this).parent().find("button"); diff --git a/src/js/tabs/onboard_logging.js b/src/js/tabs/onboard_logging.js index 6998e2c451..0461344ce6 100644 --- a/src/js/tabs/onboard_logging.js +++ b/src/js/tabs/onboard_logging.js @@ -110,7 +110,6 @@ onboard_logging.initialize = function (callback) { const deviceSelect = $(".blackboxDevice select"); const loggingRatesSelect = $(".blackboxRate select"); const debugModeSelect = $(".blackboxDebugMode select"); - const debugFieldsSelect = $(".blackboxDebugFields select"); if (FC.BLACKBOX.supported) { $(".tab-onboard_logging a.save-settings").on("click", async function () { @@ -137,7 +136,7 @@ onboard_logging.initialize = function (callback) { populateLoggingRates(loggingRatesSelect); populateDevices(deviceSelect); populateDebugModes(debugModeSelect); - populateDebugFields(debugFieldsSelect); + populateDebugFields(); deviceSelect .change(function () { @@ -262,7 +261,7 @@ onboard_logging.initialize = function (callback) { }); } - function populateDebugFields(debugFieldsSelect) { + function populateDebugFields() { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) { $(".blackboxDebugFields").show(); @@ -408,6 +407,11 @@ onboard_logging.initialize = function (callback) { loggingStatus = "Dataflash"; } + tracking.sendEvent(tracking.EVENT_CATEGORIES.FLIGHT_CONTROLLER, "DataLogging", { + logSize: FC.DATAFLASH.usedSize, + logStatus: loggingStatus, + }); + if (FC.SDCARD.supported && !sdcardTimer) { // Poll for changes in SD card status sdcardTimer = setTimeout(function () { diff --git a/src/js/tabs/osd.js b/src/js/tabs/osd.js index c9d49cfdaa..fc0ae73235 100644 --- a/src/js/tabs/osd.js +++ b/src/js/tabs/osd.js @@ -26,7 +26,7 @@ const OSD = {}; const positionConfigs = { TL: { label: "Top Left", - coords: (w, h) => ({ + coords: (_w, _h) => ({ x: 1, y: 1, }), @@ -34,7 +34,7 @@ const positionConfigs = { }, TC: { label: "Top Center", - coords: (w, h) => ({ + coords: (w, _h) => ({ x: Math.floor((OSD.data.displaySize.x - w) / 2), y: 1, }), @@ -46,7 +46,7 @@ const positionConfigs = { }, TR: { label: "Top Right", - coords: (w, h) => ({ + coords: (w, _h) => ({ x: Math.max(1, OSD.data.displaySize.x - w - 1), y: 1, }), @@ -59,7 +59,7 @@ const positionConfigs = { // Top-middle row TML: { label: "Top Middle Left", - coords: (w, h) => ({ + coords: (_w, h) => ({ x: 1, y: Math.floor(OSD.data.displaySize.y / 3) - Math.floor(h / 2), }), @@ -96,7 +96,7 @@ const positionConfigs = { // Exact middle row LMC: { label: "Left Middle", - coords: (w, h) => ({ + coords: (_w, h) => ({ x: 1, y: Math.floor((OSD.data.displaySize.y - h) / 2), }), @@ -135,7 +135,7 @@ const positionConfigs = { // Bottom-middle row BML: { label: "Bottom Middle Left", - coords: (w, h) => ({ + coords: (_w, h) => ({ x: 1, y: Math.floor((OSD.data.displaySize.y * 2) / 3) - Math.floor(h / 2), }), @@ -171,7 +171,7 @@ const positionConfigs = { }, BL: { label: "Bottom Left", - coords: (w, h) => ({ + coords: (_w, h) => ({ x: 1, y: OSD.data.displaySize.y - h - 1, }), @@ -3544,7 +3544,11 @@ osd.initialize = function (callback) { OSD.msp.decode(info); } - if (OSD.data.state.haveMax7456FontDeviceConfigured && !OSD.data.state.isMax7456FontDeviceDetected && !OSD.data.state.haveAirbotTheiaOsdDevice) { + if ( + OSD.data.state.haveMax7456FontDeviceConfigured && + !OSD.data.state.isMax7456FontDeviceDetected && + !OSD.data.state.haveAirbotTheiaOsdDevice + ) { $(".noOsdChipDetect").show(); } @@ -3820,7 +3824,10 @@ osd.initialize = function (callback) { $(".requires-max7456").hide(); } - if (!OSD.data.state.isMax7456FontDeviceDetected || (!OSD.data.state.haveMax7456FontDeviceConfigured && !OSD.data.state.haveAirbotTheiaOsdDevice)) { + if ( + !OSD.data.state.isMax7456FontDeviceDetected || + (!OSD.data.state.haveMax7456FontDeviceConfigured && !OSD.data.state.haveAirbotTheiaOsdDevice) + ) { $(".requires-max7456-font-device-detected").addClass("disabled"); } @@ -3890,7 +3897,6 @@ osd.initialize = function (callback) { // display fields on/off and position const $displayFields = $("#element-fields").empty(); - let enabledCount = 0; OSD.data.displaySize.total = OSD.data.displaySize.x * OSD.data.displaySize.y; @@ -3900,10 +3906,6 @@ osd.initialize = function (callback) { continue; } - if (field.isVisible[OSD.getCurrentPreviewProfile()]) { - enabledCount++; - } - const $field_wrapper = $(`
`); const $field = $(``); let desc = null; diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 79f1642794..dd2c097a91 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -2105,7 +2105,7 @@ pid_tuning.initialize = function (callback) { self.analyticsChanges["PidTuningSliders"] = "On"; }); - allPidTuningSliders.each(function (i) { + allPidTuningSliders.each(function () { self.sliderOnScroll($(this)); }); @@ -3318,7 +3318,7 @@ pid_tuning.expertModeChanged = function (expertModeEnabled) { TuningSliders.setExpertMode(expertModeEnabled); }; -pid_tuning.sliderOnScroll = function (slider, e) { +pid_tuning.sliderOnScroll = function (slider) { slider.parent().on("input wheel", function (e) { if (slider.prop("disabled")) { return; diff --git a/src/js/utils/EscProtocols.js b/src/js/utils/EscProtocols.js index c218a78bc0..dd0f393466 100644 --- a/src/js/utils/EscProtocols.js +++ b/src/js/utils/EscProtocols.js @@ -49,7 +49,7 @@ class EscProtocols { return EscProtocols.DSHOT_PROTOCOLS_SET.includes(protocolName); } - static GetAvailableProtocols(apiVersion) { + static GetAvailableProtocols(_apiVersion) { const escProtocols = [ EscProtocols.PROTOCOL_PWM, EscProtocols.PROTOCOL_ONESHOT125, @@ -66,7 +66,7 @@ class EscProtocols { return escProtocols; } - static ReorderPwmProtocols(apiVersion, protocolIndex) { + static ReorderPwmProtocols(_apiVersion, protocolIndex) { return protocolIndex; } } diff --git a/src/js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js b/src/js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js index 8a0af8f834..fc7f8c2e94 100644 --- a/src/js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js +++ b/src/js/utils/VtxDeviceStatus/SmartAudioDeviceStatus.js @@ -14,7 +14,6 @@ class VtxDeviceStatusSmartAudio extends VtxDeviceStatus { } get smartAudioVersion() { - const sa = this._version * 100 + this._mode; let result = ""; switch (this._version) { diff --git a/src/js/utils/common.js b/src/js/utils/common.js index 265cd15387..51798f9ca7 100644 --- a/src/js/utils/common.js +++ b/src/js/utils/common.js @@ -61,7 +61,7 @@ export function urlExists(url) { * @return {object} sorted option list. */ -$.fn.sortSelect = function (text = "") { +$.fn.sortSelect = function () { /* Chrome v140 does not work with sortSelect function properly. diff --git a/src/js/utils/three/CanvasRenderer.js b/src/js/utils/three/CanvasRenderer.js index f6291d4d5b..095e3d6425 100644 --- a/src/js/utils/three/CanvasRenderer.js +++ b/src/js/utils/three/CanvasRenderer.js @@ -551,7 +551,7 @@ class CanvasRenderer { ); grad.addColorStop(0, colorStyle1); grad.addColorStop(1, colorStyle2); - } catch (exception) { + } catch { grad = colorStyle1; } diff --git a/src/js/utils/three/Projector.js b/src/js/utils/three/Projector.js index 074c35d89d..ea73c3d2ad 100644 --- a/src/js/utils/three/Projector.js +++ b/src/js/utils/three/Projector.js @@ -133,13 +133,13 @@ class Projector { let uvs = []; let object = null; - let material = null; + let _material = null; let normalMatrix = new THREE.Matrix3(); function setObject(value) { object = value; - material = object.material; + _material = object.material; normalMatrix.getNormalMatrix(object.matrixWorld); diff --git a/src/tabs/presets/SourcesDialog/SourcesDialog.js b/src/tabs/presets/SourcesDialog/SourcesDialog.js index 0500164460..592ce8bf2d 100644 --- a/src/tabs/presets/SourcesDialog/SourcesDialog.js +++ b/src/tabs/presets/SourcesDialog/SourcesDialog.js @@ -66,7 +66,7 @@ export default class PresetsSourcesDialog { return sources; } - _readActiveSourceIndexFromStorage(sourcesCount) { + _readActiveSourceIndexFromStorage() { const obj = getConfig("PresetSourcesActiveIndexes"); return obj.PresetSourcesActiveIndexes || [0]; } diff --git a/src/tabs/presets/presets.js b/src/tabs/presets/presets.js index ed9c64848c..01b582d005 100644 --- a/src/tabs/presets/presets.js +++ b/src/tabs/presets/presets.js @@ -375,7 +375,7 @@ presets.tryLoadPresets = function () { const failedToLoad = []; - Promise.all(this.presetsRepo.map((p) => p.loadIndex().catch((reason) => failedToLoad.push(p)))) + Promise.all(this.presetsRepo.map((p) => p.loadIndex().catch(() => failedToLoad.push(p)))) .then(() => { this._domWarningFailedToLoadRepositories.toggle(failedToLoad.length > 0); this._domWarningFailedToLoadRepositories.html(