");
- for (const field in stats) {
+ for (const field of stats) {
const stat = stats[field];
if (stat === undefined) {
continue;
@@ -268,12 +268,12 @@ function BlackboxLogViewer() {
// update time field on status bar
$(".graph-time").val(formatTime((currentBlackboxTime-flightLog.getMinTime())/1000, true));
- if(hasMarker) {
+ if (hasMarker) {
$(".marker-offset", statusBar).text('Marker Offset ' + formatTime((currentBlackboxTime-markerTime)/1000, true) + 'ms ' + (1000000/(currentBlackboxTime-markerTime)).toFixed(0) + "Hz");
}
// Update the Legend Values
- if(graphLegend) graphLegend.updateValues(flightLog, frame);
+ if (graphLegend) graphLegend.updateValues(flightLog, frame);
}
}
@@ -282,7 +282,7 @@ function BlackboxLogViewer() {
function animationLoop() {
- var
+ let
now = Date.now();
if (!graph) {
@@ -293,7 +293,7 @@ function BlackboxLogViewer() {
if (hasVideo) {
currentBlackboxTime = blackboxTimeFromVideoTime();
} else if (graphState == GRAPH_STATE_PLAY) {
- var
+ let
delta;
if (lastRenderTime === false) {
@@ -344,14 +344,14 @@ function BlackboxLogViewer() {
}
function updateCanvasSize() {
- var
+ let
width = $(canvas).width(),
height = $(canvas).height();
if (graph) {
graph.resize(width, height);
seekBar.resize(canvas.offsetWidth, 50);
- if(flightLog.hasGpsData()) {
+ if (flightLog.hasGpsData()) {
mapGrapher.resize(width, height);
}
@@ -360,7 +360,7 @@ function BlackboxLogViewer() {
}
function renderSeekBarPicker(){
- var
+ let
seekBarContainer = $(".seekBar-selection"),
seekBarPicker,
seekBarItems = [
@@ -378,9 +378,8 @@ function BlackboxLogViewer() {
seekBar.setActivity(activity.times, activity[displayItem], activity.hasEvent);
seekBar.repaint();
});
- for (let item of seekBarItems) {
- let option;
- option = $("");
+ for (const item of seekBarItems) {
+ const option = $("");
option.text(item[1]);
option.attr("value", item[0]);
seekBarPicker.append(option);
@@ -392,11 +391,10 @@ function BlackboxLogViewer() {
function renderLogFileInfo(file) {
$(".log-filename").text(file.name);
- var
+ let
logIndexContainer = $(".log-index"),
logIndexPicker,
- logCount = flightLog.getLogCount(),
- index;
+ logCount = flightLog.getLogCount();
logIndexContainer.empty();
@@ -405,14 +403,14 @@ function BlackboxLogViewer() {
logIndexPicker.change(function() {
selectLog(parseInt($(this).val(), 10));
- if(graph) {
+ if (graph) {
(hasAnalyserFullscreen)?html.addClass("has-analyser-fullscreen"):html.removeClass("has-analyser-fullscreen");
graph.setAnalyser(hasAnalyserFullscreen);
}
});
}
- for (index = 0; index < logCount; index++) {
+ for (let index = 0; index < logCount; index++) {
let
logLabel,
option, holder,
@@ -477,7 +475,7 @@ function BlackboxLogViewer() {
**/
// Add log version information to status bar
- var sysConfig = flightLog.getSysConfig();
+ let sysConfig = flightLog.getSysConfig();
$('.version', statusBar).text( ((sysConfig['Craft name']!=null)?(sysConfig['Craft name'] + ' : '):'') +
((sysConfig['Firmware revision']!=null)?(sysConfig['Firmware revision']):''));
$('.looptime', statusBar).text( stringLoopTime(sysConfig.looptime, sysConfig.pid_process_denom, sysConfig.unsynced_fast_pwm, sysConfig.motor_pwm_rate));
@@ -486,7 +484,7 @@ function BlackboxLogViewer() {
seekBar.setTimeRange(flightLog.getMinTime(), flightLog.getMaxTime(), currentBlackboxTime);
seekBar.setActivityRange(flightLog.getSysConfig().motorOutput[0], flightLog.getSysConfig().motorOutput[1]);
- var
+ let
activity = flightLog.getActivitySummary();
seekBar.setActivity(activity.times, activity[seekBarMode], activity.hasEvent);
@@ -494,7 +492,7 @@ function BlackboxLogViewer() {
// Add flightLog to map
html.toggleClass("has-gps", flightLog.hasGpsData());
- if(flightLog.hasGpsData()) {
+ if (flightLog.hasGpsData()) {
mapGrapher.setUserSettings(userSettings);
mapGrapher.setFlightLog(flightLog);
}
@@ -503,7 +501,7 @@ function BlackboxLogViewer() {
function setGraphState(newState) {
graphState = newState;
- var btnLogPlayPause = $(".log-play-pause");
+ let btnLogPlayPause = $(".log-play-pause");
lastRenderTime = false;
@@ -607,8 +605,8 @@ function BlackboxLogViewer() {
}
function showConfigFile(state) {
- if(hasConfig) {
- if(state == null) { // no state specified, just toggle
+ if (hasConfig) {
+ if (state == null) { // no state specified, just toggle
hasConfigOverlay = !hasConfigOverlay;
} else { //state defined, just set item
hasConfigOverlay = (state)?true:false;
@@ -618,7 +616,7 @@ function BlackboxLogViewer() {
}
function showValueTable(state) {
- if(state == null) { // no state specified, just toggle
+ if (state == null) { // no state specified, just toggle
hasTableOverlay = !hasTableOverlay;
} else { //state defined, just set item
hasTableOverlay = (state)?true:false;
@@ -632,12 +630,12 @@ function BlackboxLogViewer() {
* available log.
*/
function selectLog(logIndex) {
- var
+ let
success = false;
try {
if (logIndex === null) {
- for (var i = 0; i < flightLog.getLogCount(); i++) {
+ for (let i = 0; i < flightLog.getLogCount(); i++) {
if (flightLog.openLog(i)) {
success = true;
currentOffsetCache.index = i;
@@ -709,56 +707,56 @@ function BlackboxLogViewer() {
}
function loadFiles(files) {
- for (var i = 0; i < files.length; i++) {
- var
- isLog = files[i].name.match(/\.(BBL|TXT|CFL|BFL|LOG)$/i),
- isVideo = files[i].name.match(/\.(AVI|MOV|MP4|MPEG)$/i),
- isWorkspaces = files[i].name.match(/\.(JSON)$/i);
+ for (const file of files) {
+ let
+ isLog = file.name.match(/\.(BBL|TXT|CFL|BFL|LOG)$/i),
+ isVideo = file.name.match(/\.(AVI|MOV|MP4|MPEG)$/i),
+ isWorkspaces = file.name.match(/\.(JSON)$/i);
- loadFileMessage(files[i].name);
+ loadFileMessage(file.name);
if (!isLog && !isVideo && !isWorkspaces) {
- if (files[i].size < 10 * 1024 * 1024)
+ if (file.size < 10 * 1024 * 1024)
isLog = true; //Assume small files are logs rather than videos
else
isVideo = true;
}
if (isLog) {
- loadLogFile(files[i]);
+ loadLogFile(file);
} else if (isVideo) {
- loadVideo(files[i]);
+ loadVideo(file);
} else if (isWorkspaces) {
- loadWorkspaces(files[i])
+ loadWorkspaces(file);
}
}
// finally, see if there is an offsetCache value already, and auto set the offset
- for(i=0; iStored defaults for all pens';
}
- if(graph!=null && field!=null) { // restore single pen
- if(graphConfig[parseInt(graph)].fields[parseInt(field)].default==null) {
+ if (graph!=null && field!=null) { // restore single pen
+ if (graphConfig[parseInt(graph)].fields[parseInt(field)].default==null) {
graphConfig[parseInt(graph)].fields[parseInt(field)].default = [];
graphConfig[parseInt(graph)].fields[parseInt(field)].default.smoothing = graphConfig[parseInt(graph)].fields[parseInt(field)].smoothing;
graphConfig[parseInt(graph)].fields[parseInt(field)].default.power = graphConfig[parseInt(graph)].fields[parseInt(field)].curve.power;
@@ -1587,19 +1589,19 @@ function BlackboxLogViewer() {
* field is the actual pen to change, null means all pens within group
*/
- if(graph==null && field==null) return false; // no pen specified, just exit
+ if (graph==null && field==null) return false; // no pen specified, just exit
- if(graph!=null && field==null) { // restore ALL pens within group
- for(var i=0; iRestored defaults for all pens';
}
- if(graph!=null && field!=null) { // restore single pen
- if(graphConfig[parseInt(graph)].fields[parseInt(field)].default!=null) {
+ if (graph!=null && field!=null) { // restore single pen
+ if (graphConfig[parseInt(graph)].fields[parseInt(field)].default!=null) {
graphConfig[parseInt(graph)].fields[parseInt(field)].smoothing = graphConfig[parseInt(graph)].fields[parseInt(field)].default.smoothing;
graphConfig[parseInt(graph)].fields[parseInt(field)].curve.power = graphConfig[parseInt(graph)].fields[parseInt(field)].default.power;
return '
Restored defaults for single pen
';
@@ -1619,20 +1621,20 @@ function BlackboxLogViewer() {
const range = { min:0, max:10000 }; // actually in milliseconds!
const scroll = 1000; // actually in milliseconds
- if(graph==null && field==null) return false; // no pen specified, just exit
+ if (graph==null && field==null) return false; // no pen specified, just exit
savePenDefaults(graphConfig, graph, field); // only updates defaults if they are not already set
- var changedValue = '
Smoothing
';
- if(graph!=null && field==null) { // change ALL pens within group
- for(var i=0; i=0))
@@ -1783,7 +1785,7 @@ function BlackboxLogViewer() {
e.preventDefault();
}
- if(refreshRequired) {
+ if (refreshRequired) {
graph.refreshGraphConfig();
invalidateGraph();
mouseNotification.show($('.log-graph'), null, null, refreshRequired, 750, null, 'bottom-right', 0);
@@ -1799,8 +1801,8 @@ function BlackboxLogViewer() {
// Pressing any key hides dropdown menus
//$(".dropdown-toggle").dropdown("toggle");
- var shifted = (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey);
- if(e.which === 13 && e.target.type === 'text' && $(e.target).parents('.modal').length == 0) {
+ let shifted = (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey);
+ if (e.which === 13 && e.target.type === 'text' && $(e.target).parents('.modal').length == 0) {
// pressing return on a text field clears the focus.
$(e.target).blur();
}
@@ -1850,7 +1852,7 @@ function BlackboxLogViewer() {
case "A".charCodeAt(0):
if(!(shifted)) {
- if(activeGraphConfig.selectedFieldName != null) {
+ if (activeGraphConfig.selectedFieldName != null) {
hasAnalyser = !hasAnalyser;
} else hasAnalyser = false;
graph.setDrawAnalyser(hasAnalyser);
@@ -1859,7 +1861,7 @@ function BlackboxLogViewer() {
invalidateGraph();
e.preventDefault();
} else { // Maximize
- if(hasAnalyser) {
+ if (hasAnalyser) {
hasAnalyserFullscreen = !hasAnalyserFullscreen;
} else hasAnalyserFullscreen = false;
(hasAnalyserFullscreen)?html.addClass("has-analyser-fullscreen"):html.removeClass("has-analyser-fullscreen");
@@ -1897,7 +1899,7 @@ function BlackboxLogViewer() {
case "9".charCodeAt(0):
try {
if (!e.altKey) { // Workspaces feature
- var id = e.which - 48;
+ let id = e.which - 48;
if (!e.shiftKey) { // retrieve graph configuration from workspace
if (workspaceGraphConfigs[id] != null) {
onSwitchWorkspace(workspaceGraphConfigs, id)
@@ -1919,22 +1921,22 @@ function BlackboxLogViewer() {
} else {// store time to bookmark
// Special Case : Shift Alt 0 clears all bookmarks
- if(e.which==48) {
+ if (e.which==48) {
bookmarkTimes = null;
- for(var i=1; i<=9; i++) {
+ for (let i=1; i<=9; i++) {
$('.bookmark-'+ i, statusBar).css('visibility', 'hidden' );
}
$('.bookmark-clear', statusBar).css('visibility', 'hidden' );
} else {
- if(bookmarkTimes==null) bookmarkTimes = new Array();
+ if (bookmarkTimes==null) bookmarkTimes = new Array();
if (bookmarkTimes[e.which-48] == null) {
bookmarkTimes[e.which-48] = currentBlackboxTime; // Save current time to bookmark
} else {
bookmarkTimes[e.which-48] = null; // clear the bookmark
}
$('.bookmark-'+(e.which-48), statusBar).css('visibility', ((bookmarkTimes[e.which-48]!=null)?('visible'):('hidden')) );
- var countBookmarks = 0;
- for(var i=0; i<=9; i++) {
+ let countBookmarks = 0;
+ for (let i=0; i<=9; i++) {
countBookmarks += (bookmarkTimes[i]!=null)?1:0;
}
$('.bookmark-clear', statusBar).css('visibility', ((countBookmarks>0)?('visible'):('hidden')) );
@@ -1955,7 +1957,7 @@ function BlackboxLogViewer() {
break;
case "Z".charCodeAt(0): // Ctrl-Z key to toggle between last graph config and current one - undo
try {
- if(e.ctrlKey) {
+ if (e.ctrlKey) {
if (lastGraphConfig != null) {
newGraphConfig(lastGraphConfig);
}
@@ -2056,7 +2058,7 @@ function BlackboxLogViewer() {
loadeddata: videoLoaded
});
- var percentageFormat = {
+ let percentageFormat = {
to: function(value) {
return value.toFixed(0) + "%";
},
@@ -2131,7 +2133,7 @@ function BlackboxLogViewer() {
const item = e.dataTransfer.items[0];
const entry = item.webkitGetAsEntry();
if (entry.isFile) {
- var file = e.dataTransfer.files[0];
+ let file = e.dataTransfer.files[0];
loadFiles([file]);
}
return false;
@@ -2147,7 +2149,7 @@ function BlackboxLogViewer() {
}
loadFiles(files);
});
- };
+ }
prefs.get('videoConfig', function(item) {
if (item) {
@@ -2163,22 +2165,18 @@ function BlackboxLogViewer() {
});
prefs.get('graphConfig', function(item) {
- graphConfig = GraphConfig.load(item);
-
- if (!graphConfig && flightLog) {
- graphConfig = GraphConfig.getExampleGraphConfigs(flightLog, ["Motors", "Gyros"]);
+ if (item) {
+ graphConfig = GraphConfig.load(item);
}
});
// New workspaces feature; local storage of user configurations
prefs.get('workspaceGraphConfigs', function(item) {
- if(item) {
+ if (item) {
workspaceGraphConfigs = upgradeWorkspaceFormat(item);
} else {
workspaceGraphConfigs = defaultWorkspaceGraphConfigs;
}
-
- onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace);
});
prefs.get('activeWorkspace', function (id){
@@ -2188,23 +2186,22 @@ function BlackboxLogViewer() {
else {
activeWorkspace = 1
}
-
- onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace);
});
+ onSwitchWorkspace(workspaceGraphConfigs, activeWorkspace);
// Get the offsetCache buffer
prefs.get('offsetCache', function(item) {
- if(item) {
+ if (item) {
offsetCache = item;
}
- })
+ });
});
}
// Close the dropdowns if not clicking a descendant of the dropdown
$(document).click(function (e) {
- var p = $(e.target).closest(".dropdown");
+ let p = $(e.target).closest(".dropdown");
if (!p.length) {
$(".dropdown").removeClass("open");
}