import AnimeNotifier from "../AnimeNotifier" // newAnimeDiffIgnore export async function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) { if(!confirm("Are you sure you want to permanently ignore this difference?")) { return } const id = button.dataset.id const hash = button.dataset.hash try { await arn.post(`/api/new/ignoreanimedifference`, { id, hash }) arn.reloadContent() } catch(err) { arn.statusMessage.showError(err) } } // Import Kitsu anime export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) { if(!confirm("Are you sure you want to import this anime?")) { return } const newTab = window.open() if(!newTab) { arn.statusMessage.showError("Error opening new tab") return } const animeId = button.dataset.id const response = await fetch(`/api/import/kitsu/anime/${animeId}`, { method: "POST", credentials: "same-origin" }) if(response.ok) { newTab.location.href = `/kitsu/anime/${animeId}` arn.reloadContent() } else { arn.statusMessage.showError(await response.text()) } } // Delete Kitsu anime export async function deleteKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) { if(!confirm("Are you sure you want to delete this anime?")) { return } const animeId = button.dataset.id await arn.post(`/api/delete/kitsu/anime/${animeId}`) arn.reloadContent() } // Multi-search anime export async function multiSearchAnime(arn: AnimeNotifier, textarea: HTMLTextAreaElement) { const results = document.getElementById("multi-search-anime") as HTMLDivElement const animeTitles = textarea.value.split("\n") results.innerHTML = "" for(let i = 0; i < animeTitles.length; i++) { console.log(animeTitles[i]) const response = await fetch("/_/anime-search/" + animeTitles[i]) const html = await response.text() results.innerHTML += "