add trending links, statuses for v3.5.0

This commit is contained in:
cutls 2022-10-10 16:09:32 +09:00
parent 48c872909d
commit cb9a3c4af1
4 changed files with 83 additions and 35 deletions

View File

@ -284,51 +284,93 @@ function graphDrawCore(his, tag, acct_id) {
</div>
</div>`
}
/*
<svg version="1.1" viewbox="0 0 50 300" width="100%" height="50">
<path d="M0,0 L10,0 20,10 20,50" fill="#3F51B5"></path>
</svg>
*/
function trend() {
async function trend() {
console.log('get trend')
$('#src-contents').html('')
var acct_id = $('#src-acct-sel').val()
if (acct_id == 'tootsearch') {
return false
}
var domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/trends'
console.log(start)
fetch(start, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
.then(function (response) {
if (!response.ok) {
response.text().then(function (text) {
setLog(response.url, response.status, text)
})
const domain = localStorage.getItem('domain_' + acct_id)
const at = localStorage.getItem('acct_' + acct_id + '_at')
try {
const tagTrendUrl = 'https://' + domain + '/api/v1/trends'
const tagTrendResponse = await fetch(tagTrendUrl, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
return response.json()
})
.catch(function (error) {
setLog(start, 'JSON', error)
console.error(error)
})
.then(function (json) {
var tags = ''
Object.keys(json).forEach(function (keye) {
var tag = json[keye]
var his = tag.history
tags = graphDrawCore(his, tag, acct_id)
$('#src-contents').append(tags)
if (!tagTrendResponse.ok) {
tagTrendResponse.text().then(function (text) {
setLog(tagTrendResponse.url, tagTrendResponse.status, text)
})
}
const tagTrends = await tagTrendResponse.json()
let tags = ''
for (const tag of tagTrends) {
const his = tag.history
tags = tags + graphDrawCore(his, tag, acct_id)
}
$('#src-contents').append(`<div id="src-content-tag">Trend Tags<br />${tags || 'none'}</div>`)
} catch {
}
try {
const tootTrendUrl = 'https://' + domain + '/api/v1/trends/statuses'
const tootTrendResponse = await fetch(tootTrendUrl, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
if (!tootTrendResponse.ok) {
tootTrendResponse.text().then(function (text) {
setLog(tootTrendResponse.url, tootTrendResponse.status, text)
})
}
const tootTrends = await tootTrendResponse.json()
if (tootTrends.length) {
const templete = parse(tootTrends, '', acct_id)
$('#src-contents').append(`<div id="src-content-status">Trend Statuses<br />${templete}</div>`)
} else {
$('#src-contents').append(`<div id="src-content-status">Trend Statuses<br />none</div>`)
}
} catch {
}
try {
const linkTrendUrl = 'https://' + domain + '/api/v1/trends/links'
const linkTrendResponse = await fetch(linkTrendUrl, {
method: 'GET',
headers: {
'content-type': 'application/json',
Authorization: 'Bearer ' + at
}
})
if (!linkTrendResponse.ok) {
linkTrendResponse.text().then(function (text) {
setLog(linkTrendResponse.url, linkTrendResponse.status, text)
})
}
const linkTrends = await linkTrendResponse.json()
console.log(linkTrends)
let links = ''
for (const link of linkTrends) {
links = links + `<a href="${link.url}" target="_blank">${link.url}</a><br />` + cardHtml(link, acct_id, '') + `<br />`
}
$('#src-contents').append(`<div id="src-content-link">Trend Links<br />${links}</div>`)
} catch {
}
}
function srcBox(mode) {
if (mode == 'open') {

View File

@ -169,6 +169,8 @@
"lang_hisdata_taketime": "It will take 30s ~ several minutes",
"lang_hisdata_notonmisskey": "Misskey is unable to request.",
"lang_hisdata_key": "This user is proofed by {{set}}",
"lang_showontl_limited_title": "Limited account",
"lang_showontl_limited": "This is limited account by moderator, show anyway?",
"lang_showontl_movetxt": "This account was moved",
"lang_showontl_movebtn": "Continue on the new account",
"lang_showontl_botacct": "[bot]",

View File

@ -169,6 +169,8 @@
"lang_hisdata_notonmisskey": "このシステムはMisskeyにはあらへん。",
"lang_hisdata_key": "こいつは{{set}}が信じれるって言うてるし信じたってな",
"lang_showontl_movetxt": "このアカウントはお引っ越ししたで",
"lang_showontl_limited_title": "制限されたアカウント",
"lang_showontl_limited": "管理者がこのアカウントはあかんって言うたけど、あんたはどうするそれでも見るんやったらOK押してくれや",
"lang_showontl_movebtn": "移行先を見る",
"lang_showontl_botacct": "botアカウント",
"lang_showontl_followed": "フォローしてもろてる",

View File

@ -170,6 +170,8 @@
"lang_hisdata_taketime": "30秒から数分かかります",
"lang_hisdata_notonmisskey": "このシステムはMisskeyにはありません。",
"lang_hisdata_key": "このユーザーの信頼性は{{set}}によって示されています",
"lang_showontl_limited_title": "制限されたアカウント",
"lang_showontl_limited": "管理者によりこのアカウントの表示は制限されています。それでも表示しますか?",
"lang_showontl_movetxt": "このアカウントは移行しています",
"lang_showontl_movebtn": "移行先を見る",
"lang_showontl_botacct": "botアカウント",