From eeda751f54fd67bb895541264fcf2b5eb91b2556 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 23 Aug 2014 17:28:55 +0100 Subject: Allow passing of keys to the underlying page (populate page popup with existing rule). --- pages/popup.coffee | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'pages') 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 -- cgit v1.2.3