diff --git a/pages/editor/mal.go b/pages/editor/mal.go index f7c66eeb..874424f5 100644 --- a/pages/editor/mal.go +++ b/pages/editor/mal.go @@ -2,6 +2,7 @@ package editor import ( "sort" + "strconv" "github.com/animenotifier/notify.moe/utils/animediff" @@ -18,9 +19,14 @@ const maxCompareMALEntries = 15 func CompareMAL(ctx *aero.Context) string { user := utils.GetUser(ctx) year, _ := ctx.GetInt("year") + status := ctx.Get("status") animeType := ctx.Get("type") animes := arn.FilterAnime(func(anime *arn.Anime) bool { + if status != "" && anime.Status != status { + return false + } + if year != 0 && year != anime.StartDateTime().Year() { return false } @@ -100,7 +106,7 @@ func CompareMAL(ctx *aero.Context) string { } // Airing start date - if anime.StartDate != malAnime.StartDate { + if anime.StartDate != malAnime.StartDate && malAnime.StartDate != "" { hash := utils.HashString(malAnime.StartDate) if !arn.IsAnimeDifferenceIgnored(anime.ID, "mal", malAnime.ID, "StartDate", hash) { @@ -192,5 +198,5 @@ func CompareMAL(ctx *aero.Context) string { } } - return ctx.HTML(components.CompareMAL(comparisons, ctx.URI(), user)) + return ctx.HTML(components.CompareMAL(comparisons, strconv.Itoa(year), status, animeType, ctx.URI(), user)) } diff --git a/pages/editor/mal.pixy b/pages/editor/mal.pixy index 716363b8..935ffab2 100644 --- a/pages/editor/mal.pixy +++ b/pages/editor/mal.pixy @@ -1,6 +1,7 @@ -component CompareMAL(comparisons []*utils.MALComparison, url string, user *arn.User) +component CompareMAL(comparisons []*utils.MALComparison, year string, status string, typ string, url string, user *arn.User) EditorTabs(url) h1.mountable MAL comparison + ExploreFilters(year, status, typ, "malDiffFilterAnime") .data-comparisons each comparison in comparisons diff --git a/pages/explore/explore.pixy b/pages/explore/explore.pixy index efa2ece4..8c477302 100644 --- a/pages/explore/explore.pixy +++ b/pages/explore/explore.pixy @@ -1,5 +1,5 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string, user *arn.User) - ExploreFilters(year, status, typ) + ExploreFilters(year, status, typ, "filterAnime") .corner-buttons-hide-on-mobile button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection") @@ -16,18 +16,18 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s else AnimeGrid(animeList, user) -component ExploreFilters(year string, status string, typ string) +component ExploreFilters(year string, status string, typ string, action string) .explore-filters - select#filter-year.action(value=year, data-action="filterAnime", data-trigger="change") + select#filter-year.action(value=year, data-action=action, data-trigger="change") for year := time.Now().Year()+1; year >= 1951; year-- option(value=year)= year - select#filter-status.action(value=status, data-action="filterAnime", data-trigger="change") + select#filter-status.action(value=status, data-action=action, data-trigger="change") option(value="current") Current option(value="upcoming") Upcoming option(value="finished") Finished - select#filter-type.action(value=typ, data-action="filterAnime", data-trigger="change") + select#filter-type.action(value=typ, data-action=action, data-trigger="change") option(value="tv") TV option(value="movie") Movie option(value="ova") OVA diff --git a/pages/index.go b/pages/index.go index 50d9212d..1bbd897f 100644 --- a/pages/index.go +++ b/pages/index.go @@ -215,6 +215,9 @@ func Configure(app *aero.Application) { l.Page("/editor/anime/missing/genres/:year", editor.Genres) l.Page("/editor/anime/missing/genres/:year/:type", editor.Genres) l.Page("/editor/anime/maldiff", editor.CompareMAL) + l.Page("/editor/anime/maldiff/:year", editor.CompareMAL) + l.Page("/editor/anime/maldiff/:year/:status", editor.CompareMAL) + l.Page("/editor/anime/maldiff/:year/:status/:type", editor.CompareMAL) // Log l.Page("/log", editlog.Get) diff --git a/scripts/Actions/Editor.ts b/scripts/Actions/Editor.ts index daa88b22..fc17805d 100644 --- a/scripts/Actions/Editor.ts +++ b/scripts/Actions/Editor.ts @@ -17,4 +17,13 @@ export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement arn.reloadContent() }) .catch(err => arn.statusMessage.showError(err)) +} + +// Filter anime on maldiff page +export function malDiffFilterAnime(arn: AnimeNotifier, input: HTMLInputElement) { + let year = arn.app.find("filter-year") as HTMLSelectElement + let status = arn.app.find("filter-status") as HTMLSelectElement + let type = arn.app.find("filter-type") as HTMLSelectElement + + arn.app.load(`/editor/anime/maldiff/${year.value}/${status.value}/${type.value}`) } \ No newline at end of file