Change lexical scope remaing root
parent
317f937fd5
commit
57539eb6de
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var Analytics = function (trackingId, userId, appName, appVersion, changesetId, os, checkForDebugVersions, optOut, debugMode, buildType) {
|
||||
const Analytics = function (trackingId, userId, appName, appVersion, changesetId, os, checkForDebugVersions, optOut, debugMode, buildType) {
|
||||
this._trackingId = trackingId;
|
||||
|
||||
this.setOptOut(optOut);
|
||||
|
@ -85,12 +85,12 @@ var Analytics = function (trackingId, userId, appName, appVersion, changesetId,
|
|||
};
|
||||
|
||||
Analytics.prototype.setDimension = function (dimension, value) {
|
||||
var dimensionName = 'dimension' + dimension;
|
||||
const dimensionName = `dimension${dimension}`;
|
||||
this._googleAnalytics.custom(dimensionName, value);
|
||||
}
|
||||
|
||||
Analytics.prototype.setMetric = function (metric, value) {
|
||||
var metricName = 'metric' + metric;
|
||||
const metricName = `metric${metric}`;
|
||||
this._googleAnalytics.custom(metricName, value);
|
||||
}
|
||||
|
||||
|
@ -99,9 +99,9 @@ Analytics.prototype.sendEvent = function (category, action, options) {
|
|||
}
|
||||
|
||||
Analytics.prototype.sendChangeEvents = function (category, changeList) {
|
||||
for (var actionName in changeList) {
|
||||
for (const actionName in changeList) {
|
||||
if (changeList.hasOwnProperty(actionName)) {
|
||||
var actionValue = changeList[actionName];
|
||||
const actionValue = changeList[actionName];
|
||||
if (actionValue !== undefined) {
|
||||
this.sendEvent(category, actionName, { eventLabel: actionValue });
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* Encapsulates the Clipboard logic, depending on web or nw
|
||||
*
|
||||
*/
|
||||
var Clipboard = {
|
||||
const Clipboard = {
|
||||
_nwClipboard: null,
|
||||
available : null,
|
||||
readAvailable : null,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
var css_dark = [
|
||||
const css_dark = [
|
||||
'./css/dark-theme.css',
|
||||
];
|
||||
|
||||
var DarkTheme = {
|
||||
const DarkTheme = {
|
||||
configEnabled: undefined,
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// and then manually setting vcp to true for boards that use VCP
|
||||
// Also, please note that the targets in this list are ordered in the order they are returned by the above command. Please do not reorder to avoid churn.
|
||||
|
||||
var BOARD_DEFINITIONS = [
|
||||
const BOARD_DEFINITIONS = [
|
||||
{name: 'AIR32', identifier: 'AR32', vcp: true},
|
||||
{name: 'AIRHEROF3', identifier: 'AIR3', vcp: false},
|
||||
{name: 'ALIENFLIGHTF1', identifier: 'AFF1', vcp: false},
|
||||
|
@ -74,17 +74,15 @@ var BOARD_DEFINITIONS = [
|
|||
{name: 'ZCOREF3', identifier: 'ZCF3', vcp: false}
|
||||
];
|
||||
|
||||
var DEFAULT_BOARD_DEFINITION = {
|
||||
const DEFAULT_BOARD_DEFINITION = {
|
||||
name: "Unknown", identifier: "????", vcp: false
|
||||
};
|
||||
|
||||
var BOARD = {};
|
||||
const BOARD = {};
|
||||
|
||||
BOARD.find_board_definition = function (identifier) {
|
||||
for (var i = 0; i < BOARD_DEFINITIONS.length; i++) {
|
||||
var candidate = BOARD_DEFINITIONS[i];
|
||||
|
||||
if (candidate.identifier == identifier) {
|
||||
for (const candidate of BOARD_DEFINITIONS) {
|
||||
if (candidate.identifier === identifier) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ const API_VERSION_1_42 = '1.42.0';
|
|||
const API_VERSION_1_43 = '1.43.0';
|
||||
const API_VERSION_1_44 = '1.44.0';
|
||||
|
||||
var CONFIGURATOR = {
|
||||
const CONFIGURATOR = {
|
||||
// all versions are specified and compared using semantic versioning http://semver.org/
|
||||
API_VERSION_ACCEPTED: '1.2.1',
|
||||
API_VERSION_MIN_SUPPORTED_BACKUP_RESTORE: '1.5.0',
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
var defaultHuffmanTree = [
|
||||
const defaultHuffmanTree = [
|
||||
{ value: 0x00, codeLen: 2, code: 0x0003 }, // 11
|
||||
{ value: 0x01, codeLen: 3, code: 0x0005 }, // 101
|
||||
{ value: 0x02, codeLen: 4, code: 0x0009 }, // 1001
|
||||
|
@ -260,12 +260,11 @@ var defaultHuffmanTree = [
|
|||
{ value: HUFFMAN_EOF, codeLen: 12, code: 0x0000 }, // 000000000000
|
||||
];
|
||||
|
||||
var defaultHuffmanLenIndex = function()
|
||||
{
|
||||
var result = Array(defaultHuffmanTree.length).fill(-1);
|
||||
const defaultHuffmanLenIndex = function() {
|
||||
const result = Array(defaultHuffmanTree.length).fill(-1);
|
||||
|
||||
for (var i = 0; i < defaultHuffmanTree.length; ++i) {
|
||||
if (result[defaultHuffmanTree[i].codeLen] == -1) {
|
||||
for (let i = 0; i < defaultHuffmanTree.length; ++i) {
|
||||
if (result[defaultHuffmanTree[i].codeLen] === -1) {
|
||||
result[defaultHuffmanTree[i].codeLen] = i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
var HUFFMAN_EOF = -1;
|
||||
const HUFFMAN_EOF = -1;
|
||||
|
||||
function huffmanDecodeBuf(inBuf, inBufCharacterCount, huffmanTree, huffmanLenIndex)
|
||||
{
|
||||
var code = 0;
|
||||
var codeLen = 0;
|
||||
var testBit = 0x80;
|
||||
var eof = false;
|
||||
var outBuf = [];
|
||||
function huffmanDecodeBuf(inBuf, inBufCharacterCount, huffmanTree, huffmanLenIndex) {
|
||||
let code = 0;
|
||||
let codeLen = 0;
|
||||
let testBit = 0x80;
|
||||
let eof = false;
|
||||
const outBuf = [];
|
||||
|
||||
while (!eof && inBuf.byteLength != 0) {
|
||||
if (outBuf.length == inBufCharacterCount) {
|
||||
|
@ -35,10 +34,10 @@ function huffmanDecodeBuf(inBuf, inBufCharacterCount, huffmanTree, huffmanLenInd
|
|||
// check if the code is a leaf node or an interior node
|
||||
if (huffmanLenIndex[codeLen] != -1) {
|
||||
// look for the code in the tree, only leaf nodes are stored in the tree
|
||||
for (var i = huffmanLenIndex[codeLen]; (i < huffmanTree.length) && (huffmanTree[i].codeLen == codeLen); ++i) {
|
||||
if (huffmanTree[i].code == code) {
|
||||
for (let i = huffmanLenIndex[codeLen]; (i < huffmanTree.length) && (huffmanTree[i].codeLen === codeLen); ++i) {
|
||||
if (huffmanTree[i].code === code) {
|
||||
// we've found the code, so it is a leaf node
|
||||
var value = huffmanTree[i].value;
|
||||
const value = huffmanTree[i].value;
|
||||
|
||||
if (value == HUFFMAN_EOF) {
|
||||
eof = true;
|
||||
|
@ -57,4 +56,4 @@ function huffmanDecodeBuf(inBuf, inBufCharacterCount, huffmanTree, huffmanLenInd
|
|||
}
|
||||
|
||||
return new Uint8Array(outBuf);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
// generate mixer
|
||||
var mixerList = [
|
||||
const mixerList = [
|
||||
{name: 'Tricopter', pos: 3, model: 'tricopter', image: 'tri'},
|
||||
{name: 'Quad +', pos: 2, model: 'quad_x', image: 'quad_p'},
|
||||
{name: 'Quad X', pos: 0, model: 'quad_x', image: 'quad_x'},
|
||||
|
@ -31,8 +31,8 @@ var mixerList = [
|
|||
];
|
||||
|
||||
// 3D model
|
||||
var Model = function (wrapper, canvas) {
|
||||
var useWebGLRenderer = this.canUseWebGLRenderer();
|
||||
const Model = function (wrapper, canvas) {
|
||||
const useWebGLRenderer = this.canUseWebGLRenderer();
|
||||
|
||||
this.wrapper = wrapper;
|
||||
this.canvas = canvas;
|
||||
|
@ -47,7 +47,7 @@ var Model = function (wrapper, canvas) {
|
|||
this.renderer.setSize(this.wrapper.width() * 2, this.wrapper.height() * 2);
|
||||
|
||||
// load the model including materials
|
||||
var model_file = useWebGLRenderer ? mixerList[FC.MIXER_CONFIG.mixer - 1].model : 'fallback';
|
||||
let model_file = useWebGLRenderer ? mixerList[FC.MIXER_CONFIG.mixer - 1].model : 'fallback';
|
||||
|
||||
// Temporary workaround for 'custom' model until akfreak's custom model is merged.
|
||||
if (model_file == 'custom') { model_file = 'fallback'; }
|
||||
|
@ -65,8 +65,8 @@ var Model = function (wrapper, canvas) {
|
|||
this.camera.position.z = 125;
|
||||
|
||||
// some light
|
||||
var light = new THREE.AmbientLight(0x404040);
|
||||
var light2 = new THREE.DirectionalLight(new THREE.Color(1, 1, 1), 1.5);
|
||||
const light = new THREE.AmbientLight(0x404040);
|
||||
const light2 = new THREE.DirectionalLight(new THREE.Color(1, 1, 1), 1.5);
|
||||
light2.position.set(0, 1, 0);
|
||||
|
||||
// add camera, model, light to the foreground scene
|
||||
|
@ -103,7 +103,7 @@ Model.prototype.canUseWebGLRenderer = function () {
|
|||
// webgl capability detector
|
||||
// it would seem the webgl "enabling" through advanced settings will be ignored in the future
|
||||
// and webgl will be supported if gpu supports it by default (canary 40.0.2175.0), keep an eye on this one
|
||||
var detector_canvas = document.createElement('canvas');
|
||||
const detector_canvas = document.createElement('canvas');
|
||||
|
||||
return window.WebGLRenderingContext && (detector_canvas.getContext('webgl') || detector_canvas.getContext('experimental-webgl'));
|
||||
};
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
// return true if user has choose a special peripheral
|
||||
function isPeripheralSelected(peripheralName) {
|
||||
for (var portIndex = 0; portIndex < FC.SERIAL_CONFIG.ports.length; portIndex++) {
|
||||
var serialPort = FC.SERIAL_CONFIG.ports[portIndex];
|
||||
for (let portIndex = 0; portIndex < FC.SERIAL_CONFIG.ports.length; portIndex++) {
|
||||
const serialPort = FC.SERIAL_CONFIG.ports[portIndex];
|
||||
if (serialPort.functions.indexOf(peripheralName) >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ function adjustBoxNameIfPeripheralWithModeID(modeId, defaultName) {
|
|||
default:
|
||||
return defaultName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return defaultName;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
var ReleaseChecker = function (releaseName, releaseUrl) {
|
||||
var self = this;
|
||||
|
||||
|
||||
self._releaseName = releaseName;
|
||||
self._releaseDataTag = `${self._releaseName}ReleaseData`;
|
||||
self._releaseLastUpdateTag = `${self._releaseName}ReleaseLastUpdate`
|
||||
|
@ -10,28 +10,28 @@ var ReleaseChecker = function (releaseName, releaseUrl) {
|
|||
}
|
||||
|
||||
ReleaseChecker.prototype.loadReleaseData = function (processFunction) {
|
||||
var self = this;
|
||||
const self = this;
|
||||
chrome.storage.local.get([self._releaseLastUpdateTag, self._releaseDataTag], function (result) {
|
||||
var releaseDataTimestamp = $.now();
|
||||
var cacheReleaseData = result[self._releaseDataTag];
|
||||
var cachedReleaseLastUpdate = result[self._releaseLastUpdateTag];
|
||||
const releaseDataTimestamp = $.now();
|
||||
const cacheReleaseData = result[self._releaseDataTag];
|
||||
const cachedReleaseLastUpdate = result[self._releaseLastUpdateTag];
|
||||
if (!cacheReleaseData || !cachedReleaseLastUpdate || releaseDataTimestamp - cachedReleaseLastUpdate > 3600 * 1000) {
|
||||
$.get(self._releaseUrl, function (releaseData) {
|
||||
GUI.log(i18n.getMessage('releaseCheckLoaded',[self._releaseName]));
|
||||
|
||||
var data = {};
|
||||
data[self._releaseDataTag] = releaseData
|
||||
data[self._releaseLastUpdateTag] = releaseDataTimestamp
|
||||
const data = {};
|
||||
data[self._releaseDataTag] = releaseData;
|
||||
data[self._releaseLastUpdateTag] = releaseDataTimestamp;
|
||||
chrome.storage.local.set(data, function () {});
|
||||
|
||||
|
||||
self._processReleaseData(releaseData, processFunction);
|
||||
}).fail(function (data) {
|
||||
var message = '';
|
||||
let message = '';
|
||||
if (data['responseJSON']) {
|
||||
message = data['responseJSON'].message;
|
||||
}
|
||||
GUI.log(i18n.getMessage('releaseCheckFailed',[self._releaseName,message]));
|
||||
|
||||
|
||||
self._processReleaseData(cacheReleaseData, processFunction);
|
||||
});
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ ReleaseChecker.prototype.loadReleaseData = function (processFunction) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
ReleaseChecker.prototype._processReleaseData = function (releaseData, processFunction) {
|
||||
if (releaseData) {
|
||||
|
|
Loading…
Reference in New Issue