aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/autocomplete.js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-03-07 16:59:55 -0800
committerzotlabs <mike@macgirvin.com>2018-03-07 16:59:55 -0800
commit48b1042347d098672e583010fe9dbf71eb81623c (patch)
treeceb68660981e533eee933c5d992c3df9882cbfd7 /view/js/autocomplete.js
parenta454aad124f999e59e8bffb625c103b975aef107 (diff)
downloadvolse-hubzilla-48b1042347d098672e583010fe9dbf71eb81623c.tar.gz
volse-hubzilla-48b1042347d098672e583010fe9dbf71eb81623c.tar.bz2
volse-hubzilla-48b1042347d098672e583010fe9dbf71eb81623c.zip
hashtag autocomplete
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r--view/js/autocomplete.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 01def9900..2d017db18 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -74,6 +74,10 @@ function bbco_format(item) {
return "<div class='dropdown-item'>" + item + "</div>";
}
+function tag_format(item) {
+ return "<div class='dropdown-item'>" + '#' + item.text + "</div>";
+}
+
function editor_replace(item) {
if(typeof item.replace !== 'undefined') {
return '$1$2' + item.replace;
@@ -202,6 +206,16 @@ function string2bb(element) {
};
+ // Autocomplete hashtags
+ tags = {
+ match: /(^|\s)(\#)([^ \n]{2,})$/,
+ index: 3,
+ search: function(term, callback) { $.getJSON('/hashtags/' + '$f=&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
+ };
+
+
smilies = {
match: /(^|\s)(:[a-z_:]{2,})$/,
index: 2,
@@ -211,7 +225,7 @@ function string2bb(element) {
template: smiley_format
};
this.attr('autocomplete','off');
- this.textcomplete([contacts,forums,smilies], {className:'acpopup', zIndex:1020});
+ this.textcomplete([contacts,forums,smilies,tags], {className:'acpopup', zIndex:1020});
};
})( jQuery );