-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
160 lines (142 loc) · 4.63 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Join Solid</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>
</head>
<body>
<nav class="navbar" role="navigation" aria-label="main navigation">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
Solid
</a>
<a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div id="navbarBasicExample" class="navbar-menu">
<div class="navbar-start">
<a class="navbar-item">
Home
</a>
<a class="navbar-item">
Documentation
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link">
More
</a>
<div class="navbar-dropdown">
<a class="navbar-item">
About
</a>
<a class="navbar-item">
Contact
</a>
<hr class="navbar-divider">
<a class="navbar-item">
Report an issue
</a>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<a id="register" href="https://solid.inrupt.com/get-a-solid-pod" target="_blank" class="button is-primary">
<strong>Sign up</strong>
</a>
<a id="login" class="button is-light">
Login
</a>
<a id="logout" class="button is-light" style="display:none">
Logout
</a>
</div>
</div>
</div>
</div>
</nav>
<section class="section">
<div class="container">
<h1 class="title">
App goes here...
</h1>
<section id="app" style="display:none">
<hr>
<a id="user" target="_blank" href="#"></a>
<hr>
</section>
</div>
</section>
<script src="https://melvincarvalho.github.io/helloworld/scripts/jquery.js"></script>
<script src="https://melvincarvalho.github.io/helloworld/scripts/solid-auth-client.bundle.js"></script>
<script src="https://melvincarvalho.github.io/helloworld/scripts/rdflib.min.js"></script>
<script>
function renderLogin(webId) {
console.log('logged in as', webId)
let logout = document.getElementById("logout");
let login = document.getElementById("login");
let register = document.getElementById("register");
let app = document.getElementById("app");
logout.style.display = "";
register.style.display = "none";
login.style.display = "";
app.style.display = "";
user.style.display = "";
user.textContent = webId;
user.setAttribute("href", webId);
}
function renderLogout() {
let logout = document.getElementById("logout");
let login = document.getElementById("login");
let register = document.getElementById("register");
let app = document.getElementById("app");
logout.style.display = "none";
app.style.display = "none";
login.style.display = "";
register.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://melvincarvalho.github.io/helloworld/popup.html";
login.addEventListener("click", () => solid.auth.popupLogin({
popupUri
}));
logout.addEventListener("click", () => solid.auth.logout());
handleLogin();
}
function hamburgerHelper() {
document.querySelector(".navbar-burger").addEventListener("click", toggleNav);
function toggleNav() {
var nav = document.querySelector(".navbar-menu");
if (nav.className == "navbar-menu") {
nav.className = "navbar-menu is-active";
} else {
nav.className = "navbar-menu";
}
}
}
addListeners();
hamburgerHelper();
</script>
</body>
</html>