Added anime multisearch
This commit is contained in:
parent
a8fad80990
commit
966943fd2e
@ -60,6 +60,7 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/pages/quotes"
|
"github.com/animenotifier/notify.moe/pages/quotes"
|
||||||
"github.com/animenotifier/notify.moe/pages/recommended"
|
"github.com/animenotifier/notify.moe/pages/recommended"
|
||||||
"github.com/animenotifier/notify.moe/pages/search"
|
"github.com/animenotifier/notify.moe/pages/search"
|
||||||
|
"github.com/animenotifier/notify.moe/pages/search/multisearch"
|
||||||
"github.com/animenotifier/notify.moe/pages/settings"
|
"github.com/animenotifier/notify.moe/pages/settings"
|
||||||
"github.com/animenotifier/notify.moe/pages/shop"
|
"github.com/animenotifier/notify.moe/pages/shop"
|
||||||
"github.com/animenotifier/notify.moe/pages/soundtrack"
|
"github.com/animenotifier/notify.moe/pages/soundtrack"
|
||||||
@ -252,7 +253,9 @@ func Configure(app *aero.Application) {
|
|||||||
l.Page("/soundtrack-search/*term", search.SoundTracks)
|
l.Page("/soundtrack-search/*term", search.SoundTracks)
|
||||||
l.Page("/user-search/*term", search.Users)
|
l.Page("/user-search/*term", search.Users)
|
||||||
l.Page("/company-search/*term", search.Companies)
|
l.Page("/company-search/*term", search.Companies)
|
||||||
|
l.Page("/multisearch/anime", multisearch.Anime)
|
||||||
|
|
||||||
|
// Shop
|
||||||
// Shop
|
// Shop
|
||||||
l.Page("/support", support.Get)
|
l.Page("/support", support.Get)
|
||||||
l.Page("/shop", shop.Get)
|
l.Page("/shop", shop.Get)
|
||||||
|
11
pages/search/multisearch/multisearch.go
Normal file
11
pages/search/multisearch/multisearch.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package multisearch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/aerogo/aero"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Anime search page.
|
||||||
|
func Anime(ctx *aero.Context) string {
|
||||||
|
return ctx.HTML(components.MultiSearch())
|
||||||
|
}
|
3
pages/search/multisearch/multisearch.pixy
Normal file
3
pages/search/multisearch/multisearch.pixy
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
component MultiSearch
|
||||||
|
textarea.action(data-action="multiSearchAnime", data-trigger="change", placeholder="Paste multiple anime titles here, one per line")
|
||||||
|
#multi-search-anime
|
@ -1,4 +1,6 @@
|
|||||||
import AnimeNotifier from "../AnimeNotifier"
|
import AnimeNotifier from "../AnimeNotifier"
|
||||||
|
import { findAllInside } from "../Utils";
|
||||||
|
import { showSearchResults } from "./Search"
|
||||||
|
|
||||||
// newAnimeDiffIgnore
|
// newAnimeDiffIgnore
|
||||||
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
|
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||||
@ -34,4 +36,23 @@ export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonEle
|
|||||||
} else {
|
} else {
|
||||||
arn.statusMessage.showError(await response.text())
|
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)
|
await arn.innerHTML(element, html)
|
||||||
|
|
||||||
// Do the same as for the content loaded event,
|
showSearchResults(arn, element)
|
||||||
// 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))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user