Fix autocomplete

This commit is contained in:
Thomas 2024-05-11 16:56:11 +02:00
parent b8873a277d
commit 2cf43f4a50

View file

@ -1457,23 +1457,21 @@ document = window.document || {};
id: css_class,
match: /\B((:[\-+\w]*)|(@[\-+\w]*)|(#[\-+\w]*))$/,
search: function (term, callback) {
if (term.startsWith(":")) {
callback($.map(map, function (emoji) {
return emoji.indexOf(term) === 0 ? emoji : null;
}));
} else if (term.startsWith("@") && term.substring(1).length > 2){
} else if (term.startsWith("@") && term.substring(1).length > 1){
$.ajax({
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=accounts&q="+term.substring(1),
headers: {"Authorization": $('#data_api').attr('data-token')},
context: document.body
}).done(function(value) {
alert(value);
callback($.map(value.accounts, function (value) {
return value;
}));
});
}else if (term.startsWith("#") && term.substring(1).length > 2){
}else if (term.startsWith("#") && term.substring(1).length > 1){
$.ajax({
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=hashtags&q="+term.substring(1),
headers: {"Authorization": $('#data_api').attr('data-token')},
@ -1483,6 +1481,10 @@ document = window.document || {};
return value;
}));
});
} else {
callback($.map(map, function () {
return null;
}));
}
},
template: function (value) {
@ -1502,7 +1504,6 @@ document = window.document || {};
}else if (typeof value.name != 'undefined') {
return "#"+value.name+ " ";
}else{
return shortnameTo(value, self.emojiTemplate);
}
},