This repository has been archived by the owner on May 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 264
/
index.html
70 lines (63 loc) · 1.75 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; width=device-width;">
<title>
BrowserID Example Primary
</title>
<style type="text/css">
body { margin: auto; font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; }
.title { font-size: 2em; font-weight: bold; text-align: center; margin: 1.5em; }
.intro { font-size: 1.2em; width: 600px; margin: auto; }
.main { text-align: center; margin-top: 2em; font-size: 1.2em; width: 500px; margin: auto; display: none; }
#whoareyou { font-weight: bold; }
</style>
</head>
<body>
<div class="title">
Example BrowserID Primary
</div>
<div class="intro">
An example BrowserID Primary identity authority. Useful for local testing and development.
</div>
<div class="main" id="logged_in">
You are logged in as <span id="whoareyou"></span>. <a id="logout" href="#">logout</a>.
</div>
<div class="main" id="logged_out">
You are not logged in. Who would you like to be?
<input type="text">
<button>doit</button>
</div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
function updateWhoIAm() {
$(".main").hide();
$.get('/api/whoami')
.success(function(r) {
if (r) {
$("#whoareyou").text(r);
$("#logged_in").show();
} else {
$("#logged_out").show();
}
});
}
$("button").click(function(e) {
$.get('/api/login', { user: $.trim($("input").val()) })
.success(function(r) {
updateWhoIAm();
});
});
$("#logout").click(function(e) {
$.get('/api/logout')
.success(function(r) {
updateWhoIAm();
});
});
updateWhoIAm();
});
</script>
</body>
</html>