diff options
| author | Stephen Blott | 2015-05-03 10:24:37 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-03 10:24:37 +0100 |
| commit | 05431a5041913d78e44058e9e7f42ef9eee29ce9 (patch) | |
| tree | cea2a3885fc9ea400f96b5c865ab6ce6817d9117 | |
| parent | 6fecc4e24392650c540354918af641b29aa6b2b4 (diff) | |
| download | vimium-05431a5041913d78e44058e9e7f42ef9eee29ce9.tar.bz2 | |
Search completion; Google maps.
| -rw-r--r-- | background_scripts/search_engines.coffee | 17 | ||||
| -rw-r--r-- | background_scripts/settings.coffee | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/background_scripts/search_engines.coffee b/background_scripts/search_engines.coffee index c61baf17..90fcb99f 100644 --- a/background_scripts/search_engines.coffee +++ b/background_scripts/search_engines.coffee @@ -41,7 +41,7 @@ class Google extends RegexpEngine class Youtube extends RegexpEngine constructor: -> - super [ new RegExp "https?://[a-z]+\.youtube\.com/results" ] + super [ new RegExp "^https?://[a-z]+\.youtube\.com/results" ] getUrl: (queryTerms) -> "http://suggestqueries.google.com/complete/search?client=youtube&ds=yt&q=#{Utils.createSearchQuery queryTerms}" @@ -53,8 +53,9 @@ class Youtube extends RegexpEngine suggestion[0] for suggestion in JSON.parse(text)[1] class Wikipedia extends RegexpEngine + # Example search URL: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s constructor: -> - super [ new RegExp "https?://[a-z]+\.wikipedia\.org/" ] + super [ new RegExp "^https?://[a-z]+\.wikipedia\.org/" ] getUrl: (queryTerms) -> "https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=#{Utils.createSearchQuery queryTerms}" @@ -62,6 +63,18 @@ class Wikipedia extends RegexpEngine parse: (xhr) -> JSON.parse(xhr.responseText)[1] +class GoogleMaps extends RegexpEngine + constructor: -> + super [ new RegExp "^https?://www\.google\.com/maps/search/" ] + + getUrl: (queryTerms) -> + "https://www.google.com/s?tbm=map&fp=1&gs_ri=maps&source=hp&suggest=p&authuser=0&hl=en&pf=p&tch=1&ech=2&q=#{Utils.createSearchQuery queryTerms}" + + parse: (xhr) -> + console.log xhr + [] + + 'google-maps': 'https://www.google.com/maps/search/', # A dummy search engine which is guaranteed to match any search URL, but never produces completions. This # allows the rest of the logic to be written knowing that there will be a search engine match. class DummySearchEngine diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index a4d95c81..01277741 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -90,7 +90,11 @@ root.Settings = Settings = # default/fall back search engine searchUrl: "http://www.google.com/search?q=" # put in an example search engine - searchEngines: "w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s wikipedia" + searchEngines: [ + "w: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s Wikipedia", "" + "t: http://www.youtube.com/results?search_query=%s Youtube", "" + "m: https://www.google.com/maps/search/%s Google Maps", "" + ].join "\n" newTabUrl: "chrome://newtab" grabBackFocus: false |
