diff --git a/.eslintrc.js b/.eslintrc.js
index 815a29a7..428fdcbc 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -17,5 +17,7 @@ module.exports = {
semi: "error",
"comma-dangle": ["error", "always-multiline"],
"no-var": "error",
+ "prefer-template": "error",
+ "template-curly-spacing": "error",
},
};
diff --git a/gulp-appdmg.js b/gulp-appdmg.js
index def0222e..f3128c79 100644
--- a/gulp-appdmg.js
+++ b/gulp-appdmg.js
@@ -14,7 +14,7 @@ module.exports = function(options) {
const ee = appdmg(options);
ee.on('progress', function(info) {
- gutil.log(info.current + '/' + info.total + ' ' + info.type + ' ' + (info.title || info.status));
+ gutil.log(`${info.current}/${info.total} ${info.type} ${info.title || info.status}`);
});
ee.on('error', function(err) {
diff --git a/src/js/Analytics.js b/src/js/Analytics.js
index 2c06f74e..b4a718c1 100644
--- a/src/js/Analytics.js
+++ b/src/js/Analytics.js
@@ -21,7 +21,7 @@ const Analytics = function (trackingId, userId, appName, appVersion, gitRevision
this._googleAnalytics.set('checkProtocolTask', null);
this._googleAnalytics.set('appName', appName);
- this._googleAnalytics.set('appVersion', debugMode ? appVersion + '-debug' : appVersion);
+ this._googleAnalytics.set('appVersion', debugMode ? `${appVersion}-debug` : appVersion);
this.EVENT_CATEGORIES = {
APPLICATION: 'Application',
@@ -130,7 +130,7 @@ Analytics.prototype.sendException = function (message) {
};
Analytics.prototype.setOptOut = function (optOut) {
- window['ga-disable-' + this._trackingId] = !!optOut;
+ window[`ga-disable-${this._trackingId}`] = !!optOut;
};
Analytics.prototype._rebuildFlightControllerEvent = function () {
diff --git a/src/js/CliAutoComplete.js b/src/js/CliAutoComplete.js
index 31df997c..5e4b08b8 100644
--- a/src/js/CliAutoComplete.js
+++ b/src/js/CliAutoComplete.js
@@ -103,7 +103,7 @@ CliAutoComplete.builderStart = function() {
};
this.builder.commandSequence = ['help', 'dump', 'get', 'mixer list'];
this.builder.currentSetting = null;
- this.builder.sentinel = '# ' + Math.random();
+ this.builder.sentinel = `# ${Math.random()}`;
this.builder.state = 'init';
this.writeToOutput('
# Building AutoComplete Cache ... ');
this.sendLine(this.builder.sentinel);
@@ -123,7 +123,7 @@ CliAutoComplete.builderParseLine = function(line) {
if (command && this.configEnabled) {
// next state
- builder.state = 'parse-' + command;
+ builder.state = `parse-${command}`;
this.sendLine(command);
this.sendLine(builder.sentinel);
} else {
@@ -398,7 +398,7 @@ CliAutoComplete._initTextcomplete = function() {
value = this.value;
}
- return '$1 = ' + value; // cosmetic - make sure we have spaces around the `=`
+ return `$1 = ${value}`; // cosmetic - make sure we have spaces around the `=`
},
index: 3,
isSettingValueArray: false,
diff --git a/src/js/ConfigInserter.js b/src/js/ConfigInserter.js
index cc59ea6a..5976656f 100644
--- a/src/js/ConfigInserter.js
+++ b/src/js/ConfigInserter.js
@@ -59,7 +59,7 @@ function generateData(firmware, input, startAddress) {
}
// Add 0 terminator
- input = input + '\0';
+ input = `${input}\0`;
let inputIndex = 0;
while (inputIndex < input.length) {
diff --git a/src/js/DarkTheme.js b/src/js/DarkTheme.js
index 35cc3836..40784bce 100644
--- a/src/js/DarkTheme.js
+++ b/src/js/DarkTheme.js
@@ -57,9 +57,9 @@ DarkTheme.setConfig = function (result) {
};
DarkTheme.applyDark = function () {
- css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', false));
+ css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', false));
};
DarkTheme.applyNormal = function () {
- css_dark.forEach((el) => $('link[href="' + el + '"]').prop('disabled', true));
+ css_dark.forEach((el) => $(`link[href="${el}"]`).prop('disabled', true));
};
diff --git a/src/js/FirmwareCache.js b/src/js/FirmwareCache.js
index ff941a15..24e9ccb3 100644
--- a/src/js/FirmwareCache.js
+++ b/src/js/FirmwareCache.js
@@ -104,7 +104,7 @@ let FirmwareCache = (function () {
* @returns {string} A key for storing cached data for a release
*/
function withCachePrefix(key) {
- return "cache:" + key;
+ return `cache:${key}`;
}
/**
@@ -133,7 +133,7 @@ let FirmwareCache = (function () {
}
let key = keyOf(release);
if (has(release)) {
- console.debug("Firmware is already cached: " + key);
+ console.debug(`Firmware is already cached: ${key}`);
return;
}
journal.set(key, true);
@@ -159,7 +159,7 @@ let FirmwareCache = (function () {
}
let key = keyOf(release);
if (!has(release)) {
- console.debug("Firmware is not cached: " + key);
+ console.debug(`Firmware is not cached: ${key}`);
return;
}
let cacheKey = withCachePrefix(key);
@@ -208,7 +208,7 @@ let FirmwareCache = (function () {
if (typeof onPutToCacheCallback === "function") {
onPutToCacheCallback(release);
}
- console.info("Release put to cache: " + keyOf(release));
+ console.info(`Release put to cache: ${keyOf(release)}`);
}
/**
@@ -218,7 +218,7 @@ let FirmwareCache = (function () {
if (typeof onRemoveFromCacheCallback === "function") {
onRemoveFromCacheCallback(release);
}
- console.debug("Cache data removed: " + keyOf(release));
+ console.debug(`Cache data removed: ${keyOf(release)}`);
}
/**
@@ -231,7 +231,7 @@ let FirmwareCache = (function () {
}
journal.assign(pairs);
journalLoaded = true;
- console.info("Firmware cache journal loaded; number of entries: " + entries.length);
+ console.info(`Firmware cache journal loaded; number of entries: ${entries.length}`);
}
return {
diff --git a/src/js/LogoManager.js b/src/js/LogoManager.js
index 5dfc1ea1..8f9c48f6 100644
--- a/src/js/LogoManager.js
+++ b/src/js/LogoManager.js
@@ -179,8 +179,8 @@ LogoManager.init = function (font, logoStartIndex) {
this.logoStartIndex = logoStartIndex;
// inject logo size variables for dynamic translation strings
i18n.addResources({
- logoWidthPx: "" + this.constraints.imageSize.expectedWidth, // NOSONAR
- logoHeightPx: "" + this.constraints.imageSize.expectedHeight, // NOSONAR
+ logoWidthPx: `${this.constraints.imageSize.expectedWidth}`, // NOSONAR
+ logoHeightPx: `${this.constraints.imageSize.expectedHeight}`, // NOSONAR
});
// find/cache DOM elements
Object.keys(this.elements).forEach(key => {
diff --git a/src/js/backup_restore.js b/src/js/backup_restore.js
index 0217a3cb..94fb3f5b 100644
--- a/src/js/backup_restore.js
+++ b/src/js/backup_restore.js
@@ -8,7 +8,7 @@ function configuration_backup(callback) {
let version = CONFIGURATOR.version;
if (version.indexOf(".") === -1) {
- version = version + ".0.0";
+ version = `${version}.0.0`;
}
const configuration = {
@@ -211,7 +211,7 @@ function configuration_backup(callback) {
const filename = generateFilename(prefix, suffix);
const accepts = [{
- description: suffix.toUpperCase() + ' files', extensions: [suffix],
+ description: `${suffix.toUpperCase()} files`, extensions: [suffix],
}];
// create or load the file
@@ -229,7 +229,7 @@ function configuration_backup(callback) {
// echo/console log path specified
chrome.fileSystem.getDisplayPath(chosenFileEntry, function (path) {
- console.log('Backup file path: ' + path);
+ console.log(`Backup file path: ${path}`);
});
// change file entry from read only to read/write
@@ -300,7 +300,7 @@ function configuration_restore(callback) {
// echo/console log path specified
chrome.fileSystem.getDisplayPath(chosenFileEntry, function (path) {
- console.log('Restore file path: ' + path);
+ console.log(`Restore file path: ${path}`);
});
// read contents into variable
diff --git a/src/js/gui.js b/src/js/gui.js
index 27559456..d3e30c86 100644
--- a/src/js/gui.js
+++ b/src/js/gui.js
@@ -487,7 +487,7 @@ GuiControl.prototype.showInformationDialog = function(informationDialogSettings)
GuiControl.prototype.saveToTextFileDialog = function(textToSave, suggestedFileName, extension) {
return new Promise((resolve, reject) => {
- const accepts = [{ description: extension.toUpperCase() + ' files', extensions: [extension] }];
+ const accepts = [{ description: `${extension.toUpperCase()} files`, extensions: [extension] }];
chrome.fileSystem.chooseEntry(
{
@@ -535,7 +535,7 @@ GuiControl.prototype._saveToTextFileDialogFileSelected = function(entry, textToS
GuiControl.prototype.readTextFileDialog = function(extension) {
- const accepts = [{ description: extension.toUpperCase() + ' files', extensions: [extension] }];
+ const accepts = [{ description: `${extension.toUpperCase()} files`, extensions: [extension] }];
return new Promise(resolve => {
chrome.fileSystem.chooseEntry({type: 'openFile', accepts: accepts}, function(entry) {
diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js
index 4309c4ea..86d40997 100644
--- a/src/js/msp/MSPHelper.js
+++ b/src/js/msp/MSPHelper.js
@@ -810,7 +810,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
case MSPCodes.MSP_API_VERSION:
FC.CONFIG.mspProtocolVersion = data.readU8();
- FC.CONFIG.apiVersion = data.readU8() + '.' + data.readU8() + '.0';
+ FC.CONFIG.apiVersion = `${data.readU8()}.${data.readU8()}.0`;
break;
case MSPCodes.MSP_FC_VARIANT:
@@ -822,7 +822,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
case MSPCodes.MSP_FC_VERSION:
- FC.CONFIG.flightControllerVersion = data.readU8() + '.' + data.readU8() + '.' + data.readU8();
+ FC.CONFIG.flightControllerVersion = `${data.readU8()}.${data.readU8()}.${data.readU8()}`;
break;
case MSPCodes.MSP_BUILD_INFO:
@@ -1741,9 +1741,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
break;
default:
- console.log('Unknown code detected: ' + code);
+ console.log(`Unknown code detected: ${code}`);
} else {
- console.log('FC reports unsupported message error: ' + code);
+ console.log(`FC reports unsupported message error: ${code}`);
if (code === MSPCodes.MSP_SET_REBOOT) {
TABS.onboard_logging.mscRebootFailedCallback();
@@ -2507,12 +2507,12 @@ MspHelper.prototype.dataflashRead = function(address, blockSize, onDataCallback)
}
} else {
// Report address error
- console.log('Expected address ' + address + ' but received ' + chunkAddress + ' - retrying');
+ console.log(`Expected address ${address} but received ${chunkAddress} - retrying`);
onDataCallback(address, null); // returning null to the callback forces a retry
}
} else {
// Report crc error
- console.log('CRC error for address ' + address + ' - retrying');
+ console.log(`CRC error for address ${address} - retrying`);
onDataCallback(address, null); // returning null to the callback forces a retry
}
}, true);
diff --git a/src/js/protocols/stm32.js b/src/js/protocols/stm32.js
index 000f1ed4..28655eb2 100644
--- a/src/js/protocols/stm32.js
+++ b/src/js/protocols/stm32.js
@@ -407,7 +407,7 @@ STM32_protocol.prototype.verify_chip_signature = function (signature) {
if (this.hex.bytes_total < this.available_flash_size) {
return true;
} else {
- console.log('Supplied hex is bigger then flash available on the chip, HEX: ' + this.hex.bytes_total + ' bytes, limit = ' + this.available_flash_size + ' bytes');
+ console.log(`Supplied hex is bigger then flash available on the chip, HEX: ${this.hex.bytes_total} bytes, limit = ${this.available_flash_size} bytes`);
return false;
}
}
diff --git a/src/js/protocols/stm32usbdfu.js b/src/js/protocols/stm32usbdfu.js
index 44d6574b..cfa2d5e2 100644
--- a/src/js/protocols/stm32usbdfu.js
+++ b/src/js/protocols/stm32usbdfu.js
@@ -95,7 +95,7 @@ STM32DFU_protocol.prototype.connect = function (device, hex, options, callback)
chrome.usb.getDevices(device, function (result) {
if (result.length) {
- console.log('USB DFU detected with ID: ' + result[0].device);
+ console.log(`USB DFU detected with ID: ${result[0].device}`);
self.openDevice(result[0]);
} else {
@@ -121,7 +121,7 @@ STM32DFU_protocol.prototype.openDevice = function (device) {
self.handle = handle;
GUI.log(i18n.getMessage('usbDeviceOpened', handle.handle.toString()));
- console.log('Device opened with Handle ID: ' + handle.handle);
+ console.log(`Device opened with Handle ID: ${handle.handle}`);
self.claimInterface(0);
});
};
@@ -136,7 +136,7 @@ STM32DFU_protocol.prototype.closeDevice = function () {
}
GUI.log(i18n.getMessage('usbDeviceClosed'));
- console.log('Device closed with Handle ID: ' + self.handle.handle);
+ console.log(`Device closed with Handle ID: ${self.handle.handle}`);
self.handle = null;
});
@@ -154,7 +154,7 @@ STM32DFU_protocol.prototype.claimInterface = function (interfaceNumber) {
self.cleanup();
}
- console.log('Claimed interface: ' + interfaceNumber);
+ console.log(`Claimed interface: ${interfaceNumber}`);
if (self.options.exitDfu) {
self.leave();
@@ -168,7 +168,7 @@ STM32DFU_protocol.prototype.releaseInterface = function (interfaceNumber) {
const self = this;
chrome.usb.releaseInterface(this.handle, interfaceNumber, function released() {
- console.log('Released interface: ' + interfaceNumber);
+ console.log(`Released interface: ${interfaceNumber}`);
self.closeDevice();
});
@@ -176,7 +176,7 @@ STM32DFU_protocol.prototype.releaseInterface = function (interfaceNumber) {
STM32DFU_protocol.prototype.resetDevice = function (callback) {
chrome.usb.resetDevice(this.handle, function (result) {
- console.log('Reset Device: ' + result);
+ console.log(`Reset Device: ${result}`);
if (callback) callback();
});
@@ -195,7 +195,7 @@ STM32DFU_protocol.prototype.getString = function (index, callback) {
'length': 255, // max length to retreive
}, function (result) {
if (checkChromeRuntimeError()) {
- console.log('USB getString failed! ' + result.resultCode);
+ console.log(`USB getString failed! ${result.resultCode}`);
callback("", result.resultCode);
return;
}
@@ -264,7 +264,7 @@ STM32DFU_protocol.prototype.getInterfaceDescriptor = function (_interface, callb
'length': 18 + _interface * 9,
}, function (result) {
if (checkChromeRuntimeError()) {
- console.log('USB getInterfaceDescriptor failed! ' + result.resultCode);
+ console.log(`USB getInterfaceDescriptor failed! ${result.resultCode}`);
callback({}, result.resultCode);
return;
}
@@ -298,7 +298,7 @@ STM32DFU_protocol.prototype.getFunctionalDescriptor = function (_interface, call
'length': 255,
}, function (result) {
if (checkChromeRuntimeError()) {
- console.log('USB getFunctionalDescriptor failed! ' + result.resultCode);
+ console.log(`USB getFunctionalDescriptor failed! ${result.resultCode}`);
callback({}, result.resultCode);
return;
}
@@ -360,7 +360,7 @@ STM32DFU_protocol.prototype.getChipInfo = function (_interface, callback) {
// support option bytes.
if (tmp1.length > 3) {
- console.log('parseDescriptor: shrinking long descriptor "' + str + '"');
+ console.log(`parseDescriptor: shrinking long descriptor "${str}"`);
tmp1.length = 3;
}
if (!tmp1[0].startsWith("@")) {
@@ -446,9 +446,9 @@ STM32DFU_protocol.prototype.controlTransfer = function (direction, request, valu
'timeout': timeout,
}, function (result) {
if (checkChromeRuntimeError()) {
- console.log('USB controlTransfer IN failed for request ' + request + '!');
+ console.log(`USB controlTransfer IN failed for request ${request}!`);
}
- if (result.resultCode) console.log('USB transfer result code: ' + result.resultCode);
+ if (result.resultCode) console.log(`USB transfer result code: ${result.resultCode}`);
var buf = new Uint8Array(result.data);
callback(buf, result.resultCode);
@@ -474,9 +474,9 @@ STM32DFU_protocol.prototype.controlTransfer = function (direction, request, valu
'timeout': timeout,
}, function (result) {
if (checkChromeRuntimeError()) {
- console.log('USB controlTransfer OUT failed for request ' + request + '!');
+ console.log(`USB controlTransfer OUT failed for request ${request}!`);
}
- if (result.resultCode) console.log('USB transfer result code: ' + result.resultCode);
+ if (result.resultCode) console.log(`USB transfer result code: ${result.resultCode}`);
callback(result);
});
@@ -542,12 +542,12 @@ STM32DFU_protocol.prototype.loadAddress = function (address, callback, abort) {
STM32DFU_protocol.prototype.verify_flash = function (first_array, second_array) {
for (var i = 0; i < first_array.length; i++) {
if (first_array[i] != second_array[i]) {
- console.log('Verification failed on byte: ' + i + ' expected: 0x' + first_array[i].toString(16) + ' received: 0x' + second_array[i].toString(16));
+ console.log(`Verification failed on byte: ${i} expected: 0x${first_array[i].toString(16)} received: 0x${second_array[i].toString(16)}`);
return false;
}
}
- console.log('Verification successful, matching: ' + first_array.length + ' bytes');
+ console.log(`Verification successful, matching: ${first_array.length} bytes`);
return true;
};
@@ -600,7 +600,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
case 0:
self.getChipInfo(0, function (chipInfo, resultCode) {
if (resultCode != 0 || typeof chipInfo === "undefined") {
- console.log('Failed to detect chip info, resultCode: ' + resultCode);
+ console.log(`Failed to detect chip info, resultCode: ${resultCode}`);
self.cleanup();
} else {
let nextAction;
@@ -643,7 +643,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
} else {
self.getFunctionalDescriptor(0, function (descriptor, resultCode) {
self.transferSize = resultCode ? 2048 : descriptor.wTransferSize;
- console.log('Using transfer size: ' + self.transferSize);
+ console.log(`Using transfer size: ${self.transferSize}`);
self.clearStatus(function () {
self.upload_procedure(nextAction);
});
@@ -717,7 +717,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// the following should fail if read protection is active
self.controlTransfer('in', self.request.UPLOAD, 2, 0, self.chipInfo.option_bytes.total_size, 0, function (ob_data, errcode) {
if(errcode) {
- console.log('USB transfer error while reading option bytes: ' + errcode1);
+ console.log(`USB transfer error while reading option bytes: ${errcode1}`);
self.cleanup();
return;
}
@@ -853,8 +853,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.flash_layout.sectors[erase_pages[page].sector].start_address;
var cmd = [0x41, page_addr & 0xff, (page_addr >> 8) & 0xff, (page_addr >> 16) & 0xff, (page_addr >> 24) & 0xff];
total_erased += self.flash_layout.sectors[erase_pages[page].sector].page_size;
- console.log('Erasing. sector ' + erase_pages[page].sector +
- ', page ' + erase_pages[page].page + ' @ 0x' + page_addr.toString(16));
+ console.log(`Erasing. sector ${erase_pages[page].sector
+ }, page ${erase_pages[page].page} @ 0x${page_addr.toString(16)}`);
self.controlTransfer('out', self.request.DNLOAD, 0, 0, 0, cmd, function () {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data) {
@@ -882,7 +882,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (data[4] == self.state.dfuIDLE) {
erase_page_next();
} else {
- console.log('Failed to erase page 0x' + page_addr.toString(16) + ' (did not reach dfuIDLE after clearing');
+ console.log(`Failed to erase page 0x${page_addr.toString(16)} (did not reach dfuIDLE after clearing`);
self.cleanup();
}
});
@@ -890,13 +890,13 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
} else if (data[4] == self.state.dfuDNLOAD_IDLE) {
erase_page_next();
} else {
- console.log('Failed to erase page 0x' + page_addr.toString(16));
+ console.log(`Failed to erase page 0x${page_addr.toString(16)}`);
self.cleanup();
}
});
}, delay);
} else {
- console.log('Failed to initiate page erase, page 0x' + page_addr.toString(16));
+ console.log(`Failed to initiate page erase, page 0x${page_addr.toString(16)}`);
self.cleanup();
}
});
@@ -945,13 +945,13 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// flash another page
write();
} else {
- console.log('Failed to write ' + bytes_to_write + 'bytes to 0x' + address.toString(16));
+ console.log(`Failed to write ${bytes_to_write}bytes to 0x${address.toString(16)}`);
self.cleanup();
}
});
}, delay);
} else {
- console.log('Failed to initiate write ' + bytes_to_write + 'bytes to 0x' + address.toString(16));
+ console.log(`Failed to initiate write ${bytes_to_write}bytes to 0x${address.toString(16)}`);
self.cleanup();
}
});
@@ -1104,7 +1104,7 @@ STM32DFU_protocol.prototype.cleanup = function () {
var timeSpent = new Date().getTime() - self.upload_time_start;
- console.log('Script finished after: ' + (timeSpent / 1000) + ' seconds');
+ console.log(`Script finished after: ${timeSpent / 1000} seconds`);
if (self.callback) {
self.callback();
diff --git a/src/js/serial.js b/src/js/serial.js
index 51feedb0..6acc7cc1 100644
--- a/src/js/serial.js
+++ b/src/js/serial.js
@@ -104,7 +104,7 @@ const serial = {
case 'frame_error':
case 'parity_error':
- GUI.log(i18n.getMessage('serialError' + inflection.camelize(info.error)));
+ GUI.log(i18n.getMessage(`serialError${inflection.camelize(info.error)}`));
self.errorHandler(info.error, 'receive');
break;
case 'break': // This seems to be the error that is thrown under NW.js in Windows when the device reboots after typing 'exit' in CLI
diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js
index 4a5a18d7..2f8168c2 100644
--- a/src/js/serial_backend.js
+++ b/src/js/serial_backend.js
@@ -789,17 +789,17 @@ function bit_clear(num, bit) {
function update_dataflash_global() {
function formatFilesize(bytes) {
if (bytes < 1024) {
- return bytes + "B";
+ return `${bytes}B`;
}
const kilobytes = bytes / 1024;
if (kilobytes < 1024) {
- return Math.round(kilobytes) + "kB";
+ return `${Math.round(kilobytes)}kB`;
}
const megabytes = kilobytes / 1024;
- return megabytes.toFixed(1) + "MB";
+ return `${megabytes.toFixed(1)}MB`;
}
const supportsDataflash = FC.DATAFLASH.totalSize > 0;
@@ -814,10 +814,10 @@ function update_dataflash_global() {
});
$(".dataflash-free_global").css({
- width: (100-(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize) / FC.DATAFLASH.totalSize * 100) + "%",
+ width: `${100-(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize) / FC.DATAFLASH.totalSize * 100}%`,
display: 'block',
});
- $(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize));
+ $(".dataflash-free_global div").text(`Dataflash: free ${formatFilesize(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize)}`);
} else {
$(".noflash_global").css({
display: 'block',
diff --git a/src/js/tabs/adjustments.js b/src/js/tabs/adjustments.js
index a1f32d7f..c66dde57 100644
--- a/src/js/tabs/adjustments.js
+++ b/src/js/tabs/adjustments.js
@@ -30,7 +30,7 @@ TABS.adjustments.initialize = function (callback) {
const template = $('#tab-adjustments-templates .adjustments .adjustment');
const newAdjustment = template.clone();
- $(newAdjustment).attr('id', 'adjustment-' + adjustmentIndex);
+ $(newAdjustment).attr('id', `adjustment-${adjustmentIndex}`);
$(newAdjustment).data('index', adjustmentIndex);
//
@@ -51,7 +51,7 @@ TABS.adjustments.initialize = function (callback) {
channelOptionTemplate.remove();
for (let channelIndex = 0; channelIndex < auxChannelCount; channelIndex++) {
const channelOption = channelOptionTemplate.clone();
- channelOption.text('AUX ' + (channelIndex + 1));
+ channelOption.text(`AUX ${channelIndex + 1}`);
channelOption.val(channelIndex);
channelList.append(channelOption);
}
@@ -76,7 +76,7 @@ TABS.adjustments.initialize = function (callback) {
let switchOption;
for (let switchIndex = 0; switchIndex < auxChannelCount; switchIndex++) {
switchOption = switchOptionTemplate.clone();
- switchOption.text('AUX ' + (switchIndex + 1));
+ switchOption.text(`AUX ${switchIndex + 1}`);
switchOption.val(switchIndex);
switchList.append(switchOption);
}
@@ -250,7 +250,7 @@ TABS.adjustments.initialize = function (callback) {
return;
}
- $(this).find('.range .marker').css('left', percentage + '%');
+ $(this).find('.range .marker').css('left', `${percentage}%`);
});
}
@@ -304,7 +304,7 @@ TABS.adjustments.adjust_template = function () {
}
for (let i = 0; i < elementsNumber; i++) {
- selectFunction.append(new Option(i18n.getMessage('adjustmentsFunction' + i), i));
+ selectFunction.append(new Option(i18n.getMessage(`adjustmentsFunction${i}`), i));
}
// For 1.40, the D Setpoint has been replaced, so we replace it with the correct values
diff --git a/src/js/tabs/auxiliary.js b/src/js/tabs/auxiliary.js
index 2a0d0019..15531dd4 100644
--- a/src/js/tabs/auxiliary.js
+++ b/src/js/tabs/auxiliary.js
@@ -46,7 +46,7 @@ TABS.auxiliary.initialize = function (callback) {
// Adjust the name of the box if a peripheral is selected
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
- $(newMode).attr('id', 'mode-' + modeIndex);
+ $(newMode).attr('id', `mode-${modeIndex}`);
$(newMode).find('.name').text(modeName);
$(newMode).data('index', modeIndex);
@@ -99,7 +99,7 @@ TABS.auxiliary.initialize = function (callback) {
for (let channelIndex = 0; channelIndex < auxChannelCount; channelIndex++) {
channelOption = channelOptionTemplate.clone();
- channelOption.text('AUX ' + (channelIndex + 1));
+ channelOption.text(`AUX ${channelIndex + 1}`);
channelOption.val(channelIndex);
channelList.append(channelOption);
}
@@ -151,7 +151,7 @@ TABS.auxiliary.initialize = function (callback) {
const rangeIndex = modeRanges.children().length;
let rangeElement = $('#tab-auxiliary-templates .range').clone();
- rangeElement.attr('id', 'mode-' + modeIndex + '-range-' + rangeIndex);
+ rangeElement.attr('id', `mode-${modeIndex}-range-${rangeIndex}`);
modeRanges.append(rangeElement);
if (rangeIndex == 0) {
@@ -172,9 +172,9 @@ TABS.auxiliary.initialize = function (callback) {
}),
});
- const elementName = '#mode-' + modeIndex + '-range-' + rangeIndex;
- $(elementName + ' .channel-slider').Link('lower').to($(elementName + ' .lowerLimitValue'));
- $(elementName + ' .channel-slider').Link('upper').to($(elementName + ' .upperLimitValue'));
+ const elementName = `#mode-${modeIndex}-range-${rangeIndex}`;
+ $(`${elementName} .channel-slider`).Link('lower').to($(`${elementName} .lowerLimitValue`));
+ $(`${elementName} .channel-slider`).Link('upper').to($(`${elementName} .upperLimitValue`));
let sliderValues = [900, 1000, 1200, 1400, 1500, 1600, 1800, 2000, 2100];
if ($(window).width() < 575) {
@@ -215,7 +215,7 @@ TABS.auxiliary.initialize = function (callback) {
const linkIndex = modeRanges.children().length;
let linkElement = $('#tab-auxiliary-templates .link').clone();
- linkElement.attr('id', 'mode-' + modeIndex + '-link-' + linkIndex);
+ linkElement.attr('id', `mode-${modeIndex}-link-${linkIndex}`);
modeRanges.append(linkElement);
if (linkIndex == 0) {
@@ -226,7 +226,7 @@ TABS.auxiliary.initialize = function (callback) {
// disable the option associated with this mode
const linkSelect = $(linkElement).find('.linkedTo');
- $(linkSelect).find('option[value="' + modeId + '"]').prop('disabled',true);
+ $(linkSelect).find(`option[value="${modeId}"]`).prop('disabled',true);
$(linkElement).find('.deleteLink').data('linkElement', linkElement);
$(linkElement).find('.deleteLink').data('modeElement', modeElement);
@@ -422,7 +422,7 @@ TABS.auxiliary.initialize = function (callback) {
return;
}
- $(this).find('.marker').css('left', percentage + '%');
+ $(this).find('.marker').css('left', `${percentage}%`);
});
}
@@ -434,7 +434,7 @@ TABS.auxiliary.initialize = function (callback) {
function update_ui() {
let hasUsedMode = false;
for (let i = 0; i < FC.AUX_CONFIG.length; i++) {
- let modeElement = $('#mode-' + i);
+ let modeElement = $(`#mode-${i}`);
if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) {
// if the mode is unused, skip it
modeElement.removeClass('off').removeClass('on').removeClass('disabled');
@@ -469,7 +469,7 @@ TABS.auxiliary.initialize = function (callback) {
// that arming is disabled.
if (armSwitchActive) {
$('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('off').addClass('disabled');
- $('.mode .name').eq(i).html(FC.AUX_CONFIG[i] + '
' + i18n.getMessage('auxiliaryDisabled'));
+ $('.mode .name').eq(i).html(`${FC.AUX_CONFIG[i]}
${i18n.getMessage('auxiliaryDisabled')}`);
} else {
$('.mode .name').eq(i).data('modeElement').removeClass('on').removeClass('disabled').addClass('off');
$('.mode .name').eq(i).html(FC.AUX_CONFIG[i]);
@@ -483,7 +483,7 @@ TABS.auxiliary.initialize = function (callback) {
let hideUnused = hideUnusedModes && hasUsedMode;
for (let i = 0; i < FC.AUX_CONFIG.length; i++) {
- let modeElement = $('#mode-' + i);
+ let modeElement = $(`#mode-${i}`);
if (modeElement.find(' .range').length == 0 && modeElement.find(' .link').length == 0) {
modeElement.toggle(!hideUnused);
}
diff --git a/src/js/tabs/cli.js b/src/js/tabs/cli.js
index 9c986590..95695f2a 100644
--- a/src/js/tabs/cli.js
+++ b/src/js/tabs/cli.js
@@ -37,7 +37,7 @@ function commandWithBackSpaces(command, buffer, noOfCharsToDelete) {
function getCliCommand(command, cliBuffer) {
const buffer = removePromptHash(cliBuffer);
- const bufferRegex = new RegExp('^' + buffer, 'g');
+ const bufferRegex = new RegExp(`^${buffer}`, 'g');
if (command.match(bufferRegex)) {
return command.replace(bufferRegex, '');
}
@@ -146,7 +146,7 @@ TABS.cli.initialize = function (callback) {
const filename = generateFilename(prefix, suffix);
const accepts = [{
- description: suffix.toUpperCase() + ' files', extensions: [suffix],
+ description: `${suffix.toUpperCase()} files`, extensions: [suffix],
}];
chrome.fileSystem.chooseEntry({type: 'saveFile', suggestedName: filename, accepts: accepts}, function(entry) {
@@ -377,7 +377,7 @@ function writeLineToOutput(text) {
if (text.startsWith("###ERROR")) {
writeToOutput(`
`);
} else {
- writeToOutput(text + "
");
+ writeToOutput(`${text}
`);
}
}
@@ -488,11 +488,11 @@ TABS.cli.read = function (readInfo) {
};
TABS.cli.sendLine = function (line, callback) {
- this.send(line + '\n', callback);
+ this.send(`${line}\n`, callback);
};
TABS.cli.sendNativeAutoComplete = function (line, callback) {
- this.send(line + '\t', callback);
+ this.send(`${line}\t`, callback);
};
TABS.cli.send = function (line, callback) {
diff --git a/src/js/tabs/failsafe.js b/src/js/tabs/failsafe.js
index 12c0b7a7..ecb16341 100644
--- a/src/js/tabs/failsafe.js
+++ b/src/js/tabs/failsafe.js
@@ -118,7 +118,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
let modeName = FC.AUX_CONFIG[modeIndex];
modeName = adjustBoxNameIfPeripheralWithModeID(modeId, modeName);
- auxAssignment[modeRange.auxChannelIndex] += "" + modeName + "";
+ auxAssignment[modeRange.auxChannelIndex] += `${modeName}`;
}
}
@@ -136,52 +136,53 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
for (let i = 0; i < FC.RXFAIL_CONFIG.length; i++) {
if (i < channelNames.length) {
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
- fullChannels_e.append('\
+ fullChannels_e.append(`\