feat: add app entry point, password toggle, and schedule modules
This commit is contained in:
15
static/app.ts
Normal file
15
static/app.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import "./theme";
|
||||||
|
import "./toast";
|
||||||
|
import "./htmx";
|
||||||
|
import "./dropdown";
|
||||||
|
import "./discover";
|
||||||
|
import "./anime";
|
||||||
|
import "./timezone";
|
||||||
|
import "./search";
|
||||||
|
import "./sort_filter";
|
||||||
|
import "./dedupe";
|
||||||
|
import "./shell";
|
||||||
|
import "./watchlist";
|
||||||
|
import "./top_pick_carousel";
|
||||||
|
import "./login";
|
||||||
|
import "./schedule";
|
||||||
22
static/login.ts
Normal file
22
static/login.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const initPasswordToggle = (): void => {
|
||||||
|
document.addEventListener("click", (event) => {
|
||||||
|
const target = event.target;
|
||||||
|
if (!(target instanceof Element)) return;
|
||||||
|
|
||||||
|
const button = target.closest<HTMLButtonElement>("[data-toggle-password]");
|
||||||
|
if (!button) return;
|
||||||
|
|
||||||
|
const field = button.closest("form")?.querySelector<HTMLInputElement>("#password");
|
||||||
|
const openEye = button.querySelector<SVGElement>("[data-eye-open]");
|
||||||
|
const closedEye = button.querySelector<SVGElement>("[data-eye-closed]");
|
||||||
|
if (!(field instanceof HTMLInputElement) || !openEye || !closedEye) return;
|
||||||
|
|
||||||
|
const showPassword = field.type === "password";
|
||||||
|
field.type = showPassword ? "text" : "password";
|
||||||
|
button.setAttribute("aria-label", showPassword ? "Hide password" : "Show password");
|
||||||
|
openEye.classList.toggle("hidden", showPassword);
|
||||||
|
closedEye.classList.toggle("hidden", !showPassword);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
initPasswordToggle();
|
||||||
13
static/schedule.ts
Normal file
13
static/schedule.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { onReady } from "./utils";
|
||||||
|
|
||||||
|
const scheduleTimezone = (): string => Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
|
||||||
|
|
||||||
|
const initScheduleLoader = (): void => {
|
||||||
|
onReady(() => {
|
||||||
|
const loader = document.querySelector<HTMLElement>("[data-schedule-loader]");
|
||||||
|
if (!loader) return;
|
||||||
|
loader.setAttribute("hx-vals", JSON.stringify({ timezone: scheduleTimezone() }));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
initScheduleLoader();
|
||||||
Reference in New Issue
Block a user