From 01a6df1f155b8b068925cc813d663457edc860e8 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 31 May 2015 14:04:28 +0100 Subject: Re-write class with inheritence. --- background_scripts/completion_engines.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'background_scripts') diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 9a88d491..48f94965 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -43,15 +43,15 @@ class Google extends GoogleXMLRegexpEngine # A wrapper class for Google completions. This adds prefix terms to the query, and strips those terms from # the resulting suggestions. For example, for Google Maps, we add "map of" as a prefix, then strip "map of" # from the resulting suggestions. -class GoogleWithPrefix +class GoogleWithPrefix extends Google constructor: (prefix, args...) -> - @engine = new Google args... - @prefix = "#{prefix.trim()} " - @queryTerms = @prefix.split /\s+/ - match: (args...) -> @engine.match args... - getUrl: (queryTerms) -> @engine.getUrl [ @queryTerms..., queryTerms... ] + super args... + prefix = prefix.trim() + @prefix = "#{prefix} " + @queryTerms = prefix.split /\s+/ + getUrl: (queryTerms) -> super [ @queryTerms..., queryTerms... ] parse: (xhr) -> - @engine.parse(xhr) + super(xhr) .filter (suggestion) => suggestion.startsWith @prefix .map (suggestion) => suggestion[@prefix.length..].ltrim() -- cgit v1.2.3