aboutsummaryrefslogtreecommitdiffstats
path: root/popup.js
diff options
context:
space:
mode:
authorDaniel MacDougall2012-08-18 22:58:15 -0700
committerDaniel MacDougall2012-08-18 22:58:20 -0700
commita3fb35be007a44e5ba35e5ee9d75af3634bf5dac (patch)
treeb6a81e3e09d77e32d4f36ea2eec210a50235e781 /popup.js
parentc21b62e9d1645dc09af7e8a57761e57e3bb7c49d (diff)
downloadvimium-a3fb35be007a44e5ba35e5ee9d75af3634bf5dac.tar.bz2
Move inline popup javascript to popup.js
Diffstat (limited to 'popup.js')
-rw-r--r--popup.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/popup.js b/popup.js
new file mode 100644
index 00000000..859f30f3
--- /dev/null
+++ b/popup.js
@@ -0,0 +1,20 @@
+function onLoad() {
+ document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html"));
+ chrome.tabs.getSelected(null, function(tab) {
+ // The common use case is to disable Vimium at the domain level.
+ // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html".
+ var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url;
+ document.getElementById("popupInput").value = domain + "*";
+ });
+}
+
+function onExcludeUrl(e) {
+ var url = document.getElementById("popupInput").value;
+ chrome.extension.getBackgroundPage().addExcludedUrl(url);
+ document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block");
+}
+
+document.addEventListener("DOMContentLoaded", function() {
+ document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false);
+ onLoad();
+});