Check-in [145df5a3e1]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Shortcuts SHIFT+N and SHIFT+M to put focus the first (topmost) or last (bottommost) entry.
Timelines: family | ancestors | descendants | both | timeline-keyboard-navigation
Files: files | file ages | folders
SHA3-256: 145df5a3e10a7fb1507111020a078d815caaf97ac6328258707d7250716a4c6d
User & Date: florian 2022-08-04 03:41:00.000
Context
2022-08-04
03:45
Shortcut "," (comma) to tick/untick the node of the currently focused entry. This has the same effect as mouse clicks, i.e. as soon as two nodes are ticked, the corresponding diff page is opened. check-in: 15f943f0c2 user: florian tags: timeline-keyboard-navigation
03:41
Shortcuts SHIFT+N and SHIFT+M to put focus the first (topmost) or last (bottommost) entry. check-in: 145df5a3e1 user: florian tags: timeline-keyboard-navigation
03:35
Access the hidden input field used for back/forward caching via dedicated functions, and let browsers do the buffering of `document.getElementById()' results themselves. check-in: 115b484992 user: florian tags: timeline-keyboard-navigation
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/graph.js.
850
851
852
853
854
855
856
857








858


859
860
861
862
863
864
865
*/
(function(){
  window.addEventListener('load',function(){
    function focusDefaultId(){
      var tn = document.querySelector('.timelineSelected .tl-nodemark') ||
                document.querySelector('.timelineCurrent .tl-nodemark');
      return tn ? tn.id : 'm1';
    }








    function focusNextId(id,dx){


      var m = /^m(\d+)$/.exec(id);
      return m!==null ? 'm' + (parseInt(m[1]) + dx) : null;
    }
    function timelineGetDataBlock(i){
      var tb = document.getElementById('timeline-data-' + i);
      return tb ? JSON.parse(tb.textContent || tb.innerText) : null;
    }








>
>
>
>
>
>
>
>

>
>







850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
*/
(function(){
  window.addEventListener('load',function(){
    function focusDefaultId(){
      var tn = document.querySelector('.timelineSelected .tl-nodemark') ||
                document.querySelector('.timelineCurrent .tl-nodemark');
      return tn ? tn.id : 'm1';
    }
    function focusFirstId(id){
      return 'm1';
    }
    function focusLastId(id){
      var el = document.getElementsByClassName('tl-nodemark');
      var tn = el ? el[el.length-1] : null;
      return tn ? tn.id : id;
    }
    function focusNextId(id,dx){
      if( dx<-1 ) return focusFirstId(id);
      if( dx>+1 ) return focusLastId(id);
      var m = /^m(\d+)$/.exec(id);
      return m!==null ? 'm' + (parseInt(m[1]) + dx) : null;
    }
    function timelineGetDataBlock(i){
      var tb = document.getElementById('timeline-data-' + i);
      return tb ? JSON.parse(tb.textContent || tb.innerText) : null;
    }
910
911
912
913
914
915
916


917
918

919
920
921
922
923
924
925

926





927

928
929
930
931
932
933
934
      var e = document.getElementById('timeline-kbfocus');
      if( e ) e.value = v;
    }
    focusCacheInit();
    document.addEventListener('keydown',function(evt){
      if( evt.target.tagName=='INPUT' ) return;
      var


        kNEXT = 78 /* N */,
        kPREV = 77 /* M */,

        kTMLN = 74 /* J */,
        kVIEW = 75 /* K */,
        kDONE = 76 /* L */,
        mod = evt.altKey<<15 | evt.ctrlKey<<14 | evt.shiftKey<<13,
        key = ( evt.which || evt.keyCode ) | mod;
      var dx = 0;
      if( key==kPREV ) dx++;

      else if( key==kNEXT ) dx--;





      else if( key!=kTMLN && key!=kVIEW && key!=kDONE ) return;

      if( key==kDONE ){
        focusCacheSet(null);
        focusVisualize(null,false);
        document.cookie =
          'fossil_timeline_kbnav=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
        return;
      }







>
>


>






|
>
|
>
>
>
>
>
|
>







920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
      var e = document.getElementById('timeline-kbfocus');
      if( e ) e.value = v;
    }
    focusCacheInit();
    document.addEventListener('keydown',function(evt){
      if( evt.target.tagName=='INPUT' ) return;
      var
        mSHIFT = 1<<13,
        kFRST = mSHIFT | 78 /* SHIFT+N */,
        kNEXT = 78 /* N */,
        kPREV = 77 /* M */,
        kLAST = mSHIFT | 77 /* SHIFT+M */,
        kTMLN = 74 /* J */,
        kVIEW = 75 /* K */,
        kDONE = 76 /* L */,
        mod = evt.altKey<<15 | evt.ctrlKey<<14 | evt.shiftKey<<13,
        key = ( evt.which || evt.keyCode ) | mod;
      var dx = 0;
      switch( key ){
        case kFRST: dx = -2; break;
        case kNEXT: dx = -1; break;
        case kPREV: dx = +1; break;
        case kLAST: dx = +2; break;
        case kTMLN: break;
        case kVIEW: break;
        case kDONE: break;
        default: return;
      }
      if( key==kDONE ){
        focusCacheSet(null);
        focusVisualize(null,false);
        document.cookie =
          'fossil_timeline_kbnav=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
        return;
      }