diff options
Diffstat (limited to 'commands.js')
| -rw-r--r-- | commands.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/commands.js b/commands.js index e49574e3..635c5350 100644 --- a/commands.js +++ b/commands.js @@ -1,14 +1,17 @@ var availableCommands = {}; var keyToCommandRegistry = {}; -function addCommand(command, description, isBackgroundCommand) { +function addCommand(command, description, isBackgroundCommand, passCountToFunction) { if (availableCommands[command]) { console.log(command, "is already defined! Check commands.js for duplicates."); return; } - availableCommands[command] = { description: description, isBackgroundCommand: isBackgroundCommand }; + availableCommands[command] = { description: description, + isBackgroundCommand: isBackgroundCommand, + passCountToFunction: passCountToFunction + }; } function mapKeyToCommand(key, command) { @@ -18,7 +21,10 @@ function mapKeyToCommand(key, command) { return; } - keyToCommandRegistry[key] = { command: command, isBackgroundCommand: availableCommands[command].isBackgroundCommand }; + keyToCommandRegistry[key] = { command: command, + isBackgroundCommand: availableCommands[command].isBackgroundCommand, + passCountToFunction: availableCommands[command].passCountToFunction + }; } function unmapKey(key) { delete keyToCommandRegistry[key]; } @@ -80,7 +86,6 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('k', 'scrollUp'); mapKeyToCommand('h', 'scrollLeft'); mapKeyToCommand('l', 'scrollRight'); - mapKeyToCommand('gg', 'scrollToTop'); mapKeyToCommand('G', 'scrollToBottom'); mapKeyToCommand('zH', 'scrollToLeft'); @@ -103,6 +108,8 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('zi', 'zoomIn'); mapKeyToCommand('zo', 'zoomOut'); + mapKeyToCommand('gi', 'focusInput'); + mapKeyToCommand('f', 'activateLinkHintsMode'); mapKeyToCommand('F', 'activateLinkHintsModeToOpenInNewTab'); @@ -147,6 +154,8 @@ addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard'); addCommand('enterInsertMode', 'Enter insert mode'); +addCommand('focusInput', 'Focus the first (or n-th) text box on the page', false, true); + addCommand('activateLinkHintsMode', 'Enter link hints mode to open links in current tab'); addCommand('activateLinkHintsModeToOpenInNewTab', 'Enter link hints mode to open links in new tab'); @@ -176,9 +185,11 @@ addCommand('nextFrame', "Cycle forward to the next frame on the page", var commandGroups = { pageNavigation: ["scrollDown", "scrollUp", "scrollLeft", "scrollRight", - "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", "scrollPageUp", "scrollFullPageDown", + "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", + "scrollPageUp", "scrollFullPageDown", "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp", - "enterInsertMode", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", + "enterInsertMode", "focusInput", + "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"], historyNavigation: ["goBack", "goForward"], |
