refactor: replace inline scripts with module scripts block
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
{{define "title"}}Login{{end}}
|
||||
{{define "scripts"}}{{end}}
|
||||
{{define "content"}}
|
||||
<main class="flex min-h-dvh items-center justify-center bg-[url(/static/images/background.png)] bg-cover bg-center px-3 py-4 sm:px-4 sm:py-8">
|
||||
<div class="mx-auto w-full max-w-[31.25rem] bg-background-surface px-5 pb-6 pt-7 shadow-sm sm:px-8 sm:pb-8 sm:pt-11 lg:px-12">
|
||||
@@ -96,30 +97,4 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(() => {
|
||||
const button = document.querySelector('[data-toggle-password]');
|
||||
const input = document.getElementById('password');
|
||||
const openEye = document.querySelector('[data-eye-open]');
|
||||
const closedEye = document.querySelector('[data-eye-closed]');
|
||||
if (!(button instanceof HTMLButtonElement)) return;
|
||||
if (!(input instanceof HTMLInputElement)) return;
|
||||
if (!(openEye instanceof SVGElement)) return;
|
||||
if (!(closedEye instanceof SVGElement)) return;
|
||||
|
||||
let showPassword = false;
|
||||
const render = () => {
|
||||
input.type = showPassword ? 'text' : 'password';
|
||||
button.setAttribute('aria-label', showPassword ? 'Hide password' : 'Show password');
|
||||
openEye.classList.toggle('hidden', showPassword);
|
||||
closedEye.classList.toggle('hidden', !showPassword);
|
||||
};
|
||||
|
||||
button.addEventListener('click', () => {
|
||||
showPassword = !showPassword;
|
||||
render();
|
||||
});
|
||||
render();
|
||||
})();
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{{define "title"}}Schedule{{end}}
|
||||
{{define "scripts"}}<script type="module" src="/dist/static/schedule_board.js" defer></script>{{end}}
|
||||
{{define "content"}}
|
||||
<div class="flex flex-col gap-12 pb-24">
|
||||
<section class="px-1">
|
||||
@@ -8,8 +9,8 @@
|
||||
</section>
|
||||
|
||||
<div
|
||||
data-schedule-loader
|
||||
hx-get="/api/schedule?year={{.ScheduleYear}}&week={{.ScheduleWeek}}"
|
||||
hx-vals='js:{timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC"}'
|
||||
hx-trigger="load"
|
||||
hx-swap="outerHTML"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user