diff options
| -rw-r--r-- | CREDITS | 1 | ||||
| -rw-r--r-- | README.markdown | 3 | ||||
| -rw-r--r-- | commands.js | 7 | ||||
| -rw-r--r-- | vimiumFrontend.js | 39 |
4 files changed, 50 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..fb7f5673 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 '<'. Helpful for browsing paginated sites. Navigating your history: H go back in history @@ -88,6 +90,7 @@ Release Notes - Some sites are now excluded by default. - View source (`gs`) now opens in a new tab. +- Support for browsing paginated sites using `]]` and `[[` to go forward and backward respectively. - Bugfixes. 1.21 (10/24/2010) diff --git a/commands.js b/commands.js index 9c5b1562..7f30df97 100644 --- a/commands.js +++ b/commands.js @@ -119,6 +119,9 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('n', 'performFind'); mapKeyToCommand('N', 'performBackwardsFind'); + mapKeyToCommand('[[', 'goPrevious'); + mapKeyToCommand(']]', 'goNext'); + mapKeyToCommand('yy', 'copyCurrentUrl'); mapKeyToCommand('K', 'nextTab'); @@ -167,6 +170,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'); @@ -194,6 +200,7 @@ var commandGroups = { "reload", "toggleViewSource", "zoomIn", "zoomOut", "zoomReset", "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 e2884527..8c5f94db 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -555,6 +555,45 @@ function performBackwardsFind() { findModeQueryHasResults = window.find(findModeQuery, false, true, true, false, true, false); } +function findAndFollowLink(linkStrings) { + for (i = 0; i < linkStrings.length; i++) { + var findModeQueryHasResults = window.find(linkStrings[i], 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 true; + } + node = node.parentNode; + } + } + } +} + +function findAndFollowRel(value) { + var relTags = ['link', 'a', 'area']; + for (i = 0; i < relTags.length; i++) { + var elements = document.getElementsByTagName(relTags[i]); + for (j = 0; j < elements.length; j++) { + if (elements[j].hasAttribute('rel') && elements[j].rel == value) { + window.location = elements[j].href; + return true; + } + } + } +} + +function goPrevious() { + var previousStrings = ["\bprev\b","\bprevious\b","\u00AB","<<","<"]; + findAndFollowRel('prev') || findAndFollowLink(previousStrings); +} + +function goNext() { + var nextStrings = ["\bnext\b","\u00BB",">>","\bmore\b",">"]; + findAndFollowRel('next') || findAndFollowLink(nextStrings); +} + function showFindModeHUDForQuery() { if (findModeQueryHasResults || findModeQuery.length == 0) HUD.show("/" + insertSpaces(findModeQuery)); |
