Fossil

Check-in [115b484992]
Login

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

Overview
Comment:Access the hidden input field used for back/forward caching via dedicated functions, and let browsers do the buffering of `document.getElementById()' results themselves.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | timeline-keyboard-navigation
Files: files | file ages | folders
SHA3-256: 115b4849922ba9f72b38e16b3aeb360be75ea88fa9a43eb32ead769ea19eab32
User & Date: florian 2022-08-04 03:35:00.000
Context
2022-08-04
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)
03:34
Merge with trunk to get the latest web UI updates. ... (check-in: 0f9981971e user: florian tags: timeline-keyboard-navigation)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/graph.js.
887
888
889
890
891
892
893

894
895
896
897
898
899
900
901
902










903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919

920
921
922
923
924
925
926
927
928
929
930
931
932
933
            else td.scrollIntoView(false);
          }
          return true;
        }
      }
      return false;
    }

    var kf = document.getElementById('timeline-kbfocus');
    if( !kf ){
      kf = document.createElement('input');
      kf.type = 'text';
      kf.style.display = 'none';
      kf.style.visibility = 'hidden';
      kf.id = 'timeline-kbfocus';
      document.body.appendChild(kf);
    }










    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;
      var kf = document.getElementById('timeline-kbfocus');
      if( key==kDONE ){
        kf.value = '';

        focusVisualize(null,false);
        document.cookie =
          'fossil_timeline_kbnav=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/';
        return;
      }
      document.cookie = 'fossil_timeline_kbnav=1;path=/';
      var id = kf.value;
      if( id && dx==0 ){
        var ri = timelineGetRowInfo(id);
        if( ri ){
          var page = key==kVIEW ? '/info/' : '/timeline?c=';
          var href = ri.baseurl + page + encodeURIComponent(ri.hash);
          if( href!=location.href.slice(-href.length) ){
            location.href = href;







>
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>














<

<
>






|







887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
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
935
936
937
938
939
940
941
942
943
            else td.scrollIntoView(false);
          }
          return true;
        }
      }
      return false;
    }
    function focusCacheInit(){
      var e = document.getElementById('timeline-kbfocus');
      if( !e ){
        e = document.createElement('input');
        e.type = 'text';
        e.style.display = 'none';
        e.style.visibility = 'hidden';
        e.id = 'timeline-kbfocus';
        document.body.appendChild(e);
      }
    }
    function focusCacheGet(){
      var e = document.getElementById('timeline-kbfocus');
      return e ? e.value : null;
    }
    function focusCacheSet(v){
      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;
      }
      document.cookie = 'fossil_timeline_kbnav=1;path=/';
      var id = focusCacheGet();
      if( id && dx==0 ){
        var ri = timelineGetRowInfo(id);
        if( ri ){
          var page = key==kVIEW ? '/info/' : '/timeline?c=';
          var href = ri.baseurl + page + encodeURIComponent(ri.hash);
          if( href!=location.href.slice(-href.length) ){
            location.href = href;
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
          var btn =
            document.querySelector('.tl-button-' + ( dx>0 ? 'prev' : 'next' ));
          if( btn ) btn.click();
          return;
        }
      }
      else if ( !id ) id = focusDefaultId();
      kf.value = id;
      focusVisualize(id,true);
    }/*,true*/);
    window.addEventListener('pageshow',function(evt){
      var id;
      var kf = document.getElementById('timeline-kbfocus');
      if( kf ) id = kf.value;
      if( !id || !focusVisualize(id,false) ){
        if( document.cookie.match(/fossil_timeline_kbnav=1/) ){
          id = focusDefaultId();
          kf.value = id;
          focusVisualize(id,false);
        }
      }
    },false);
  },false);
}());







|



|
<
<



|






951
952
953
954
955
956
957
958
959
960
961
962


963
964
965
966
967
968
969
970
971
972
          var btn =
            document.querySelector('.tl-button-' + ( dx>0 ? 'prev' : 'next' ));
          if( btn ) btn.click();
          return;
        }
      }
      else if ( !id ) id = focusDefaultId();
      focusCacheSet(id);
      focusVisualize(id,true);
    }/*,true*/);
    window.addEventListener('pageshow',function(evt){
      var id = focusCacheGet();


      if( !id || !focusVisualize(id,false) ){
        if( document.cookie.match(/fossil_timeline_kbnav=1/) ){
          id = focusDefaultId();
          focusCacheSet(id);
          focusVisualize(id,false);
        }
      }
    },false);
  },false);
}());