aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
Diffstat (limited to 'background_scripts')
-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