@@ -344,7 +344,7 @@ function BlackboxLogViewer() {
344
344
}
345
345
346
346
function updateCanvasSize ( ) {
347
- let
347
+ const
348
348
width = $ ( canvas ) . width ( ) ,
349
349
height = $ ( canvas ) . height ( ) ;
350
350
@@ -360,18 +360,17 @@ function BlackboxLogViewer() {
360
360
}
361
361
362
362
function renderSeekBarPicker ( ) {
363
- let
363
+ const
364
364
seekBarContainer = $ ( ".seekBar-selection" ) ,
365
- seekBarPicker ,
365
+ seekBarPicker = $ ( '<select id="seekbarTypeSelect", class="seekbarTypeSelect">' ) ,
366
366
seekBarItems = [
367
367
[ "avgThrottle" , "Average motor throttle" ] ,
368
368
[ "maxRC" , "Maximum stick input" ] ,
369
369
[ "maxMotorDiff" , "Maximum motor differential" ] ,
370
370
] ;
371
371
seekBarContainer . empty ( ) ;
372
- seekBarPicker = $ ( '<select id="seekbarTypeSelect", class="seekbarTypeSelect">' ) ;
373
372
seekBarPicker . change ( function ( ) {
374
- let
373
+ const
375
374
activity = flightLog . getActivitySummary ( ) ,
376
375
displayItem = $ ( this ) . val ( ) ;
377
376
seekBarMode = displayItem ;
@@ -391,15 +390,14 @@ function BlackboxLogViewer() {
391
390
function renderLogFileInfo ( file ) {
392
391
$ ( ".log-filename" ) . text ( file . name ) ;
393
392
394
- let
393
+ const
395
394
logIndexContainer = $ ( ".log-index" ) ,
396
- logIndexPicker ,
397
395
logCount = flightLog . getLogCount ( ) ;
398
396
399
397
logIndexContainer . empty ( ) ;
400
398
399
+ const logIndexPicker = $ ( '<select class="log-index form-control no-wheel">' ) ;
401
400
if ( logCount > 1 ) {
402
- logIndexPicker = $ ( '<select class="log-index form-control no-wheel">' ) ;
403
401
404
402
logIndexPicker . change ( function ( ) {
405
403
selectLog ( parseInt ( $ ( this ) . val ( ) , 10 ) ) ;
@@ -411,12 +409,8 @@ function BlackboxLogViewer() {
411
409
}
412
410
413
411
for ( let index = 0 ; index < logCount ; index ++ ) {
414
- let
415
- logLabel ,
416
- option , holder ,
417
- error ;
418
-
419
- error = flightLog . getLogError ( index ) ;
412
+ let logLabel ;
413
+ const error = flightLog . getLogError ( index ) ;
420
414
421
415
if ( error ) {
422
416
logLabel = error ;
@@ -427,7 +421,7 @@ function BlackboxLogViewer() {
427
421
}
428
422
429
423
if ( logCount > 1 ) {
430
- option = $ ( "<option></option>" ) ;
424
+ const option = $ ( "<option></option>" ) ;
431
425
432
426
option . text ( ( index + 1 ) + "/" + ( flightLog . getLogCount ( ) ) + ": " + logLabel ) ;
433
427
option . attr ( "value" , index ) ;
@@ -437,8 +431,7 @@ function BlackboxLogViewer() {
437
431
438
432
logIndexPicker . append ( option ) ;
439
433
} else {
440
- holder = $ ( '<div class="form-control-static no-wheel"></div>' ) ;
441
-
434
+ const holder = $ ( '<div class="form-control-static no-wheel"></div>' ) ;
442
435
holder . text ( logLabel ) ;
443
436
logIndexContainer . append ( holder ) ;
444
437
}
@@ -475,7 +468,7 @@ function BlackboxLogViewer() {
475
468
**/
476
469
477
470
// Add log version information to status bar
478
- let sysConfig = flightLog . getSysConfig ( ) ;
471
+ const sysConfig = flightLog . getSysConfig ( ) ;
479
472
$ ( '.version' , statusBar ) . text ( ( ( sysConfig [ 'Craft name' ] != null ) ?( sysConfig [ 'Craft name' ] + ' : ' ) :'' ) +
480
473
( ( sysConfig [ 'Firmware revision' ] != null ) ?( sysConfig [ 'Firmware revision' ] ) :'' ) ) ;
481
474
$ ( '.looptime' , statusBar ) . text ( stringLoopTime ( sysConfig . looptime , sysConfig . pid_process_denom , sysConfig . unsynced_fast_pwm , sysConfig . motor_pwm_rate ) ) ;
@@ -484,7 +477,7 @@ function BlackboxLogViewer() {
484
477
seekBar . setTimeRange ( flightLog . getMinTime ( ) , flightLog . getMaxTime ( ) , currentBlackboxTime ) ;
485
478
seekBar . setActivityRange ( flightLog . getSysConfig ( ) . motorOutput [ 0 ] , flightLog . getSysConfig ( ) . motorOutput [ 1 ] ) ;
486
479
487
- let
480
+ const
488
481
activity = flightLog . getActivitySummary ( ) ;
489
482
490
483
seekBar . setActivity ( activity . times , activity [ seekBarMode ] , activity . hasEvent ) ;
@@ -501,7 +494,7 @@ function BlackboxLogViewer() {
501
494
502
495
function setGraphState ( newState ) {
503
496
graphState = newState ;
504
- let btnLogPlayPause = $ ( ".log-play-pause" ) ;
497
+ const btnLogPlayPause = $ ( ".log-play-pause" ) ;
505
498
506
499
lastRenderTime = false ;
507
500
@@ -743,12 +736,12 @@ function BlackboxLogViewer() {
743
736
}
744
737
745
738
function loadLogFile ( file ) {
746
- let reader = new FileReader ( ) ;
739
+ const reader = new FileReader ( ) ;
747
740
748
741
reader . onload = function ( e ) {
749
- let bytes = e . target . result ;
742
+ const bytes = e . target . result ;
750
743
751
- let fileContents = String . fromCharCode . apply ( null , new Uint8Array ( bytes , 0 , 100 ) ) ;
744
+ const fileContents = String . fromCharCode . apply ( null , new Uint8Array ( bytes , 0 , 100 ) ) ;
752
745
753
746
if ( fileContents . match ( / # d u m p | # d i f f / i) ) { // this is actually a configuration file
754
747
try {
@@ -884,7 +877,7 @@ function BlackboxLogViewer() {
884
877
}
885
878
886
879
this . getBookmarks = function ( ) { // get bookmark events
887
- let bookmarks = [ ] ;
880
+ const bookmarks = [ ] ;
888
881
try {
889
882
if ( bookmarkTimes != null ) {
890
883
for ( let i = 0 ; i <= 9 ; i ++ ) {
@@ -918,7 +911,7 @@ function BlackboxLogViewer() {
918
911
data = JSON . stringify ( workspaceGraphConfigs , undefined , 4 ) ;
919
912
}
920
913
921
- let blob = new Blob ( [ data ] , { type : 'text/json' } ) ,
914
+ const blob = new Blob ( [ data ] , { type : 'text/json' } ) ,
922
915
e = document . createEvent ( 'MouseEvents' ) ,
923
916
a = document . createElement ( 'a' ) ;
924
917
@@ -934,7 +927,7 @@ function BlackboxLogViewer() {
934
927
// Check if upgrade is needed
935
928
if ( ! oldFormat . graphConfig ) { return oldFormat }
936
929
937
- let newFormat = [ ] ;
930
+ const newFormat = [ ] ;
938
931
939
932
oldFormat . graphConfig . forEach ( ( element , id ) => {
940
933
if ( element ) {
@@ -957,10 +950,10 @@ function BlackboxLogViewer() {
957
950
}
958
951
959
952
function loadWorkspaces ( file ) {
960
- let reader = new FileReader ( ) ;
953
+ const reader = new FileReader ( ) ;
961
954
962
955
reader . onload = function ( e ) {
963
- let data = e . target . result ;
956
+ const data = e . target . result ;
964
957
let tmp = JSON . parse ( data ) ;
965
958
if ( tmp . graphConfig ) {
966
959
window . alert ( 'Old Workspace format. Upgrading...' ) ;
@@ -981,7 +974,7 @@ function BlackboxLogViewer() {
981
974
console . debug ( "Empty data, nothing to save" ) ;
982
975
return ;
983
976
}
984
- let blob = new Blob ( [ data ] , { type : fileType } ) ,
977
+ const blob = new Blob ( [ data ] , { type : fileType } ) ,
985
978
e = document . createEvent ( 'MouseEvents' ) ,
986
979
a = document . createElement ( 'a' ) ;
987
980
a . download = file || $ ( ".log-filename" ) . text ( ) + "." + fileExtension ;
@@ -1114,8 +1107,7 @@ function BlackboxLogViewer() {
1114
1107
} ) ;
1115
1108
1116
1109
$ ( ".file-open" ) . change ( function ( e ) {
1117
- let
1118
- files = e . target . files ;
1110
+ const files = e . target . files ;
1119
1111
1120
1112
loadFiles ( files ) ;
1121
1113
@@ -1163,7 +1155,7 @@ function BlackboxLogViewer() {
1163
1155
if ( activeGraphConfig . selectedFieldName != null ) {
1164
1156
hasAnalyser = ! hasAnalyser ;
1165
1157
} else {
1166
- let graphs = activeGraphConfig . getGraphs ( ) ;
1158
+ const graphs = activeGraphConfig . getGraphs ( ) ;
1167
1159
if ( graphs . length == 0 || graphs [ 0 ] . fields . length == 0 ) {
1168
1160
hasAnalyser = false ;
1169
1161
} else {
@@ -1225,7 +1217,7 @@ function BlackboxLogViewer() {
1225
1217
if ( slow ) { scrollTime = ( 1 / 60 ) * 1000000 ; } // Assume 60Hz video
1226
1218
setVideoTime ( video . currentTime - scrollTime / 1000000 ) ;
1227
1219
} else {
1228
- let currentFrame = flightLog . getCurrentFrameAtTime ( ( hasVideo ) ?video . currentTime :currentBlackboxTime ) ;
1220
+ const currentFrame = flightLog . getCurrentFrameAtTime ( ( hasVideo ) ?video . currentTime :currentBlackboxTime ) ;
1229
1221
if ( currentFrame && currentFrame . previous && slow ) {
1230
1222
setCurrentBlackboxTime ( currentFrame . previous [ FlightLogParser . prototype . FLIGHT_LOG_FIELD_INDEX_TIME ] ) ;
1231
1223
} else {
@@ -1245,7 +1237,7 @@ function BlackboxLogViewer() {
1245
1237
if ( slow ) { scrollTime = ( 1 / 60 ) * 1000000 ; } // Assume 60Hz video
1246
1238
setVideoTime ( video . currentTime + scrollTime / 1000000 ) ;
1247
1239
} else {
1248
- let currentFrame = flightLog . getCurrentFrameAtTime ( ( hasVideo ) ?video . currentTime :currentBlackboxTime ) ;
1240
+ const currentFrame = flightLog . getCurrentFrameAtTime ( ( hasVideo ) ?video . currentTime :currentBlackboxTime ) ;
1249
1241
if ( currentFrame && currentFrame . next && slow ) {
1250
1242
setCurrentBlackboxTime ( currentFrame . next [ FlightLogParser . prototype . FLIGHT_LOG_FIELD_INDEX_TIME ] ) ;
1251
1243
} else {
@@ -1386,7 +1378,7 @@ function BlackboxLogViewer() {
1386
1378
invalidateGraph ( ) ;
1387
1379
1388
1380
}
1389
- let
1381
+ const
1390
1382
graphConfigDialog = new GraphConfigurationDialog (
1391
1383
$ ( "#dlgGraphConfiguration" ) ,
1392
1384
function ( newConfig , redrawChart ) {
@@ -1402,7 +1394,7 @@ function BlackboxLogViewer() {
1402
1394
flightLog . setSysConfig ( newSysConfig ) ;
1403
1395
1404
1396
// Save Current Position then re-calculate all the log information
1405
- let activePosition = ( hasVideo ) ?video . currentTime :currentBlackboxTime ;
1397
+ const activePosition = ( hasVideo ) ?video . currentTime :currentBlackboxTime ;
1406
1398
1407
1399
selectLog ( null ) ;
1408
1400
if ( hasVideo ) {
@@ -1543,7 +1535,7 @@ function BlackboxLogViewer() {
1543
1535
$ ( window ) . resize ( function ( ) { updateCanvasSize ( ) ; /*updateHeaderSize()*/ } ) ;
1544
1536
1545
1537
function updateHeaderSize ( ) {
1546
- let newHeight = $ ( ".video-top-controls" ) . height ( ) - 20 ; // 23px offset
1538
+ const newHeight = $ ( ".video-top-controls" ) . height ( ) - 20 ; // 23px offset
1547
1539
$ ( ".log-graph" ) . css ( "top" , newHeight + "px" ) ;
1548
1540
$ ( ".log-graph-config" ) . css ( "top" , newHeight + "px" ) ;
1549
1541
$ ( ".log-seek-bar" ) . css ( "top" , newHeight + "px" ) ;
@@ -1732,7 +1724,7 @@ function BlackboxLogViewer() {
1732
1724
if ( e . which != 2 ) return ; // is it the middle mouse button, no, then ignore
1733
1725
1734
1726
if ( $ ( e . target ) . hasClass ( 'graph-legend-group' ) || $ ( e . target ) . hasClass ( 'graph-legend-field' ) ) {
1735
- let refreshRequired = restorePenDefaults ( activeGraphConfig . getGraphs ( ) , $ ( e . target ) . attr ( 'graph' ) , $ ( e . target ) . attr ( 'field' ) ) ;
1727
+ const refreshRequired = restorePenDefaults ( activeGraphConfig . getGraphs ( ) , $ ( e . target ) . attr ( 'graph' ) , $ ( e . target ) . attr ( 'field' ) ) ;
1736
1728
1737
1729
if ( refreshRequired ) {
1738
1730
graph . refreshGraphConfig ( ) ;
@@ -1752,7 +1744,7 @@ function BlackboxLogViewer() {
1752
1744
}
1753
1745
1754
1746
if ( graph && $ ( e . target ) . parents ( '.modal' ) . length == 0 ) {
1755
- let delta = Math . max ( - 1 , Math . min ( 1 , ( e . originalEvent . wheelDelta ) ) ) ;
1747
+ const delta = Math . max ( - 1 , Math . min ( 1 , ( e . originalEvent . wheelDelta ) ) ) ;
1756
1748
if ( delta != 0 ) {
1757
1749
if ( $ ( e . target ) . attr ( 'id' ) == 'graphCanvas' ) { // we are scrolling the graph
1758
1750
if ( delta < 0 ) { // scroll down (or left)
@@ -1801,7 +1793,7 @@ function BlackboxLogViewer() {
1801
1793
// Pressing any key hides dropdown menus
1802
1794
//$(".dropdown-toggle").dropdown("toggle");
1803
1795
1804
- let shifted = ( e . altKey || e . shiftKey || e . ctrlKey || e . metaKey ) ;
1796
+ const shifted = ( e . altKey || e . shiftKey || e . ctrlKey || e . metaKey ) ;
1805
1797
if ( e . which === 13 && e . target . type === 'text' && $ ( e . target ) . parents ( '.modal' ) . length == 0 ) {
1806
1798
// pressing return on a text field clears the focus.
1807
1799
$ ( e . target ) . blur ( ) ;
@@ -1899,7 +1891,7 @@ function BlackboxLogViewer() {
1899
1891
case "9" . charCodeAt ( 0 ) :
1900
1892
try {
1901
1893
if ( ! e . altKey ) { // Workspaces feature
1902
- let id = e . which - 48 ;
1894
+ const id = e . which - 48 ;
1903
1895
if ( ! e . shiftKey ) { // retrieve graph configuration from workspace
1904
1896
if ( workspaceGraphConfigs [ id ] != null ) {
1905
1897
onSwitchWorkspace ( workspaceGraphConfigs , id )
@@ -2058,7 +2050,7 @@ function BlackboxLogViewer() {
2058
2050
loadeddata : videoLoaded
2059
2051
} ) ;
2060
2052
2061
- let percentageFormat = {
2053
+ const percentageFormat = {
2062
2054
to : function ( value ) {
2063
2055
return value . toFixed ( 0 ) + "%" ;
2064
2056
} ,
@@ -2133,7 +2125,7 @@ function BlackboxLogViewer() {
2133
2125
const item = e . dataTransfer . items [ 0 ] ;
2134
2126
const entry = item . webkitGetAsEntry ( ) ;
2135
2127
if ( entry . isFile ) {
2136
- let file = e . dataTransfer . files [ 0 ] ;
2128
+ const file = e . dataTransfer . files [ 0 ] ;
2137
2129
loadFiles ( [ file ] ) ;
2138
2130
}
2139
2131
return false ;
@@ -2170,25 +2162,6 @@ function BlackboxLogViewer() {
2170
2162
}
2171
2163
} ) ;
2172
2164
2173
- // New workspaces feature; local storage of user configurations
2174
- prefs . get ( 'workspaceGraphConfigs' , function ( item ) {
2175
- if ( item ) {
2176
- workspaceGraphConfigs = upgradeWorkspaceFormat ( item ) ;
2177
- } else {
2178
- workspaceGraphConfigs = defaultWorkspaceGraphConfigs ;
2179
- }
2180
- } ) ;
2181
-
2182
- prefs . get ( 'activeWorkspace' , function ( id ) {
2183
- if ( id ) {
2184
- activeWorkspace = id
2185
- }
2186
- else {
2187
- activeWorkspace = 1
2188
- }
2189
- } ) ;
2190
- onSwitchWorkspace ( workspaceGraphConfigs , activeWorkspace ) ;
2191
-
2192
2165
// Get the offsetCache buffer
2193
2166
prefs . get ( 'offsetCache' , function ( item ) {
2194
2167
if ( item ) {
@@ -2201,7 +2174,7 @@ function BlackboxLogViewer() {
2201
2174
2202
2175
// Close the dropdowns if not clicking a descendant of the dropdown
2203
2176
$ ( document ) . click ( function ( e ) {
2204
- let p = $ ( e . target ) . closest ( ".dropdown" ) ;
2177
+ const p = $ ( e . target ) . closest ( ".dropdown" ) ;
2205
2178
if ( ! p . length ) {
2206
2179
$ ( ".dropdown" ) . removeClass ( "open" ) ;
2207
2180
}
0 commit comments