diff options
| author | Stephen Blott | 2015-05-11 14:37:57 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-05-11 14:43:29 +0100 |
| commit | 3975c13fe040639beb56582e50d951ad4839afbb (patch) | |
| tree | 9e6086f5d416c142837868178d55955bd34ca0c2 | |
| parent | 212a47dca607983f424a59da3b5ab915f3aff403 (diff) | |
| download | vimium-3975c13fe040639beb56582e50d951ad4839afbb.tar.bz2 | |
Search completion; add weigthing option.
| -rw-r--r-- | background_scripts/completion.coffee | 6 | ||||
| -rw-r--r-- | background_scripts/settings.coffee | 1 | ||||
| -rw-r--r-- | pages/options.coffee | 1 | ||||
| -rw-r--r-- | pages/options.css | 5 | ||||
| -rw-r--r-- | pages/options.html | 27 |
5 files changed, 36 insertions, 4 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index 25fdf44e..23526f85 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -416,7 +416,9 @@ class SearchEngineCompleter return onComplete [] unless custom or 0 < queryTerms.length query = queryTerms.join " " + factor = Settings.get "omniSearchWeight" haveCompletionEngine = CompletionSearch.haveCompletionEngine searchUrl + haveCompletionEngine = false unless 0.0 < factor # Relevancy: # - Relevancy does not depend upon the actual suggestion (so, it does not depend upon word @@ -429,7 +431,7 @@ class SearchEngineCompleter # a useful suggestion from another completer. # characterCount = query.length - queryTerms.length + 1 - relavancy = 0.6 * (Math.min(characterCount, 10.0)/10.0) + relavancy = factor * (Math.min(characterCount, 10.0)/10.0) # This distinguishes two very different kinds of vomnibar baviours, the newer bahviour (true) and the # legacy behavior (false). We retain the latter for the default search engine, and for custom search @@ -478,7 +480,7 @@ class SearchEngineCompleter # Post suggestions and bail if we already have all of the suggestions, or if there is no prospect of # adding further suggestions. if queryTerms.length == 0 or cachedSuggestions? or not haveCompletionEngine - if cachedSuggestions? + if cachedSuggestions? and 0 < factor console.log "cached suggestions:", cachedSuggestions.length, query if SearchEngineCompleter.debug suggestions.push cachedSuggestions.map(mkSuggestion)... return onComplete suggestions, { filter, continuation: null } diff --git a/background_scripts/settings.coffee b/background_scripts/settings.coffee index 11f492d7..e042eded 100644 --- a/background_scripts/settings.coffee +++ b/background_scripts/settings.coffee @@ -43,6 +43,7 @@ root.Settings = Settings = # or strings defaults: scrollStepSize: 60 + omniSearchWeight: 0.6 smoothScroll: true keyMappings: "# Insert your preferred key mappings here." linkHintCharacters: "sadfjklewcmpgh" diff --git a/pages/options.coffee b/pages/options.coffee index b3ecf69a..18ff226d 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -261,6 +261,7 @@ initOptionsPage = -> searchEngines: TextOption searchUrl: NonEmptyTextOption userDefinedLinkHintCss: TextOption + omniSearchWeight: NumberOption # Populate options. The constructor adds each new object to "Option.all". for name, type of options diff --git a/pages/options.css b/pages/options.css index 5b098c8f..1a3ff757 100644 --- a/pages/options.css +++ b/pages/options.css @@ -107,9 +107,10 @@ input#linkHintNumbers { input#linkHintCharacters { width: 100%; } -input#scrollStepSize { - width: 40px; +input#scrollStepSize, input#omniSearchWeight { + width: 50px; margin-right: 3px; + padding-left: 3px; } textarea#userDefinedLinkHintCss, textarea#keyMappings, textarea#searchEngines { width: 100%;; diff --git a/pages/options.html b/pages/options.html index f89ddcbb..75089d75 100644 --- a/pages/options.html +++ b/pages/options.html @@ -233,6 +233,33 @@ b: http://b.com/?q=%s description <div class="nonEmptyTextOption"> </td> </tr> + + <!-- Vimium Labs --> + <tr> + <td colspan="2"><header>Vimium Labs</header></td> + </tr> + <tr> + <td class="caption"></td> + <td> + <div class="help"> + <div class="example"> + </div> + </div> + These features are experimental and may be changed or removed in future releases. + </td> + </tr> + <tr> + <td class="caption">Search weighting</td> + <td> + <div class="help"> + <div class="example"> + How prominent should suggestions be in the vomnibar? + <tt>0</tt> disables suggestions altogether. + </div> + </div> + <input id="omniSearchWeight" type="number" min="0.0" max="1.0" step="0.05" />(0 to 1) + </td> + </tr> </tbody> </table> </div> |
