aboutsummaryrefslogtreecommitdiffstats
path: root/pages
diff options
context:
space:
mode:
authorStephen Blott2014-08-23 17:28:55 +0100
committerStephen Blott2014-08-23 17:28:55 +0100
commiteeda751f54fd67bb895541264fcf2b5eb91b2556 (patch)
tree6396afc561ae66dba3ed96fa92a4a6fcde860297 /pages
parent951f8839d02a8d85747d86ccd09efc0ee3a72501 (diff)
downloadvimium-eeda751f54fd67bb895541264fcf2b5eb91b2556.tar.bz2
Allow passing of keys to the underlying page (populate page popup with existing rule).
Diffstat (limited to 'pages')
-rw-r--r--pages/popup.coffee17
1 files changed, 13 insertions, 4 deletions
diff --git a/pages/popup.coffee b/pages/popup.coffee
index 6d7afafc..5332a596 100644
--- a/pages/popup.coffee
+++ b/pages/popup.coffee
@@ -1,10 +1,19 @@
onLoad = ->
document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html")
chrome.tabs.getSelected null, (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".
- domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) or tab.url
- document.getElementById("popupInput").value = domain + "*"
+ # Check if we have an existing exclusing rule for this page.
+ isEnabled = chrome.extension.getBackgroundPage().isEnabledForUrl(url: tab.url)
+ if isEnabled.matchingUrl
+ # There is an existing rule for this page.
+ pattern = isEnabled.matchingUrl
+ pattern += " " + isEnabled.passKeys if isEnabled.passKeys
+ document.getElementById("popupInput").value = pattern
+ else
+ # No existing exclusion rule.
+ # 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".
+ domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) or tab.url
+ document.getElementById("popupInput").value = domain + "*"
onExcludeUrl = (e) ->
url = document.getElementById("popupInput").value