From 064a8b523ea53d4999bbd5987be5dc3db5caa4c8 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 28 Dec 2010 22:30:35 +0800 Subject: Add command repetition for goUp command. Closes #179. --- commands.js | 2 +- vimiumFrontend.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/commands.js b/commands.js index c86b129f..3b9203dc 100644 --- a/commands.js +++ b/commands.js @@ -170,7 +170,7 @@ addCommand('goBack', 'Go back in history'); addCommand('goForward', 'Go forward in history'); // Navigating the URL hierarchy -addCommand('goUp', 'Go up the URL hierarchy'); +addCommand('goUp', 'Go up the URL hierarchy', false, true); // Manipulating tabs: addCommand('nextTab', 'Go one tab right', true); diff --git a/vimiumFrontend.js b/vimiumFrontend.js index e3c28371..a18c7966 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -266,7 +266,7 @@ function reload() { window.location.reload(); } function goBack() { history.back(); } function goForward() { history.forward(); } -function goUp() { +function goUp(count) { var url = window.location.href; if (url[url.length-1] == '/') url = url.substring(0, url.length - 1); @@ -274,7 +274,7 @@ function goUp() { var urlsplit = url.split('/'); // make sure we haven't hit the base domain yet if (urlsplit.length > 3) { - delete urlsplit[urlsplit.length-1]; + urlsplit = urlsplit.slice(0, Math.max(3, urlsplit.length - count)); window.location.href = urlsplit.join('/'); } } -- cgit v1.2.3