-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
70 lines (44 loc) · 1.6 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import './style.css';
import LoginId from "ul-javascript/login-id"
console.log("[debug]", "script-sdk.js")
// [step-1] SDK instantiate
const login = new LoginId()
// [step-2] Creating Simple login-ui
const formString = /*html*/`
<form class="conatiner">
<h1>Sign In</h1>
<label for="username">Username</label>
<input type="text" name="username">
<button id="signIn">Sign In</button>
</form>
`;
// [step-3] Adding UI to the dom
const template = document.createElement('div');
template.innerHTML = formString.trim();
document.body.appendChild(template);
// [step-4] Event handler attached to login button
document.getElementById('signIn').addEventListener('click', (event) => {
event.preventDefault();
const usernameFieldValue = document.querySelector('input[name="username"]').value;
login.continueWithUsername({
username: usernameFieldValue
});
});
/**
* Misc code snippets
*/
// 1. Enable connections
// import { createConnections } from './features/connections';
// const getConnections = createConnections(login.transaction.connections);
// document.body.appendChild(getConnections);
// document.getElementById('google-oauth2').addEventListener('click', (event) => {
// event.preventDefault();
// const usernameField = document.querySelector('input[name="username"]').value;
// login.submitFederatedLoginData({connection: 'google-oauth2'})
// });
// 2. Enable form submission
// const form = template.querySelector('form');
// form.addEventListener('submit', (event) => {
// event.preventDefault(); // Prevent the default form submission
// login.submitForm(event)
// });