1import { click, find, findAll } from 'reader/helpers/dom-utils'; 2import KeyStroke from 'reader/KeyStroke'; 3 4export default () => { 5 function enable() { 6 KeyStroke.enable(); 7 $('.toggleKeyboardShortcuts').text($('#menuKeyboardShortcutsOff').text()); 8 } 9 10 function disable() { 11 KeyStroke.disable(); 12 $('.toggleKeyboardShortcuts').text($('#menuKeyboardShortcutsOn').text()); 13 } 14 15 // Initial setup to update state from cookie 16 if (KeyStroke.isEnabled()) { 17 enable(); 18 } else { 19 disable(); 20 } 21 22 const triggers = findAll('.toggleKeyboardShortcuts'); 23 24 triggers.forEach((t) => { 25 click(t, () => { 26 if (KeyStroke.isEnabled()) { 27 disable(); 28 } else { 29 enable(); 30 } 31 }); 32 }); 33 34 if (find('#basic-shortcuts')) { 35 KeyStroke.register(['KeyH'], () => { 36 window.location = '/'; 37 }); 38 39 KeyStroke.register(['Slash'], (e) => { 40 e.preventDefault(); 41 42 const search = find('#search-term'); 43 search.focus(); 44 search.select(); 45 }); 46 } 47};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.