@@ -39,6 +39,9 @@ function BlackboxLogViewer() {
39
39
// JSON graph configuration:
40
40
graphConfig = { } ,
41
41
42
+ offsetCache = [ ] , // Storage for the offset cache (last 20 files)
43
+ currentOffsetCache = { log :null , index :null , video :null , offset :null } ,
44
+
42
45
// JSON array of graph configurations for New Workspaces feature
43
46
lastGraphConfig = null , // Undo feature - go back to last configuration.
44
47
workspaceGraphConfigs = { } , // Workspaces
@@ -100,7 +103,7 @@ function BlackboxLogViewer() {
100
103
*/
101
104
$ ( ".video-offset" ) . val ( ( videoOffset >= 0 ? "+" : "" ) + ( videoOffset . toFixed ( 3 ) != videoOffset ? videoOffset . toFixed ( 3 ) : videoOffset ) ) ;
102
105
103
- if ( wihtoutRefresh ) invalidateGraph ( ) ;
106
+ if ( withoutRefresh ) invalidateGraph ( ) ;
104
107
}
105
108
106
109
function isInteger ( value ) {
@@ -434,6 +437,7 @@ function BlackboxLogViewer() {
434
437
for ( var i = 0 ; i < flightLog . getLogCount ( ) ; i ++ ) {
435
438
if ( flightLog . openLog ( i ) ) {
436
439
success = true ;
440
+ currentOffsetCache . index = i ;
437
441
break ;
438
442
}
439
443
}
@@ -443,9 +447,11 @@ function BlackboxLogViewer() {
443
447
}
444
448
} else {
445
449
flightLog . openLog ( logIndex ) ;
450
+ currentOffsetCache . index = logIndex ;
446
451
}
447
452
} catch ( e ) {
448
453
alert ( "Error opening log: " + e ) ;
454
+ currentOffsetCache . index = null ;
449
455
return ;
450
456
}
451
457
@@ -510,6 +516,8 @@ function BlackboxLogViewer() {
510
516
}
511
517
512
518
renderLogFileInfo ( file ) ;
519
+ currentOffsetCache . log = file . name ; // store the name of the loaded log file
520
+ currentOffsetCache . index = null ; // and clear the index
513
521
514
522
hasLog = true ;
515
523
$ ( "html" ) . addClass ( "has-log" ) ;
@@ -524,13 +532,15 @@ function BlackboxLogViewer() {
524
532
}
525
533
526
534
function loadVideo ( file ) {
535
+ currentOffsetCache . video = file . name ; // store the name of the loaded video
527
536
if ( videoURL ) {
528
537
URL . revokeObjectURL ( videoURL ) ;
529
538
videoURL = false ;
530
539
}
531
540
532
541
if ( ! URL . createObjectURL ) {
533
542
alert ( "Sorry, your web browser doesn't support showing videos from your local computer. Try Google Chrome instead." ) ;
543
+ currentOffsetCache . video = null ; // clear the associated video name
534
544
return ;
535
545
}
536
546
@@ -634,6 +644,13 @@ function BlackboxLogViewer() {
634
644
] } ;
635
645
}
636
646
} ) ;
647
+
648
+ // Get the offsetCache buffer
649
+ prefs . get ( 'offsetCache' , function ( item ) {
650
+ if ( item ) {
651
+ offsetCache = item ;
652
+ }
653
+ } )
637
654
638
655
activeGraphConfig . addListener ( function ( ) {
639
656
invalidateGraph ( ) ;
@@ -677,12 +694,11 @@ function BlackboxLogViewer() {
677
694
}
678
695
} ) ;
679
696
680
-
681
697
$ ( ".file-open" ) . change ( function ( e ) {
682
698
var
683
699
files = e . target . files ,
684
700
i ;
685
-
701
+
686
702
for ( i = 0 ; i < files . length ; i ++ ) {
687
703
var
688
704
isLog = files [ i ] . name . match ( / \. ( T X T | C F L | L O G ) $ / i) ,
@@ -701,8 +717,19 @@ function BlackboxLogViewer() {
701
717
loadVideo ( files [ i ] ) ;
702
718
}
703
719
}
704
- } ) ;
705
720
721
+ // finally, see if there is an offsetCache value already, and auto set the offset
722
+ for ( i = 0 ; i < offsetCache . length ; i ++ ) {
723
+ if (
724
+ ( currentOffsetCache . log == offsetCache [ i ] . log ) &&
725
+ ( currentOffsetCache . index == offsetCache [ i ] . index ) &&
726
+ ( currentOffsetCache . video == offsetCache [ i ] . video ) ) {
727
+ setVideoOffset ( offsetCache [ i ] . offset , true ) ;
728
+ }
729
+
730
+ }
731
+ } ) ;
732
+
706
733
// New View Controls
707
734
$ ( ".view-craft" ) . click ( function ( ) {
708
735
hasCraft = ! hasCraft ;
@@ -814,7 +841,14 @@ function BlackboxLogViewer() {
814
841
var offset = parseFloat ( $ ( ".video-offset" ) . val ( ) ) ;
815
842
816
843
if ( ! isNaN ( offset ) ) {
817
- videoOffset = offset ;
844
+ videoOffset = offset ;
845
+ // Store the video offset to the local cache
846
+ currentOffsetCache . offset = offset ;
847
+ if ( hasLog && hasVideo ) {
848
+ if ( offsetCache . length > 20 ) offsetCache . shift ( ) ;
849
+ offsetCache . push ( currentOffsetCache ) ;
850
+ prefs . set ( 'offsetCache' , offsetCache ) ;
851
+ }
818
852
invalidateGraph ( ) ;
819
853
}
820
854
} ) ;
@@ -853,10 +887,11 @@ function BlackboxLogViewer() {
853
887
headerDialog = new HeaderDialog ( $ ( "#dlgHeaderDialog" ) , function ( newSysConfig ) {
854
888
if ( newSysConfig != null ) {
855
889
prefs . set ( 'lastHeaderData' , newSysConfig ) ;
856
- // flightLog.setSysConfig(newSysConfig);
890
+ flightLog . setSysConfig ( newSysConfig ) ;
857
891
858
892
// Save Current Position then re-calculate all the log information
859
893
var activePosition = ( hasVideo ) ?video . currentTime :currentBlackboxTime ;
894
+
860
895
selectLog ( null ) ;
861
896
if ( hasVideo ) {
862
897
setVideoTime ( activePosition ) ;
0 commit comments