aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorPhil Crosby2010-09-05 15:38:37 -0700
committerPhil Crosby2010-09-05 15:41:20 -0700
commitce2093fcfef6f7000edc7eae026c7d529273199d (patch)
tree2223d241dbe987af662fde2590b7b66b4ace3b38 /vimiumFrontend.js
parentaf6d4cef077149dbc8b9be3d96e595404ddd5156 (diff)
downloadvimium-ce2093fcfef6f7000edc7eae026c7d529273199d.tar.bz2
Implemented "gi" feature to focus first input element
Conflicts: commands.js
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index e288714a..f2f5abd3 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -198,6 +198,19 @@ function scrollFullPageDown() { window.scrollBy(0, window.innerHeight); }
function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); }
function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); }
+function focusFirstInput() {
+ 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 == null ) return;
+
+ var el = document.getElementById( result.singleNodeValue.id );
+ if ( el ) {
+ el.focus();
+ }
+}
+
function reload() { window.location.reload(); }
function goBack() { history.back(); }
function goForward() { history.forward(); }