1 /** @license 0BSD 2020 k0tyk <k0tyk@pm.me> */
2 import { createElement as h
} from "./.crank/index.js";
3 import { Todo
} from "./m.js";
10 /** @param {Props} props */ export async
function c(props
) {
11 var { TodoQ
} = await
import("./.mq.js");
12 var { Repo
} = await
import("./repo.js");
13 var m
= /^\?done\.set=([01])\&id\.eq=(.+)$/.exec(props
.location
.search
);
16 { done
: Number(m
[1]) },
17 new TodoQ().id
.eq(decodeURIComponent(m
[2]))
19 return { ...props
, title
: "TodoV", xs
: new Repo(Todo
).get(new TodoQ()) };
21 /** @param {Props} props */ export function* v(props
) {
23 this.addEventListener("click", (ev
) => {
24 if (/^done/.test(ev
.target
.id
))
26 if (x
.id
== ev
.target
.value
)
28 `/todo?done.set=${x.done ? 0 : 1}&id.eq=${encodeURIComponent(x.id)}`
30 .then(async (x
) => ((m
= await x
.json()), this.refresh()))
31 .catch((e
) => alert(`${e.message}\n${e.stack}`));
34 yield h("form", { style
: { "line-height": 1.5, padding
: "0 4em" } }, [
35 h("h1", null, m
.title
),
37 h("p", { id
: x
.id
}, [
39 checked
: x
.done
? "checked" : null,
45 h("label", { for: `done${x.id}` }, x
.text
),