File tree 2 files changed +45
-0
lines changed
2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -654,6 +654,13 @@ class Constants {
654
654
655
655
clientToken = null ;
656
656
657
+ /**
658
+ * Mark and recall vars. Used to store the current mark and recall state of the chart.
659
+ * @type {Array<number> }
660
+ * @default Array(10).fill(null)
661
+ */
662
+ mark = Array ( 10 ) . fill ( null ) ;
663
+
657
664
/**
658
665
* Stops the autoplay if it is currently running.
659
666
*
Original file line number Diff line number Diff line change @@ -548,6 +548,44 @@ class Control {
548
548
} ,
549
549
] ) ;
550
550
551
+ // mark and recall
552
+ // mark with M + # (0-9), recall with m + # (0-9)
553
+ // available in chart and braille, not review
554
+ let lastKeytime = 0 ;
555
+ let lastKey = null ;
556
+ constants . events . push ( [
557
+ [ constants . chart , constants . brailleInput ] ,
558
+ 'keydown' ,
559
+ function ( e ) {
560
+ // setup
561
+ const now = new Date ( ) . getTime ( ) ;
562
+ const key = e . key ;
563
+
564
+ // check for keypress within threshold
565
+ if ( now - lastKeytime < constants . keypressInterval ) {
566
+ // mark with M
567
+ if ( lastKey == 'M' && / [ 0 - 9 ] / . test ( key ) ) {
568
+ const markIndex = parseInt ( key , 10 ) ;
569
+ constants . mark [ markIndex ] = JSON . parse ( JSON . stringify ( position ) ) ; // deep copy
570
+ display . announceText ( 'Marked position ' + markIndex ) ;
571
+ }
572
+
573
+ // recall with m
574
+ if ( lastKey == 'm' && / [ 0 - 9 ] / . test ( key ) ) {
575
+ const recallIndex = parseInt ( key , 10 ) ;
576
+ if ( constants . mark [ recallIndex ] ) {
577
+ position = constants . mark [ recallIndex ] ;
578
+ control . UpdateAll ( ) ;
579
+ }
580
+ }
581
+ }
582
+
583
+ // update last key and time
584
+ lastKey = key ;
585
+ lastKeytime = now ;
586
+ } ,
587
+ ] ) ;
588
+
551
589
// Init a few things
552
590
let lastPlayed = '' ;
553
591
if ( [ ] . concat ( singleMaidr . type ) . includes ( 'bar' ) ) {
You can’t perform that action at this time.
0 commit comments