refactor: replace inline scripts with module scripts block
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{{define "title"}}Login{{end}}
|
{{define "title"}}Login{{end}}
|
||||||
|
{{define "scripts"}}{{end}}
|
||||||
{{define "content"}}
|
{{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">
|
<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">
|
<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">
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
placeholder="you@example.com"
|
placeholder="you@example.com"
|
||||||
required
|
required
|
||||||
value="{{.Username}}"
|
value="{{.Username}}"
|
||||||
class="h-10 w-full bg-background-surface px-3 text-foreground outline-none transition focus:ring-1 focus:ring-accent rounded-none!"
|
class="h-10 w-full bg-background-surface px-3 text-foreground outline-none transition focus:ring-1 focus:ring-accent rounded-none!"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -96,30 +97,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</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}}
|
{{end}}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{{define "title"}}Schedule{{end}}
|
{{define "title"}}Schedule{{end}}
|
||||||
|
{{define "scripts"}}<script type="module" src="/dist/static/schedule_board.js" defer></script>{{end}}
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<div class="flex flex-col gap-12 pb-24">
|
<div class="flex flex-col gap-12 pb-24">
|
||||||
<section class="px-1">
|
<section class="px-1">
|
||||||
@@ -8,8 +9,8 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
data-schedule-loader
|
||||||
hx-get="/api/schedule?year={{.ScheduleYear}}&week={{.ScheduleWeek}}"
|
hx-get="/api/schedule?year={{.ScheduleYear}}&week={{.ScheduleWeek}}"
|
||||||
hx-vals='js:{timezone: Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC"}'
|
|
||||||
hx-trigger="load"
|
hx-trigger="load"
|
||||||
hx-swap="outerHTML"
|
hx-swap="outerHTML"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user