diff options
| author | Stephen Blott | 2015-05-08 06:17:19 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-08 06:17:19 +0100 |
| commit | 723b66e24f9b3f4e8dd9843e21352eeceb7c96a9 (patch) | |
| tree | 8432256ca80136498c84f52cec5a9e01c8c9d37d /background_scripts/completion_engines.coffee | |
| parent | 4bb739c30f22be39ece9813312ca7219619a9347 (diff) | |
| download | vimium-723b66e24f9b3f4e8dd9843e21352eeceb7c96a9.tar.bz2 | |
Search completion; tweak timeouts and caching.
Diffstat (limited to 'background_scripts/completion_engines.coffee')
| -rw-r--r-- | background_scripts/completion_engines.coffee | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/background_scripts/completion_engines.coffee b/background_scripts/completion_engines.coffee index 3e762e32..19a18ecd 100644 --- a/background_scripts/completion_engines.coffee +++ b/background_scripts/completion_engines.coffee @@ -24,7 +24,7 @@ class RegexpEngine # Several Google completion engines package XML responses in this way. class GoogleXMLRegexpEngine extends RegexpEngine - doNotCache: true + doNotCache: false # true (disbaled, experimental) parse: (xhr) -> for suggestion in xhr.responseXML.getElementsByTagName "suggestion" continue unless suggestion = suggestion.getAttribute "data" @@ -51,7 +51,7 @@ class Youtube extends GoogleXMLRegexpEngine "http://suggestqueries.google.com/complete/search?client=youtube&ds=yt&xml=t&q=#{Utils.createSearchQuery queryTerms}" class Wikipedia extends RegexpEngine - doNotCache: true + doNotCache: false # true (disbaled, experimental) # Example search URL: http://www.wikipedia.org/w/index.php?title=Special:Search&search=%s constructor: -> super [ new RegExp "^https?://[a-z]+\.wikipedia\.org/" ] @@ -125,7 +125,7 @@ CompletionEngines = # The amount of time to wait for new requests before launching the HTTP request. The intention is to cut # down on the number of HTTP requests we issue. - delay: 250 + delay: 200 get: (searchUrl, url, callback) -> xhr = new XMLHttpRequest() @@ -177,9 +177,8 @@ CompletionEngines = @completionCache ?= new SimpleCache 60 * 60 * 1000, 2000 # One hour, 2000 entries. if @completionCache.has completionCacheKey # We add a short delay, even for a cache hit. This avoids an ugly flicker when the additional - # suggestions are posted. It also makes the vomnibar behave similarly regardless of whether there's a - # cache hit. - Utils.setTimeout @delay, => + # suggestions are posted. + Utils.setTimeout 75, => console.log "hit", completionCacheKey if @debug callback @completionCache.get completionCacheKey return @@ -227,6 +226,7 @@ CompletionEngines = console.log "callbacks", queue.length, completionCacheKey if @debug and 0 < queue.length callback suggestions for callback in queue + # Cancel any pending (ie. blocked on @delay) queries. Does not cancel in-flight queries. cancel: -> if @mostRecentHandler? @mostRecentHandler = null |
