From 04abfdd5a64b016f2c94db5d52ff35e2d552d6d0 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 16 Apr 2018 17:37:38 -0700 Subject: update the search js --- view/js/autocomplete.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'view/js/autocomplete.js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 69ccd1fe5..e92de17c4 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -253,9 +253,18 @@ function string2bb(element) { template: contact_format }; + // Autocomplete hashtags + tags = { + match: /(^\#)([^ \n]{3,})$/, + index: 2, + search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; })); }); }, + replace: function(item) { return "$1" + item.text + ' '; }, + context: function(text) { return text.toLowerCase(); }, + template: tag_format + }; this.attr('autocomplete', 'off'); - var a = this.textcomplete([contacts,forums], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'}); + var a = this.textcomplete([contacts,forums,tags], {className:'acpopup', maxCount:100, zIndex: 1020, appendTo:'nav'}); a.on('textComplete:select', function(e, value, strategy) { submit_form(this); }); }; })( jQuery ); -- cgit v1.2.3