diff options
| author | Phil Crosby | 2012-06-03 16:02:01 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-06-03 16:56:39 -0700 |
| commit | 39885cd326737534e2afc976f2a8ce086c76fc66 (patch) | |
| tree | 19364ede7af04fb4d4ab3a9d71ae9b7131e6f14e | |
| parent | 7d6f675b7b890645d7bd2819d697d8a6210f37b0 (diff) | |
| download | vimium-39885cd326737534e2afc976f2a8ce086c76fc66.tar.bz2 | |
Make title in suggestions optional (domain suggestions may not have a title)
| -rw-r--r-- | background_scripts/completion.coffee | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 8b18ce90..c9b4de78 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -3,6 +3,7 @@ class Suggestion # - type: one of [bookmark, history, tab]. constructor: (@queryTerms, @type, @url, @title, @computeRelevancyFunction, @extraRelevancyData) -> + @title ||= "" generateHtml: -> return @html if @html @@ -151,11 +152,14 @@ RankingUtils = for term in queryTerms queryLength += term.length urlScore += 1 if url.indexOf(term) >= 0 - titleScore += 1 if title.indexOf(term) >= 0 + titleScore += 1 if title && title.indexOf(term) >= 0 urlScore = urlScore / queryTerms.length urlScore = urlScore * RankingUtils.normalizeDifference(queryLength, url.length) - titleScore = titleScore / queryTerms.length - titleScore = titleScore * RankingUtils.normalizeDifference(queryLength, title.length) + if title + titleScore = titleScore / queryTerms.length + titleScore = titleScore * RankingUtils.normalizeDifference(queryLength, title.length) + else + titleScore = urlScore (urlScore + titleScore) / 2 # Returns a score between [0, 1] which indicates how recent the given timestamp is. Items which are over |
