diff options
| author | ilya | 2009-10-31 16:12:30 -0700 |
|---|---|---|
| committer | ilya | 2009-10-31 16:12:30 -0700 |
| commit | 5114f0235e455e2bc43a12c624e82849c273d9d1 (patch) | |
| tree | e374acb77682ef5be22780bca231a35109ad83d6 | |
| parent | 10c33ba614356d39d601a34bd1e4029ffa9dd124 (diff) | |
| download | vimium-5114f0235e455e2bc43a12c624e82849c273d9d1.tar.bz2 | |
Initial support for counts. Commands like '5j' and '5t' work pretty well. '5d' and '5u' need some love.
| -rw-r--r-- | background_page.html | 20 | ||||
| -rw-r--r-- | vimiumFrontend.js | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/background_page.html b/background_page.html index 077466b1..299ab901 100644 --- a/background_page.html +++ b/background_page.html @@ -41,23 +41,33 @@ } function checkKeyQueue() { - if (keyToCommandRegistry[keyQueue]) + var match = /([0-9]*)(.*)/.exec(keyQueue); + var count = parseInt(match[1]); + var command = match[2]; + + if (command.length == 0) { return; } + if (isNaN(count)) { count = 1; } + + if (keyToCommandRegistry[command]) { - registryEntry = keyToCommandRegistry[keyQueue]; + registryEntry = keyToCommandRegistry[command]; console.log("command found for [", keyQueue, "],", registryEntry); if (typeof(registryEntry) == "string") { chrome.tabs.getSelected(null, function (tab) { var port = chrome.tabs.connect(tab.id, {name: "executePageCommand"}); - port.postMessage({command: registryEntry}); + port.postMessage({command: registryEntry, count: count}); }); } - else { registryEntry.call(); } + else + { + for (var i = 0; i < count; i++) { registryEntry.call(); } + } keyQueue = ""; } - else if (keyQueue.length > 1) + else if (command.length > 1) keyQueue = ""; } </script> diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 7b0c37d5..892bdb34 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -21,7 +21,9 @@ chrome.extension.onConnect.addListener(function (port, name) { { port.onMessage.addListener(function (args) { if (this[args.command]) - this[args.command].call(); + { + for (var i = 0; i < args.count; i++) { this[args.command].call(); } + } }); } }); |
