Show character ranking in info table

This commit is contained in:
2018-10-27 11:01:21 +09:00
parent 24103d10cb
commit 252d021d90
5 changed files with 74 additions and 19 deletions

View File

@ -163,6 +163,7 @@ export default class AnimeNotifier {
Promise.resolve().then(() => this.updatePushUI()),
Promise.resolve().then(() => this.dragAndDrop()),
Promise.resolve().then(() => this.colorStripes()),
Promise.resolve().then(() => this.loadCharacterRanking()),
Promise.resolve().then(() => this.assignTooltipOffsets()),
Promise.resolve().then(() => this.countUp())
])
@ -431,6 +432,26 @@ export default class AnimeNotifier {
}
}
loadCharacterRanking() {
if(!this.app.currentPath.includes("/character/")) {
return
}
for(let element of findAll("character-ranking")) {
fetch(`/api/character/${element.dataset.characterId}/ranking`).then(async response => {
let ranking = await response.text()
if(ranking.length === 0) {
return
}
Diff.mutations.queue(() => {
element.textContent = "#" + ranking
})
})
}
}
colorStripes() {
if(!this.app.currentPath.includes("/explore/color/")) {
return