diff options
Diffstat (limited to 'fuzzyMode.js')
| -rw-r--r-- | fuzzyMode.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 8667d467..2d53431e 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -4,7 +4,7 @@ var fuzzyMode = (function() { function getCompleter(name) { if (!(name in completers)) - completers[name] = new completion.BackgroundCompleter(name); + completers[name] = new BackgroundCompleter(name); return completers[name]; } @@ -167,6 +167,34 @@ var fuzzyMode = (function() { }, } + /* + * Sends filter and refresh requests to a Vomnibar completer on the background page. + */ + var BackgroundCompleter = Class.extend({ + /* + * - name: The name of the background page completer that you want to interface with. One of [omni, tabs]. + */ + 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) { + if (msg.id != id) return; + callback(msg.results.map(function(result) { + var action = result.action; + result.action = eval(action.func).apply(null, action.args); + return result; + })); + }); + this.filterPort.postMessage({ id: id, name: this.name, query: query, maxResults: maxResults }); + } + }); + // public interface return { activateAll: function() { start("omni", false, 100); }, |
