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>
</div>` </div>`
} }
/* async function trend() {
<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() {
console.log('get trend') console.log('get trend')
$('#src-contents').html('') $('#src-contents').html('')
var acct_id = $('#src-acct-sel').val() var acct_id = $('#src-acct-sel').val()
if (acct_id == 'tootsearch') { if (acct_id == 'tootsearch') {
return false return false
} }
var domain = localStorage.getItem('domain_' + acct_id) const domain = localStorage.getItem('domain_' + acct_id)
var at = localStorage.getItem('acct_' + acct_id + '_at') const at = localStorage.getItem('acct_' + acct_id + '_at')
var start = 'https://' + domain + '/api/v1/trends' try {
console.log(start) const tagTrendUrl = 'https://' + domain + '/api/v1/trends'
fetch(start, { const tagTrendResponse = await fetch(tagTrendUrl, {
method: 'GET', method: 'GET',
headers: { headers: {
'content-type': 'application/json', 'content-type': 'application/json',
Authorization: 'Bearer ' + at Authorization: 'Bearer ' + at
} }
}) })
.then(function (response) { if (!tagTrendResponse.ok) {
if (!response.ok) { tagTrendResponse.text().then(function (text) {
response.text().then(function (text) { setLog(tagTrendResponse.url, tagTrendResponse.status, text)
setLog(response.url, response.status, text)
}) })
} }
return response.json() const tagTrends = await tagTrendResponse.json()
}) let tags = ''
.catch(function (error) { for (const tag of tagTrends) {
setLog(start, 'JSON', error) const his = tag.history
console.error(error) tags = tags + graphDrawCore(his, tag, acct_id)
}) }
.then(function (json) { $('#src-contents').append(`<div id="src-content-tag">Trend Tags<br />${tags || 'none'}</div>`)
var tags = '' } catch {
Object.keys(json).forEach(function (keye) {
var tag = json[keye]
var his = tag.history
tags = graphDrawCore(his, tag, acct_id)
$('#src-contents').append(tags) }
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) { function srcBox(mode) {
if (mode == 'open') { if (mode == 'open') {

View File

@ -169,6 +169,8 @@
"lang_hisdata_taketime": "It will take 30s ~ several minutes", "lang_hisdata_taketime": "It will take 30s ~ several minutes",
"lang_hisdata_notonmisskey": "Misskey is unable to request.", "lang_hisdata_notonmisskey": "Misskey is unable to request.",
"lang_hisdata_key": "This user is proofed by {{set}}", "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_movetxt": "This account was moved",
"lang_showontl_movebtn": "Continue on the new account", "lang_showontl_movebtn": "Continue on the new account",
"lang_showontl_botacct": "[bot]", "lang_showontl_botacct": "[bot]",

View File

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

View File

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