Added anime multisearch
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import AnimeNotifier from "../AnimeNotifier"
|
||||
import { findAllInside } from "../Utils";
|
||||
import { showSearchResults } from "./Search"
|
||||
|
||||
// newAnimeDiffIgnore
|
||||
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
@ -34,4 +36,23 @@ export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonEle
|
||||
} else {
|
||||
arn.statusMessage.showError(await response.text())
|
||||
}
|
||||
}
|
||||
|
||||
// Multi-search anime
|
||||
export async function multiSearchAnime(arn: AnimeNotifier, textarea: HTMLTextAreaElement) {
|
||||
let results = document.getElementById("multi-search-anime") as HTMLDivElement
|
||||
let animeTitles = textarea.value.split("\n")
|
||||
let animeIDs = new Array<string>(animeTitles.length)
|
||||
|
||||
results.innerHTML = ""
|
||||
|
||||
for(let i = 0; i < animeTitles.length; i++) {
|
||||
console.log(animeTitles[i])
|
||||
let response = await fetch("/_/anime-search/" + animeTitles[i])
|
||||
let html = await response.text()
|
||||
results.innerHTML += "<h3>" + animeTitles[i] + "</h3>" + html
|
||||
}
|
||||
|
||||
results.classList.remove("hidden")
|
||||
showSearchResults(arn, results)
|
||||
}
|
@ -165,10 +165,14 @@ function showResponseInElement(arn: AnimeNotifier, url: string, typeName: string
|
||||
|
||||
await arn.innerHTML(element, html)
|
||||
|
||||
// Do the same as for the content loaded event,
|
||||
// except here we are limiting it to the element.
|
||||
arn.app.ajaxify(element.getElementsByTagName("a"))
|
||||
arn.lazyLoad(findAllInside("lazy", element))
|
||||
arn.mountMountables(findAllInside("mountable", element))
|
||||
showSearchResults(arn, element)
|
||||
}
|
||||
}
|
||||
|
||||
export function showSearchResults(arn: AnimeNotifier, element: HTMLElement) {
|
||||
// Do the same as for the content loaded event,
|
||||
// except here we are limiting it to the element.
|
||||
arn.app.ajaxify(element.getElementsByTagName("a"))
|
||||
arn.lazyLoad(findAllInside("lazy", element))
|
||||
arn.mountMountables(findAllInside("mountable", element))
|
||||
}
|
||||
|
Reference in New Issue
Block a user