diff options
| author | R.T. Lechow | 2011-01-04 19:02:53 -0500 |
|---|---|---|
| committer | R.T. Lechow | 2011-01-04 19:57:29 -0500 |
| commit | 5f944bc99c7cb25412d4f7a51b946b27a14ca77d (patch) | |
| tree | fff356a668877a2b2fe6b0473af2711a0f26a590 | |
| parent | fdc320339e8cbdf978fe2259f247eec2e182a65f (diff) | |
| download | vimium-5f944bc99c7cb25412d4f7a51b946b27a14ca77d.tar.bz2 | |
Commands for following 'previous' and 'next' links.
| -rw-r--r-- | CREDITS | 1 | ||||
| -rw-r--r-- | README.markdown | 2 | ||||
| -rw-r--r-- | commands.js | 7 | ||||
| -rw-r--r-- | vimiumFrontend.js | 26 |
4 files changed, 36 insertions, 0 deletions
@@ -19,5 +19,6 @@ Contributors: tsigo Werner Laurensse (github: ab3) Svein-Erik Larsen <feinom@gmail.com> (github: feinom) + R.T. Lechow <rtlechow@gmail.com> (github: rtlechow) Feel free to add real names in addition to GitHub usernames. diff --git a/README.markdown b/README.markdown index 3a9352ca..c83678ad 100644 --- a/README.markdown +++ b/README.markdown @@ -51,6 +51,8 @@ Navigating the current page: gu go up one level in the URL hierarchy gf cycle forward to the next frame gi focus the first (or n-th) text input box on the page + ]] Follow the link labeled 'next' or '>'. Helpful for browsing paginated sites. + [[ Follow the link labeled 'previous' or '<' if it exists. Helpful for browsing paginated sites. Navigating your history: H go back in history diff --git a/commands.js b/commands.js index 3b9203dc..7ee25520 100644 --- a/commands.js +++ b/commands.js @@ -118,6 +118,9 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('n', 'performFind'); mapKeyToCommand('N', 'performBackwardsFind'); + mapKeyToCommand('[[', 'goPrevious'); + mapKeyToCommand(']]', 'goNext'); + mapKeyToCommand('yy', 'copyCurrentUrl'); mapKeyToCommand('K', 'nextTab'); @@ -165,6 +168,9 @@ addCommand('enterFindMode', 'Enter find mode'); addCommand('performFind', 'Cycle forward to the next find match'); addCommand('performBackwardsFind', 'Cycle backward to the previous find match'); +addCommand('goPrevious', 'Follow the link labeled previous or <'); +addCommand('goNext', 'Follow the link labeled next or >'); + // Navigating your history: addCommand('goBack', 'Go back in history'); addCommand('goForward', 'Go forward in history'); @@ -192,6 +198,7 @@ var commandGroups = { "reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp", "enterInsertMode", "focusInput", "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activateLinkHintsModeWithQueue", + "goPrevious", "goNext", "enterFindMode", "performFind", "performBackwardsFind", "nextFrame"], historyNavigation: ["goBack", "goForward"], diff --git a/vimiumFrontend.js b/vimiumFrontend.js index eb3de996..0ee3f762 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -550,6 +550,32 @@ function performBackwardsFind() { findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false); } +function findAndFollowLink(linkStrings) { + linkStrings.forEach(function(findModeQuery) { + findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false); + if (findModeQueryHasResults) { + var node = window.getSelection().anchorNode; + while (node.nodeName != 'BODY') { + if (node.nodeName == 'A') { + window.location = node.href; + return; + } + node = node.parentNode; + } + } + }); +} + +function goPrevious() { + previousStrings = ["\bprev\b","\bprevious\b","\u00AB","<<","<"]; + findAndFollowLink(previousStrings); +} + +function goNext() { + nextStrings = ["\bnext\b","\u00BB",">>","\bmore\b",">"]; + findAndFollowLink(nextStrings); +} + function showFindModeHUDForQuery() { if (findModeQueryHasResults || findModeQuery.length == 0) HUD.show("/" + insertSpaces(findModeQuery)); |
