X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=view%2Fjs%2Fautocomplete.js;h=a3464e459714acc75ecfe9d7e4631db5227d553d;hb=2da9dca316611be50b709fbf80f706ca31e79e21;hp=eb9d5efbea9bdccd99c1614592d1afdb1ed27ee5;hpb=96c086ea139047fc893ffb51843d3e24c5422c44;p=friendica.git diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index eb9d5efbea..a3464e4597 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -1,5 +1,6 @@ +// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat /** - * @brief Friendica people autocomplete + * Friendica people autocomplete * * require jQuery, jquery.textcomplete * @@ -220,7 +221,15 @@ function string2bb(element) { tags = { match: /(^|\s)(\#)([^ \n]{2,})$/, index: 3, - search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); }, + search: function(term, callback) { + $.getJSON(baseurl + '/hashtag/' + '?t=' + term) + .done(function(data) { + callback($.map(data, function(entry) { + // .toLowerCase() enables case-insensitive search + return entry.text.toLowerCase().indexOf(term.toLowerCase()) === 0 ? entry : null; + })); + }); + }, replace: function(item) { return "$1$2" + item.text + ' '; }, template: tag_format }; @@ -266,7 +275,7 @@ function string2bb(element) { tags = { match: /(^|\s)(\#)([^ \n]{2,})$/, index: 3, - search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?f=&t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); }, + search: function(term, callback) { $.getJSON(baseurl + '/hashtag/' + '?t=' + term).done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); }, replace: function(item) { return "$1$2" + item.text; }, template: tag_format }; @@ -277,32 +286,6 @@ function string2bb(element) { }; })( jQuery ); -(function( $ ) { - $.fn.contact_autocomplete = function(backend_url, typ, autosubmit, onselect) { - if(typeof typ === 'undefined') typ = ''; - if(typeof autosubmit === 'undefined') autosubmit = false; - - // Autocomplete contacts - contacts = { - match: /(^)([^\n]+)$/, - index: 2, - search: function(term, callback) { contact_search(term, callback, backend_url, typ); }, - replace: basic_replace, - template: contact_format, - }; - - this.attr('autocomplete','off'); - var a = this.textcomplete([contacts], {className:'acpopup', zIndex:10000}); - - if(autosubmit) - a.on('textComplete:select', function(e,value,strategy) { submit_form(this); }); - - if(typeof onselect !== 'undefined') - a.on('textComplete:select', function(e, value, strategy) { onselect(value); }); - }; -})( jQuery ); - - (function( $ ) { $.fn.name_autocomplete = function(backend_url, typ, autosubmit, onselect) { if(typeof typ === 'undefined') typ = ''; @@ -510,4 +493,4 @@ ACPopup.prototype.onkey = function(event){ this.close(); } } - +// @license-end