From 25ebcf13c2510c20caa52d230abbb29a3e91459b Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 21 Oct 2012 13:13:07 +0100 Subject: Configurable vomnibox default/fallback search engine. --- lib/utils.coffee | 15 ++++++++++++++- options/options.coffee | 5 +++-- options/options.html | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/utils.coffee b/lib/utils.coffee index a2221ba4..e4debe71 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -92,7 +92,18 @@ Utils = # Creates a search URL from the given :query. createSearchUrl: (query) -> # Escape explicitly to encode characters like "+" correctly - "http://www.google.com/search?q=" + encodeURIComponent(query) + # "http://www.google.com/search?q=" + encodeURIComponent(query) + # + # 1. pull default search engine from settungs + # 2. don't URLencode the "+", Google (and other search engines) doesn't + # require it, so it's probably ok + # + # note: query is already trimmed in convertToUrl + # + # note: it would be better to pull the default search engine from chrome + # itself, but I'm not sure if/how that's possible + # + Settings.get("defaultSearchUrl") + query.split(/\s+/).map(encodeURIComponent).join("+") # Converts :string into a Google search if it's not already a URL. We don't bother with escaping characters # as Chrome will do that for us. @@ -126,3 +137,5 @@ globalRoot.extend = (hash1, hash2) -> root = exports ? window root.Utils = Utils + +# vim: softtabstop=2 diff --git a/options/options.coffee b/options/options.coffee index 27b08e38..078a931d 100644 --- a/options/options.coffee +++ b/options/options.coffee @@ -2,8 +2,9 @@ $ = (id) -> document.getElementById id bgSettings = chrome.extension.getBackgroundPage().Settings -editableFields = ["scrollStepSize", "excludedUrls", "linkHintCharacters", "userDefinedLinkHintCss", - "keyMappings", "filterLinkHints", "previousPatterns", "nextPatterns", "hideHud", "regexFindMode"] +editableFields = [ "scrollStepSize", "excludedUrls", "linkHintCharacters", + "userDefinedLinkHintCss", "keyMappings", "filterLinkHints", "previousPatterns", + "nextPatterns", "hideHud", "regexFindMode", "defaultSearchUrl"] canBeEmptyFields = ["excludedUrls", "keyMappings", "userDefinedLinkHintCss"] diff --git a/options/options.html b/options/options.html index d7851c75..ef1267cc 100644 --- a/options/options.html +++ b/options/options.html @@ -123,6 +123,9 @@ input#previousPatterns, input#nextPatterns { width: 100%; } + input#defaultSearchUrl { + width: 100%; + } #status { margin-left: 10px; font-size: 80%; @@ -308,6 +311,17 @@ unmapAll +