diff options
| author | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-09-29 09:44:29 +0200 |
|---|---|---|
| committer | Thomas Pointhuber <thomas.pointhuber@gmx.at> | 2014-10-05 14:40:47 +0200 |
| commit | 14b0604bc0a14a110c92457f43b3828fc22e7fc7 (patch) | |
| tree | 52e9ce9da9c2382f436f8c6b985fc5e4812fd7c4 /searx/static/oscar/js/scripts.js | |
| parent | 4b7164f04a9acdda569db42c12a267fb9d2dbe94 (diff) | |
oscar template: implement autocompleter
Diffstat (limited to 'searx/static/oscar/js/scripts.js')
| -rw-r--r-- | searx/static/oscar/js/scripts.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/searx/static/oscar/js/scripts.js b/searx/static/oscar/js/scripts.js index 296cddd94..6c3a10a74 100644 --- a/searx/static/oscar/js/scripts.js +++ b/searx/static/oscar/js/scripts.js @@ -7,6 +7,15 @@ */
+if(searx.autocompleter) {
+ searx.searchResults = new Bloodhound({
+ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
+ queryTokenizer: Bloodhound.tokenizers.whitespace,
+ remote: '/autocompleter?q=%QUERY'
+ });
+ searx.searchResults.initialize();
+}
+
$(document).ready(function(){
$('.btn-toggle .btn').click(function() {
var btnClass = 'btn-' + $(this).data('btn-class');
@@ -42,4 +51,14 @@ $(document).ready(function(){ $(".select-all-on-click").click(function () {
$(this).select();
});
-});
+
+ if(searx.autocompleter) {
+ $('#q').typeahead(null, {
+ name: 'search-results',
+ displayKey: function(result) {
+ return result;
+ },
+ source: searx.searchResults.ttAdapter()
+ });
+ }
+});
|