X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=view%2Fjs%2Fautocomplete.js;h=a3464e459714acc75ecfe9d7e4631db5227d553d;hb=16c2705016554289b8e2644d8f2093fb0f16178a;hp=219ad794bc86a4b18a34626ad4c691bf36a3b18b;hpb=c48e8106e36166a498387de2ad0b81f5934ddc77;p=friendica.git
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 219ad794bc..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
*
@@ -77,6 +78,10 @@ function contact_format(item) {
return "
" + item.text + "
";
}
+function tag_format(item) {
+ return "" + '#' + item.text + "
";
+}
+
function editor_replace(item) {
if (typeof item.replace !== 'undefined') {
return '$1$2' + item.replace;
@@ -212,6 +217,23 @@ function string2bb(element) {
template: contact_format,
};
+ // Autocomplete hashtags
+ tags = {
+ match: /(^|\s)(\#)([^ \n]{2,})$/,
+ index: 3,
+ 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
+ };
+
// Autocomplete smilies e.g. ":like"
smilies = {
match: /(^|\s)(:[a-z]{2,})$/,
@@ -222,7 +244,7 @@ function string2bb(element) {
};
this.attr('autocomplete','off');
- this.textcomplete([contacts, forums, smilies], {className:'acpopup', zIndex:10000});
+ this.textcomplete([contacts, forums, smilies, tags], {className:'acpopup', zIndex:10000});
};
})( jQuery );
@@ -248,38 +270,22 @@ function string2bb(element) {
replace: webbie_replace,
template: contact_format,
};
- this.attr('autocomplete', 'off');
- var a = this.textcomplete([contacts, community], {className:'acpopup', maxCount:100, zIndex: 10000, appendTo:'nav'});
- a.on('textComplete:select', function(e, value, strategy) { submit_form(this); });
- };
-})( 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,
+ // Autocomplete hashtags
+ tags = {
+ match: /(^|\s)(\#)([^ \n]{2,})$/,
+ index: 3,
+ 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
};
- 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); });
+ this.attr('autocomplete', 'off');
+ var a = this.textcomplete([contacts, community, tags], {className:'acpopup', maxCount:100, zIndex: 10000, appendTo:'nav'});
+ a.on('textComplete:select', function(e, value, strategy) { submit_form(this); });
};
})( jQuery );
-
(function( $ ) {
$.fn.name_autocomplete = function(backend_url, typ, autosubmit, onselect) {
if(typeof typ === 'undefined') typ = '';
@@ -487,4 +493,4 @@ ACPopup.prototype.onkey = function(event){
this.close();
}
}
-
+// @license-end