2018-04-02 05:34:16 +00:00
|
|
|
|
import AnimeNotifier from "../AnimeNotifier"
|
2017-12-02 20:06:15 +00:00
|
|
|
|
import { findAll } from "scripts/Utils";
|
2017-11-07 16:46:39 +00:00
|
|
|
|
|
|
|
|
|
// Filter anime on explore page
|
|
|
|
|
export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) {
|
2018-04-02 05:44:11 +00:00
|
|
|
|
let root = document.getElementById("filter-root")
|
2018-03-23 00:43:45 +00:00
|
|
|
|
|
2018-04-02 05:44:11 +00:00
|
|
|
|
let elementYear = document.getElementById("filter-year") as HTMLSelectElement
|
2018-04-13 15:55:52 +00:00
|
|
|
|
let elementSeason = document.getElementById("filter-season") as HTMLSelectElement
|
2018-04-02 05:44:11 +00:00
|
|
|
|
let elementStatus = document.getElementById("filter-status") as HTMLSelectElement
|
|
|
|
|
let elementType = document.getElementById("filter-type") as HTMLSelectElement
|
2017-11-07 16:46:39 +00:00
|
|
|
|
|
2018-03-14 03:18:57 +00:00
|
|
|
|
for(let element of findAll("anime-grid-image")) {
|
|
|
|
|
let img = element as HTMLImageElement
|
2018-03-20 22:58:37 +00:00
|
|
|
|
img.src = arn.emptyPixel()
|
2018-03-14 03:18:57 +00:00
|
|
|
|
img.classList.remove("element-found")
|
2018-03-20 22:58:37 +00:00
|
|
|
|
img.classList.remove("element-color-preview")
|
2018-03-14 02:50:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-23 00:43:45 +00:00
|
|
|
|
let year = elementYear.value || "any"
|
2018-04-13 15:55:52 +00:00
|
|
|
|
let season = elementSeason.value || "any"
|
2018-03-23 00:43:45 +00:00
|
|
|
|
let status = elementStatus.value || "any"
|
|
|
|
|
let type = elementType.value || "any"
|
|
|
|
|
|
2018-04-13 15:55:52 +00:00
|
|
|
|
arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`)
|
2017-12-02 20:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 08:59:53 +00:00
|
|
|
|
// Hides anime that are already in your list. And "toggles" localStorage.hide if button is pressed
|
2018-07-05 15:46:33 +00:00
|
|
|
|
export function hideAddedAnime(arn?: AnimeNotifier, input?: HTMLButtonElement) {
|
|
|
|
|
if(input) {
|
|
|
|
|
if(localStorage.getItem("hideAdded") === "true") {
|
|
|
|
|
localStorage.setItem("hideAdded", "false")
|
|
|
|
|
} else {
|
|
|
|
|
localStorage.setItem("hideAdded", "true")
|
|
|
|
|
}
|
2018-07-05 08:59:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-07-05 15:46:33 +00:00
|
|
|
|
if(localStorage.getItem("hideAdded") === "true" || input.type === "submit") {
|
2018-07-05 08:59:53 +00:00
|
|
|
|
for(let anime of findAll("anime-grid-cell")) {
|
|
|
|
|
if(anime.dataset.added === "true") {
|
|
|
|
|
anime.classList.toggle("anime-grid-cell-hide")
|
|
|
|
|
}
|
2017-12-02 20:06:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-03 18:08:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Hides anime that are not in your list.
|
|
|
|
|
export function calendarShowAddedAnimeOnly() {
|
|
|
|
|
for(let anime of findAll("calendar-entry")) {
|
|
|
|
|
if(anime.dataset.added === "false") {
|
|
|
|
|
anime.classList.toggle("hidden")
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-07 16:46:39 +00:00
|
|
|
|
}
|