aboutsummaryrefslogtreecommitdiff
path: root/frontend/pwmodal.ts
blob: 485896af01a1ea9b7e136958a0073215d9dfa370 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { e } from "./helper.ts"
import { try_load_admin_panel } from "./admin.ts"

export function pw_modal() {
    let inp_name: HTMLInputElement, inp_pw: HTMLInputElement, error_msg: HTMLSpanElement;
    return e("dialog", {},
        e("form", { method: "dialog" },
            inp_name = e("input", { type: "text", placeholder: "Username" }),
            inp_pw = e("input", { type: "password", placeholder: "Password" }),
            e("button", {
                onclick: ev => {
                    ev.preventDefault()
                    try_load_admin_panel(inp_name.value, inp_pw.value).catch(err => {
                        error_msg.textContent = err
                    })
                }
            }, "Login"),
            error_msg = e("span", { class: "error-msg" }, ""),
        )
    )
}