-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
93 lines (75 loc) · 2.64 KB
/
index.html
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Chat</title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<section class="section">
<div class="container">
<h1 class="title">
Welcome to your chat!
</h1>
<section id="welcome">
<hr>
Do you have a Solid Pod?
<hr>
<button id="login" class="button button is-info is-rounded">Log in</button>
<hr>
No, choose from the list of Pod Providers!
<hr>
<a href="https://solid.inrupt.com/get-a-solid-pod" target="_blank" class="button button is-info is-rounded">I Want a Solid Pod!</a>
<hr>
</section>
<section id="logout" style="display:none">
<hr>
<a id="user" target="_blank" href="#"></a>
<hr>
<button class="button button is-info is-rounded">Log out</button>
</section>
</div>
</section>
<script src="https://lisa159.github.io/TestHelloWorld/scripts/solid-auth-client.bundle.js"></script>
<script src="https://lisa159.github.io/TestHelloWorld/scripts/rdflib.min.js"></script>
<script>
function renderLogin(webId) {
let logout = document.getElementById('logout')
let welcome = document.getElementById('welcome')
let user = document.getElementById('user')
logout.style.display = ''
welcome.style.display = 'none'
user.textContent = webId
user.setAttribute('href', webId)
}
function renderLogout() {
let logout = document.getElementById('logout')
let welcome = document.getElementById('welcome')
logout.style.display = 'none'
welcome.style.display = ''
}
function handleLogin() {
// login event
solid.auth.trackSession(session => {
if (session && session.webId) {
renderLogin(session.webId)
} else {
renderLogout()
}
})
}
// Log the user in and out on click
function addListeners() {
let login = document.getElementById('login')
let logout = document.getElementById('logout')
// login and logout buttons
const popupUri = 'https://lisa159.github.io/TestHelloWorld/popup.html'
login.addEventListener('click', () => solid.auth.popupLogin({ popupUri }))
logout.addEventListener('click', () => solid.auth.logout())
handleLogin()
}
addListeners()
</script>
</body>
</html>