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 /background_page.html | |
| 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.
Diffstat (limited to 'background_page.html')
| -rw-r--r-- | background_page.html | 20 |
1 files changed, 15 insertions, 5 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> |
