diff options
| author | ilya | 2010-09-10 22:20:21 -0700 |
|---|---|---|
| committer | ilya | 2010-09-10 22:31:46 -0700 |
| commit | 31ddc715c9cae4502e2e0b18aeea11ce9198bc47 (patch) | |
| tree | 40f266be0c305d0a3e4dc057bfd227b002b845c3 /vimiumFrontend.js | |
| parent | 827d7032b6ef7fc1e4f638f8c69b060d895e2c52 (diff) | |
| download | vimium-31ddc715c9cae4502e2e0b18aeea11ce9198bc47.tar.bz2 | |
Make 'gi' compatible with repetition, i.e. 5gi will focus the fifth input box on the page.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index d74c6d53..7677f96c 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -76,7 +76,11 @@ function initializePreDomReady() { if (port.name == "executePageCommand") { port.onMessage.addListener(function(args) { if (this[args.command]) { - for (var i = 0; i < args.count; i++) { this[args.command].call(); } + if (args.passCountToFunction) { + this[args.command].call(null, args.count); + } else { + for (var i = 0; i < args.count; i++) { this[args.command].call(); } + } } refreshCompletionKeys(args.completionKeys); @@ -198,13 +202,25 @@ function scrollFullPageDown() { window.scrollBy(0, window.innerHeight); } function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); } function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); } -function focusFirstInput() { +function focusInput(count) { var xpath = '//input[@type="text" or @type="search"]'; - var result = document.evaluate(xpath, document.documentElement, null, - XPathResult.FIRST_ORDERED_NODE_TYPE, null); - if (!result.singleNodeValue) - return; - result.singleNodeValue.focus(); + var results = document.evaluate(xpath, document.documentElement, null, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); + + var lastInputBox; + var i = 0; + + while (i < count) + { + i += 1; + + var currentInputBox = results.iterateNext(); + if (!currentInputBox) { break; } + + lastInputBox = currentInputBox; + } + + if (lastInputBox) { lastInputBox.focus(); } } function reload() { window.location.reload(); } |
