mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-26 01:35:28 +03:00
Fix critical and major bugs from Sonar in JS files (#1804)
Fix critical and major bugs from Sonar in JS files
This commit is contained in:
commit
e69c904730
8 changed files with 111 additions and 115 deletions
|
@ -11,7 +11,6 @@
|
|||
|
||||
|
||||
.dropdown {
|
||||
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
@ -26,14 +25,10 @@
|
|||
width:99%;
|
||||
margin-bottom:7px;
|
||||
border: 1px solid;
|
||||
border-color: #ccc #ccc #ccc;
|
||||
border-color: #ccc #ccc #ccc;
|
||||
border-radius: 3px;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
.dropdown:before, .dropdown:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
|
@ -46,12 +41,14 @@
|
|||
border-color: #888 transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.dropdown:before {
|
||||
border-bottom-style: solid;
|
||||
border-top: none;
|
||||
margin-top: -2px;
|
||||
|
||||
}
|
||||
|
||||
.dropdown:after {
|
||||
margin-top: 5px;
|
||||
border-top-style: solid;
|
||||
|
@ -63,7 +60,6 @@
|
|||
overflow:visible;
|
||||
width: 100%;
|
||||
margin-top:0px;
|
||||
padding-bottom:0px;
|
||||
padding: 1px 8px 6px 5px;
|
||||
height: 23px;
|
||||
line-height: 20px;
|
||||
|
@ -77,9 +73,8 @@
|
|||
border: 0;
|
||||
border-radius: 0;
|
||||
-webkit-appearance: none;
|
||||
|
||||
|
||||
}
|
||||
|
||||
.dropdown-select:focus {
|
||||
z-index: 3;
|
||||
width: 90%;
|
||||
|
@ -87,9 +82,9 @@
|
|||
outline: 0px solid #49aff2;
|
||||
outline: 0px solid -webkit-focus-ring-color;
|
||||
outline-offset: 5px;
|
||||
|
||||
height:25px;
|
||||
}
|
||||
|
||||
.dropdown-select > option {
|
||||
margin: 3px;
|
||||
padding: 6px 8px;
|
||||
|
@ -104,17 +99,18 @@
|
|||
.lt-ie9 .dropdown {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.lt-ie9 .dropdown-select {
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.lt-ie9 .dropdown-select:focus {
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.dropdown-dark {
|
||||
background: #636363; /* NEW2 */
|
||||
background: #636363; /* NEW2 */
|
||||
background: #3e403f; /* NEW */
|
||||
|
||||
border-color: #111 #0a0a0a black;
|
||||
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.4));
|
||||
background-image: -moz-linear-gradient(top, transparent, rgba(0, 0, 0, 0.4));
|
||||
|
@ -123,28 +119,28 @@
|
|||
-webkit-box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
box-shadow: inset 0 1px rgba(255, 255, 255, 0.1), 0 1px 1px rgba(0, 0, 0, 0.2);
|
||||
color:#a6a6a6;
|
||||
text-shadow:0px 1px rgba(0, 0, 0, 0.25);
|
||||
|
||||
|
||||
|
||||
|
||||
text-shadow:0px 1px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.dropdown-dark:before {
|
||||
border-bottom-color: #aaa;
|
||||
}
|
||||
|
||||
.dropdown-dark:after {
|
||||
border-top-color: #aaa;
|
||||
}
|
||||
|
||||
.dropdown-dark .dropdown-select {
|
||||
color: #a6a6a6;
|
||||
text-shadow: 0 1px black;
|
||||
/* Fallback for IE 8 */
|
||||
background: #444;
|
||||
|
||||
}
|
||||
|
||||
.dropdown-dark .dropdown-select:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dropdown-dark .dropdown-select > option {
|
||||
background: #56ab1a;
|
||||
text-shadow: 0 1px rgba(0, 0, 0, 0.4);
|
||||
|
|
|
@ -694,7 +694,6 @@
|
|||
|
||||
.tabarea {
|
||||
width: calc(100% - 22px);
|
||||
padding-left: 10px;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
border: 1px solid var(--subtleAccent);
|
||||
|
|
|
@ -54,7 +54,7 @@ CliAutoComplete.initialize = function($textarea, sendLine, writeToOutput) {
|
|||
analytics.sendEvent(analytics.EVENT_CATEGORIES.APPLICATION, 'CliAutoComplete', this.configEnabled);
|
||||
|
||||
this.$textarea = $textarea;
|
||||
this.forceOpen = false,
|
||||
this.forceOpen = false;
|
||||
this.sendLine = sendLine;
|
||||
this.writeToOutput = writeToOutput;
|
||||
this.cleanup();
|
||||
|
|
|
@ -8,9 +8,9 @@ var GUI_control = function () {
|
|||
this.connecting_to = false;
|
||||
this.connected_to = false;
|
||||
this.connect_lock = false;
|
||||
this.active_tab;
|
||||
this.active_tab = null;
|
||||
this.tab_switch_in_progress = false;
|
||||
this.operating_system;
|
||||
this.operating_system = null;
|
||||
this.interval_array = [];
|
||||
this.timeout_array = [];
|
||||
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
'use strict';
|
||||
|
||||
var STM32_protocol = function () {
|
||||
this.baud;
|
||||
this.baud = null;
|
||||
this.options = {};
|
||||
this.callback; // ref
|
||||
this.hex; // ref
|
||||
this.verify_hex;
|
||||
this.callback = null;
|
||||
this.hex = null;
|
||||
this.verify_hex = [];
|
||||
|
||||
this.receive_buffer;
|
||||
this.receive_buffer = [];
|
||||
|
||||
this.bytes_to_read = 0; // ref
|
||||
this.read_callback; // ref
|
||||
this.bytes_to_read = 0;
|
||||
this.read_callback = null;
|
||||
|
||||
this.upload_time_start;
|
||||
this.upload_process_alive;
|
||||
this.upload_time_start = 0;
|
||||
this.upload_process_alive = false;
|
||||
|
||||
this.msp_connector = new MSPConnectorImpl();
|
||||
|
||||
|
@ -282,18 +282,18 @@ STM32_protocol.prototype.retrieve = function (n_bytes, callback) {
|
|||
}
|
||||
};
|
||||
|
||||
// Array = array of bytes that will be send over serial
|
||||
// bytes_to_send = array of bytes that will be send over serial
|
||||
// bytes_to_read = received bytes necessary to trigger read_callback
|
||||
// callback = function that will be executed after received bytes = bytes_to_read
|
||||
STM32_protocol.prototype.send = function (Array, bytes_to_read, callback) {
|
||||
STM32_protocol.prototype.send = function (bytes_to_send, bytes_to_read, callback) {
|
||||
// flip flag
|
||||
this.upload_process_alive = true;
|
||||
|
||||
var bufferOut = new ArrayBuffer(Array.length);
|
||||
var bufferOut = new ArrayBuffer(bytes_to_send.length);
|
||||
var bufferView = new Uint8Array(bufferOut);
|
||||
|
||||
// set Array values inside bufferView (alternative to for loop)
|
||||
bufferView.set(Array);
|
||||
// set bytes_to_send values inside bufferView (alternative to for loop)
|
||||
bufferView.set(bytes_to_send);
|
||||
|
||||
// update references
|
||||
this.bytes_to_read = bytes_to_read;
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
'use strict';
|
||||
|
||||
var STM32DFU_protocol = function () {
|
||||
this.callback; // ref
|
||||
this.hex; // ref
|
||||
this.verify_hex;
|
||||
this.callback = null;
|
||||
this.hex = null;
|
||||
this.verify_hex = [];
|
||||
|
||||
this.handle = null; // connection handle
|
||||
|
||||
|
|
|
@ -277,7 +277,7 @@ OSD.getNumberOfProfiles = function() {
|
|||
|
||||
OSD.getCurrentPreviewProfile = function() {
|
||||
let osdprofile_e = $('.osdprofile-selector');
|
||||
if (osdprofile_e) {
|
||||
if (osdprofile_e.length > 0) {
|
||||
return osdprofile_e.val();
|
||||
} else {
|
||||
return 0;
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
TABS.servos = {};
|
||||
TABS.servos.initialize = function (callback) {
|
||||
var self = this;
|
||||
|
||||
if (GUI.active_tab != 'servos') {
|
||||
if (GUI.active_tab !== 'servos') {
|
||||
GUI.active_tab = 'servos';
|
||||
}
|
||||
|
||||
|
@ -31,7 +30,7 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
function update_ui() {
|
||||
|
||||
if (semver.lt(CONFIG.apiVersion, "1.12.0") || SERVO_CONFIG.length == 0) {
|
||||
if (semver.lt(CONFIG.apiVersion, "1.12.0") || SERVO_CONFIG.length === 0) {
|
||||
|
||||
$(".tab-servos").removeClass("supported");
|
||||
return;
|
||||
|
@ -39,16 +38,16 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
$(".tab-servos").addClass("supported");
|
||||
|
||||
var servoCheckbox = '';
|
||||
var servoHeader = '';
|
||||
for (var i = 0; i < RC.active_channels-4; i++) {
|
||||
let servoCheckbox = '';
|
||||
let servoHeader = '';
|
||||
for (let i = 0; i < RC.active_channels-4; i++) {
|
||||
servoHeader = servoHeader + '\
|
||||
<th >A' + (i+1) + '</th>\
|
||||
';
|
||||
}
|
||||
servoHeader = servoHeader + '<th style="width: 110px" i18n="servosDirectionAndRate"></th>';
|
||||
|
||||
for (var i = 0; i < RC.active_channels; i++) {
|
||||
for (let i = 0; i < RC.active_channels; i++) {
|
||||
servoCheckbox = servoCheckbox + '\
|
||||
<td class="channel"><input type="checkbox"/></td>\
|
||||
';
|
||||
|
@ -56,7 +55,7 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
$('div.tab-servos table.fields tr.main').append(servoHeader);
|
||||
|
||||
function process_servos(name, alternate, obj) {
|
||||
function process_servos(name, obj) {
|
||||
|
||||
$('div.supported_wrapper').show();
|
||||
|
||||
|
@ -81,9 +80,9 @@ TABS.servos.initialize = function (callback) {
|
|||
<select class="rate" name="rate"></select>\
|
||||
');
|
||||
|
||||
var select = $('div.tab-servos table.fields tr:last td.direction select');
|
||||
const select = $('div.tab-servos table.fields tr:last td.direction select');
|
||||
|
||||
for (var i = 100; i > -101; i--) {
|
||||
for (let i = 100; i > -101; i--) {
|
||||
select.append('<option value="' + i + '">Rate: ' + i + '%</option>');
|
||||
}
|
||||
|
||||
|
@ -104,12 +103,12 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
function servos_update(save_configuration_to_eeprom) {
|
||||
$('div.tab-servos table.fields tr:not(".main")').each(function () {
|
||||
var info = $(this).data('info');
|
||||
const info = $(this).data('info');
|
||||
|
||||
|
||||
var selection = $('.channel input', this);
|
||||
var channelIndex = parseInt(selection.index(selection.filter(':checked')));
|
||||
if (channelIndex == -1) {
|
||||
const selection = $('.channel input', this);
|
||||
let channelIndex = parseInt(selection.index(selection.filter(':checked')));
|
||||
if (channelIndex === -1) {
|
||||
channelIndex = undefined;
|
||||
}
|
||||
|
||||
|
@ -120,7 +119,7 @@ TABS.servos.initialize = function (callback) {
|
|||
SERVO_CONFIG[info.obj].min = parseInt($('.min input', this).val());
|
||||
SERVO_CONFIG[info.obj].max = parseInt($('.max input', this).val());
|
||||
|
||||
var val = parseInt($('.direction select', this).val());
|
||||
const val = parseInt($('.direction select', this).val());
|
||||
SERVO_CONFIG[info.obj].rate = val;
|
||||
});
|
||||
|
||||
|
@ -146,8 +145,8 @@ TABS.servos.initialize = function (callback) {
|
|||
// drop previous table
|
||||
$('div.tab-servos table.fields tr:not(:first)').remove();
|
||||
|
||||
for (var servoIndex = 0; servoIndex < 8; servoIndex++) {
|
||||
process_servos('Servo ' + servoIndex, '', servoIndex, false);
|
||||
for (let servoIndex = 0; servoIndex < 8; servoIndex++) {
|
||||
process_servos('Servo ' + servoIndex, servoIndex);
|
||||
}
|
||||
|
||||
// UI hooks for dynamically generated elements
|
||||
|
@ -181,5 +180,7 @@ TABS.servos.initialize = function (callback) {
|
|||
};
|
||||
|
||||
TABS.servos.cleanup = function (callback) {
|
||||
if (callback) callback();
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue