-
Notifications
You must be signed in to change notification settings - Fork 3
/
index_old.html
118 lines (102 loc) · 3.21 KB
/
index_old.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
<head>
<title>Virion</title>
<style>
body {
background: white;
color: black;
font-family: Arial, sans-serif;
}
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21739289-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<!-- Facebook Integration
All of this is just to set g_user_id and g_user_name
-->
<!-- This initialized the SDK so we can use it -->
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:179028108782663, cookie:true,
status:true, xfbml:true
});
// Reload when user logs in (like with the fb login button)
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
</script>
<script>
// If user is already logged in, then refresh to get
// the auth token
if(window.location.hash.length == 0)
{
var real_index = "http://virus-game.cs.brown.edu/game/fb/index1.html";
var url = "https://www.facebook.com/dialog/oauth?client_id= \
179028108782663&redirect_uri=" + real_index + //window.location + "1"+
"&response_type=token";
//window.open(url);
//window.location = url;
FB.getLoginStatus(function(response) {
if (response.session) { //logged in and known
console.log("refreshing");
window.location=url;
return false; // For safari on macs
}
else {
window.location = real_index;
}
})
} else { // access token in URL
accessToken = window.location.hash.substring(1);
// Only update if hash is from facebook
//console.log(accessToken.indexOf('access_token'));
if (accessToken.indexOf('access_token') !== -1) {
graphUrl = "https://graph.facebook.com/me?" + accessToken +
"&callback=got_user"
//use JSON-P to call the graph
var script = document.createElement("script");
script.src = graphUrl;
document.body.appendChild(script);
}
}
//initialize global user variables to null
g_user_id = null;
g_user_name = null;
// This 'user' object has all the info from fb
function got_user(user) {
//userName.innerText = user.name;
//console.log("user id: " + user.id);
// Error checking, only update if it went correctly
if (user.id) {
//Global vars for Unique User ID and name
g_user_id = user.id;
g_user_name = user.name;
// do scores after setting name and id
//scores.do_scores();
// Display name
/*
console.log("Adding name");
var name_div = document.getElementById('fb_name_div');
name_div.innerHTML = "";//"Your are logged in as " + g_user_name;
*/
// Remove fb login button
var login_div = document.getElementById("fb_login_button");
login_div.parentNode.removeChild(login_div);
}
else {
console.log("Error in getting facebook info");
}
}
</script>
</body>