-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
120 lines (112 loc) · 3.93 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
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title> Protocharts </title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js"></script>
<link rel="stylesheet" type="text/css" href="./public/style.css">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand">Protocharts</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<form class="navbar-form navbar-right">
<div class="form-group">
<button type="button" class="btn btn-default" id="login">Login</button>
<button type="button" class="btn btn-default" id="logout">Logout</button>
</div>
</div>
</nav>
</head>
<body>
<div style="text-align:center">
<h1>
<div id="welcome">
Welcome to Protocharts!
</div>
<div id="playername">
</div>
</h1>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-7">
<div id="content">
</div>
<div id="settings">
<h3>
Settings
</h3>
<div class="form-group" id="settings">
</div>
</div>
</div>
<div id="chart" class="col-md-5" style="width: 400px;">
</div>
</div>
</div>
<script>
document.getElementById("logout").style.display="none";
document.getElementById("settings").style.display="none";
document.getElementById("login").style.display="initial";
</script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://labratrevenge.com/d3-tip/javascripts/d3.tip.v0.6.3.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="./public/draw.js" ></script>
<script src="https://login.persona.org/include.js"></script>
<script>
getChart("sample");
navigator.id.watch({
onlogin: function(assertion) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/persona/verify", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.addEventListener("loadend", function(e) {
var data = JSON.parse(this.responseText);
if (data && data.status === "okay") {
getChart((data.email));
document.getElementById("logout").style.display="initial";
document.getElementById("login").style.display="none";
document.getElementById("welcome").style.display="none";
document.getElementById("playername").style.display="initial";
}
}, false);
xhr.send(JSON.stringify({
assertion: assertion
}));
},
onlogout: function() {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/persona/logout", true);
xhr.addEventListener("loadend", function(e) {
document.getElementById("logout").style.display="none";
document.getElementById("settings").style.display="none";
document.getElementById("login").style.display="initial";
document.getElementById("welcome").style.display="initial";
document.getElementById("playername").style.display="none";
});
xhr.send();
}
});
document.querySelector("#login").addEventListener("click", function() {
navigator.id.request();
}, false);
document.querySelector("#logout").addEventListener("click", function() {
navigator.id.logout();
window.location.reload();
}, false);
</script>
</body>
</html>