aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorPhil Crosby2012-06-03 01:19:02 -0700
committerPhil Crosby2012-06-03 16:56:39 -0700
commitb04a90e85ffb65d53429c0d482bff98c9a80151e (patch)
tree6e7faaf768138f21d9f7e3f321406e4576c5f481 /background_scripts/completion.coffee
parent51f197952208701542eef60b353f248e5b9c6054 (diff)
downloadvimium-b04a90e85ffb65d53429c0d482bff98c9a80151e.tar.bz2
Show relevancy in the ui for debugging search ranking
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee13
1 files changed, 10 insertions, 3 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 2f6053b8..47ab1ac4 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -1,14 +1,21 @@
class Suggestion
+ showRelevancy: true # Set this to true to render relevancy when debugging the ranking scores.
+
# - type: one of [bookmark, history, tab].
constructor: (@queryTerms, @type, @url, @title, @computeRelevancyFunction, @extraRelevancyData) ->
generateHtml: ->
- @html ||=
+ return @html if @html
+ relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy() + ''}</span>" else ""
+ @html =
"<div class='topHalf'>
<span class='source'>#{@type}</span>
<span class='title'>#{@highlightTerms(utils.escapeHtml(@title))}</span>
</div>
- <div class='bottomHalf'><span class='url'>#{@shortenUrl(@highlightTerms(@url))}</span></div>"
+ <div class='bottomHalf'>
+ <span class='url'>#{@shortenUrl(@highlightTerms(@url))}</span>
+ #{relevancyHtml}
+ </div>"
shortenUrl: (url) ->
@stripTrailingSlash(url).replace(/^http:\/\//, "")
@@ -177,4 +184,4 @@ root = exports ? window
root.Suggestion = Suggestion
root.BookmarkCompleter = BookmarkCompleter
root.MultiCompleter = MultiCompleter
-root.HistoryCompleter = HistoryCompleter \ No newline at end of file
+root.HistoryCompleter = HistoryCompleter