aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorjez2010-12-31 11:18:01 +0800
committerjez2010-12-31 11:18:01 +0800
commit83be3670b293fa78a8c74d092be9f6c4cdb6d66b (patch)
tree175e7768c25543a58f4c89095f4dc942d95673f4 /vimiumFrontend.js
parent489ff3f8f0f7b44817a09472b5b1e2fad46d7632 (diff)
parent1fd0a389ffe7460ac1c658227f0627c050153632 (diff)
downloadvimium-83be3670b293fa78a8c74d092be9f6c4cdb6d66b.tar.bz2
Merge remote branch 'origin/master' into filter-hints
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js24
1 files changed, 18 insertions, 6 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index dac778cb..7289c135 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.
*/
@@ -245,8 +256,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;
@@ -268,7 +279,7 @@ function reload() { window.location.reload(); }
function goBack() { history.back(); }
function goForward() { history.forward(); }
-function goUp() {
+function goUp(count) {
var url = window.location.href;
if (url[url.length-1] == '/')
url = url.substring(0, url.length - 1);
@@ -276,7 +287,7 @@ function goUp() {
var urlsplit = url.split('/');
// make sure we haven't hit the base domain yet
if (urlsplit.length > 3) {
- delete urlsplit[urlsplit.length-1];
+ urlsplit = urlsplit.slice(0, Math.max(3, urlsplit.length - count));
window.location.href = urlsplit.join('/');
}
}
@@ -638,6 +649,7 @@ HUD = {
"bottom: 0px;" +
"color: black;" +
"height: 13px;" +
+ "width: auto;" +
"max-width: 400px;" +
"min-width: 150px;" +
"text-align: left;" +
@@ -800,8 +812,8 @@ Tween = {
function addCssToPage(css) {
var head = document.getElementsByTagName("head")[0];
if (!head) {
- console.log("Warning: unable to add CSS to the page.");
- return;
+ head = document.createElement("head");
+ document.documentElement.appendChild(head);
}
var style = document.createElement("style");
style.type = "text/css";