From 63e66ffd7def88563ab3f705fe91eea85118cb85 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 5 May 2012 00:11:57 -0700 Subject: shorten the definition of BackgroundCompleter --- lib/completion.js | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/completion.js b/lib/completion.js index 240468cb..fa2e9209 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -254,15 +254,14 @@ var completion = (function() { }); /** Get completion results from the background page */ - var BackgroundCompleter = function(name) { - this.name = name; - this.filterPort = chrome.extension.connect({ name: 'filterCompleter' }); - } - BackgroundCompleter.prototype = { - refresh: function() { - chrome.extension.sendRequest({ handler: 'refreshCompleter', name: this.name }); + var BackgroundCompleter = Class.extend({ + init: function(name) { + this.name = name; + this.filterPort = chrome.extension.connect({ name: "filterCompleter" }); }, + refresh: function() { chrome.extension.sendRequest({ handler: "refreshCompleter", name: this.name }); }, + filter: function(query, maxResults, callback) { var id = utils.createUniqueId(); this.filterPort.onMessage.addListener(function(msg) { @@ -273,12 +272,9 @@ var completion = (function() { return result; })); }); - this.filterPort.postMessage({ id: id, - name: this.name, - query: query, - maxResults: maxResults }); - }, - } + this.filterPort.postMessage({ id: id, name: this.name, query: query, maxResults: maxResults }); + } + }); /** A meta-completer that delegates queries and merges and sorts the results of a collection of other * completer instances given in :sources. The optional argument :queryThreshold determines how long a -- cgit v1.2.3