Skip to content

Commit 6f92697

Browse files
committed
feat: add onload js setup
1 parent d45c7f1 commit 6f92697

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

views/login.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{{{card}}}
33

44
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_login_trigger"}}
5+
{{> js_setup nodes=nodes}}
56
{{#if extraPartial }}
67
{{> (extraPartial) }}
78
{{/if}}

views/partials/js_setup.hbs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{{! This partial sets up the onclick and onload event handlers for each passkey node.}}
2+
<script type="text/javascript">
3+
// register onclick and onload event handlers for each passkey node.
4+
window.addEventListener("load", () => {
5+
{{#each (onlyNodes nodes "passkey" "")}}
6+
{{#if attributes.onclick}}
7+
// onclick for {{attributes.name}}
8+
document.getElementsByName("{{attributes.name}}").forEach((el) => {
9+
el.addEventListener("click", () => { {{{attributes.onclick}}} })
10+
})
11+
{{/if}}
12+
{{#if attributes.onload}}
13+
// onload for {{attributes.name}}
14+
{{{attributes.onload}}}
15+
{{/if}}
16+
{{/each}}
17+
})
18+
</script>

views/registration.hbs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{{{card}}}
44

55
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
6+
{{> js_setup nodes=nodes}}
67
{{#if extraPartial }}
78
{{> (extraPartial) }}
89
{{/if}}

views/settings.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
</div>
66

77
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
8-
8+
{{> js_setup nodes=nodes}}
99
</div>

0 commit comments

Comments
 (0)