diff options
| author | int3 | 2010-04-17 10:29:02 +0800 |
|---|---|---|
| committer | int3 | 2010-06-12 23:34:54 +0800 |
| commit | c3649ada9fb51f09cf4d229a2589955ad96d7413 (patch) | |
| tree | 09000bcc3c95f27bc76bb1523daa35c044e6f22c | |
| parent | 626d7be7d10884dd401996ef7b88049b420f42f9 (diff) | |
| download | vimium-c3649ada9fb51f09cf4d229a2589955ad96d7413.tar.bz2 | |
Add 'goUp' function. However, it does not support command repetition.
| -rw-r--r-- | commands.js | 4 | ||||
| -rw-r--r-- | vimiumFrontend.js | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/commands.js b/commands.js index de6ce701..2a180966 100644 --- a/commands.js +++ b/commands.js @@ -95,6 +95,7 @@ function clearKeyMappingsAndSetDefaults() { mapKeyToCommand('H', 'goBack'); mapKeyToCommand('L', 'goForward'); + mapKeyToCommand('gu', 'goUp'); mapKeyToCommand('zi', 'zoomIn'); mapKeyToCommand('zo', 'zoomOut'); @@ -150,6 +151,9 @@ addCommand('performBackwardsFind', 'Cycle backward to the previous find match'); addCommand('goBack', 'Go back in history'); addCommand('goForward', 'Go forward in history'); +// Navigating the URL hierarchy +addCommand('goUp', 'Go up the URL hierarchy'); + // Manipulating tabs: addCommand('nextTab', 'Go one tab right', true); addCommand('previousTab', 'Go one tab left', true); diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 4346d18f..c33e87db 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -200,6 +200,19 @@ function reload() { window.location.reload(); } function goBack() { history.back(); } function goForward() { history.forward(); } +function goUp() { + var url = window.location.href; + if (url[url.length-1] == '/') + url = url.substring(0, url.length - 1); + + var urlsplit = url.split('/'); + // make sure we haven't hit the base domain yet + if (urlsplit.length > 3) { + delete urlsplit[urlsplit.length-1]; + window.location.href = urlsplit.join('/'); + } +} + function toggleViewSource() { getCurrentUrlHandlers.push(toggleViewSourceCallback); |
