use fediversearch to suggest

This commit is contained in:
cutls 2021-02-14 11:21:29 +09:00
parent 7281db2375
commit d2c9917b7f

View File

@ -1107,14 +1107,12 @@ input.addEventListener(
var new_val = input.value var new_val = input.value
if (prev_val != new_val) { if (prev_val != new_val) {
if (new_val.length > 3) { if (new_val.length > 3) {
var start = 'https://instances.social/api/1.0/instances/search?q=' + new_val var start = 'https://www.fediversesearch.com/search?keyword=' + new_val
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
Authorization: }
'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
}
}) })
.then(function (response) { .then(function (response) {
if (!response.ok) { if (!response.ok) {
@ -1132,11 +1130,11 @@ input.addEventListener(
.then(function (json) { .then(function (json) {
if (!json.error) { if (!json.error) {
var urls = 'Suggest:' var urls = 'Suggest:'
Object.keys(json.instances).forEach(function (key) { Object.keys(json.data).forEach(function (key) {
var url = json.instances[key] var url = json.data[key]
urls = urls =
urls + urls +
` <a onclick="login('${url.name}')" class="pointer">${escapeHTML(url.name)}</a>` ` <a onclick="login('${url.url}')" class="pointer" title="${url.uri}">${escapeHTML(url.title)}</a>`
}) })
$('#ins-suggest').html(urls) $('#ins-suggest').html(urls)
} else { } else {