From 8a83eda8402fa836a66ef9c3632f416569ab9382 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 14 May 2015 05:44:02 +0100 Subject: Search completion; add Merriam-Webster. --- background_scripts/completion_engines.coffee | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 49569b5d..189f66f3 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -102,6 +102,12 @@ class DuckDuckGo extends RegexpEngine parse: (xhr) -> suggestion.phrase for suggestion in JSON.parse xhr.responseText +class Webster extends RegexpEngine + # Example search URL: http://www.merriam-webster.com/dictionary/%s + constructor: -> super [ new RegExp "^https?://www.merriam-webster.com/dictionary/" ] + getUrl: (queryTerms) -> Utils.createSearchUrl queryTerms, "http://www.merriam-webster.com/autocomplete?query=%s" + parse: (xhr) -> JSON.parse(xhr.responseText).suggestions + # 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 always be a completion engine match. class DummyCompletionEngine @@ -119,6 +125,7 @@ CompletionEngines = [ Wikipedia Bing Amazon + Webster DummyCompletionEngine ] -- cgit v1.2.3