2018-12-02 15:01:21 +01:00
|
|
|
function searchlocalfill() {
|
2019-10-13 18:34:02 +02:00
|
|
|
if(current_search_history.length > 0) {
|
2018-12-02 15:01:21 +01:00
|
|
|
var dropdown = $("<ul>").addClass("account_list");
|
|
|
|
var searchsuggestions = new Array();
|
|
|
|
current_search_history.reverse();
|
|
|
|
for(var i=0;i<current_search_history.length;i++) {
|
|
|
|
if(searchsuggestions.length == 10) break;
|
|
|
|
if(searchsuggestions.indexOf(current_search_history[i]) == -1) {
|
|
|
|
dropdown.append($("<li>").data("value",current_search_history[i]).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px")))
|
|
|
|
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html("#"+current_search_history[i])))).click(function() {
|
|
|
|
window.location.href = "/search?q="+encodeURIComponent($(this).data("value"));
|
|
|
|
}));
|
|
|
|
searchsuggestions.push(current_search_history[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current_search_history.reverse();
|
|
|
|
$(".header_search_suggestions").empty().removeClass("invisible").append(dropdown);
|
|
|
|
replace_emoji();
|
|
|
|
}
|
2019-10-13 18:34:02 +02:00
|
|
|
}
|
2018-12-02 15:01:21 +01:00
|
|
|
function searchremotefill(text) {
|
|
|
|
if(text == "@") searchlocalfill();
|
|
|
|
else {
|
2019-12-23 14:58:06 +01:00
|
|
|
api.search("q="+encodeURIComponent(text)+"&resolve=false&limit=5",function(data) {
|
2018-12-02 15:01:21 +01:00
|
|
|
if(data.hashtags.length == 0 && data.accounts.length == 0) $(".header_search_suggestions").addClass("invisible");
|
|
|
|
else {
|
|
|
|
var dropdown = $("<ul>").addClass("account_list");
|
|
|
|
for(var i=0;i<data.hashtags.length;i++) {
|
|
|
|
if(i == 5) break;
|
2019-12-23 14:58:06 +01:00
|
|
|
dropdown.append($("<li>").data("value",data.hashtags[i].name).addClass("account_box").append($("<div>").addClass("icon_box").append($("<span>").addClass("emoji_poss").html("#️⃣").css("float","left").css("font-size","32px")))
|
|
|
|
.append($("<div>").addClass("label_box").append($("<span>").addClass("dn").append($("<h3>").html("#"+data.hashtags[i].name)))).click(function() {
|
2018-12-02 15:01:21 +01:00
|
|
|
window.location.href = "/search?q="+encodeURIComponent($(this).data("value"));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
for(var i=0;i<data.accounts.length;i++) {
|
|
|
|
if(i == 5) break;
|
|
|
|
if(data.accounts[i].display_name == "") data.accounts[i].display_name = data.accounts[i].username;
|
|
|
|
for(var a=0;a<data.accounts[i].emojis.length;a++) {
|
|
|
|
data.accounts[i].display_name = data.accounts[i].display_name.replace(new RegExp(":"+data.accounts[i].emojis[a].shortcode+":","g"),"<img src='"+data.accounts[i].emojis[a].url+"' class='emoji'>");
|
|
|
|
}
|
2019-01-31 17:53:40 +01:00
|
|
|
var account_link;
|
|
|
|
if(data.accounts[i].acct.indexOf("@") == -1) account_link = "/@"+data.accounts[i].acct+"@"+current_instance+"?mid="+data.accounts[i].id;
|
|
|
|
else account_link = "/@"+data.accounts[i].acct+"?mid="+data.accounts[i].id;
|
|
|
|
dropdown.append($("<li>").data("value",account_link).addClass("account_box").append($("<div>").addClass("icon_box").append($("<img>").attr("src",data.accounts[i].avatar).css("float","left")))
|
2018-12-02 15:01:21 +01:00
|
|
|
.append($("<div>").addClass("label_box").css("width","unset").append($("<span>").addClass("dn").append($("<h3>").html(data.accounts[i].display_name).addClass("emoji_poss"))).append($("<span>").addClass("un").html(data.accounts[i].acct))).click(function() {
|
|
|
|
window.location.href = $(this).data("value");
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
$(".header_search_suggestions").empty().removeClass("invisible").append(dropdown);
|
|
|
|
replace_emoji();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function searchredirect(text) {
|
|
|
|
if(text[0] == "@") window.location.href = "/search/users?q="+encodeURIComponent(text.substr(1));
|
|
|
|
else if(text[0] == "#") window.location.href = "/search?q="+encodeURIComponent(text.substr(1));
|
|
|
|
else if(text.substr(0,8) == "https://") openStatus(text);
|
|
|
|
else window.location.href = "/search?q="+encodeURIComponent(text);
|
|
|
|
}
|