aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Crosby2012-06-03 16:02:01 -0700
committerPhil Crosby2012-06-03 16:56:39 -0700
commit39885cd326737534e2afc976f2a8ce086c76fc66 (patch)
tree19364ede7af04fb4d4ab3a9d71ae9b7131e6f14e
parent7d6f675b7b890645d7bd2819d697d8a6210f37b0 (diff)
downloadvimium-39885cd326737534e2afc976f2a8ce086c76fc66.tar.bz2
Make title in suggestions optional (domain suggestions may not have a title)
-rw-r--r--background_scripts/completion.coffee10
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