mirror of
https://framagit.org/tom79/fediplan.git
synced 2025-04-06 06:01:50 +02:00
Fix autocomplete
This commit is contained in:
parent
b8873a277d
commit
2cf43f4a50
1 changed files with 6 additions and 5 deletions
|
@ -1457,23 +1457,21 @@ document = window.document || {};
|
||||||
id: css_class,
|
id: css_class,
|
||||||
match: /\B((:[\-+\w]*)|(@[\-+\w]*)|(#[\-+\w]*))$/,
|
match: /\B((:[\-+\w]*)|(@[\-+\w]*)|(#[\-+\w]*))$/,
|
||||||
search: function (term, callback) {
|
search: function (term, callback) {
|
||||||
|
|
||||||
if (term.startsWith(":")) {
|
if (term.startsWith(":")) {
|
||||||
callback($.map(map, function (emoji) {
|
callback($.map(map, function (emoji) {
|
||||||
return emoji.indexOf(term) === 0 ? emoji : null;
|
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({
|
$.ajax({
|
||||||
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=accounts&q="+term.substring(1),
|
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=accounts&q="+term.substring(1),
|
||||||
headers: {"Authorization": $('#data_api').attr('data-token')},
|
headers: {"Authorization": $('#data_api').attr('data-token')},
|
||||||
context: document.body
|
context: document.body
|
||||||
}).done(function(value) {
|
}).done(function(value) {
|
||||||
alert(value);
|
|
||||||
callback($.map(value.accounts, function (value) {
|
callback($.map(value.accounts, function (value) {
|
||||||
return value;
|
return value;
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
}else if (term.startsWith("#") && term.substring(1).length > 2){
|
}else if (term.startsWith("#") && term.substring(1).length > 1){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=hashtags&q="+term.substring(1),
|
url: "https://"+$('#data_api').attr('data-instance')+"/api/v2/search?type=hashtags&q="+term.substring(1),
|
||||||
headers: {"Authorization": $('#data_api').attr('data-token')},
|
headers: {"Authorization": $('#data_api').attr('data-token')},
|
||||||
|
@ -1483,6 +1481,10 @@ document = window.document || {};
|
||||||
return value;
|
return value;
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
callback($.map(map, function () {
|
||||||
|
return null;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: function (value) {
|
template: function (value) {
|
||||||
|
@ -1502,7 +1504,6 @@ document = window.document || {};
|
||||||
}else if (typeof value.name != 'undefined') {
|
}else if (typeof value.name != 'undefined') {
|
||||||
return "#"+value.name+ " ";
|
return "#"+value.name+ " ";
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
return shortnameTo(value, self.emojiTemplate);
|
return shortnameTo(value, self.emojiTemplate);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue