aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index b108d141..16f0fdde 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -26,6 +26,17 @@ var linkHintCss;
// TODO(philc): This should be pulled from the extension's storage when the page loads.
var currentZoomLevel = 100;
+// The types in <input type="..."> that we consider for focusInput command. Right now this is recalculated in
+// each content script. Alternatively we could calculate it once in the background page and use a request to
+// fetch it each time.
+//
+// Should we include the HTML5 date pickers here?
+var textInputTypes = ["text", "search", "email", "url", "number"];
+// The corresponding XPath for such elements.
+var textInputXPath = '//input[' +
+ textInputTypes.map(function (type) { return '@type="' + type + '"'; }).join(" or ") +
+ ' or not(@type)]';
+
/*
* Give this frame a unique id.
*/
@@ -232,8 +243,8 @@ function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); }
function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); }
function focusInput(count) {
- var xpath = '//input[@type="text" or @type="search"]';
- var results = document.evaluate(xpath, document.documentElement, null,
+ var results = document.evaluate(textInputXPath,
+ document.documentElement, null,
XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
var lastInputBox;