-
Notifications
You must be signed in to change notification settings - Fork 0
/
#index.html#
145 lines (119 loc) · 3.79 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
<!DOCTYPE html>
<html>
<head>
<title>Bounce</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<meta charset="UTF-8">
</head>
<body>
<script>
var id, friends, parties;
function statusChangeCallback(response) {
if (response.status === 'connected') {
FB.api('/me', function(response) {
window.id = response["id"];
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
FB.api('/me/friends', function (response) {
if (response && !response.error) {
window.friends = response;
}
});
} else if (response.status === 'not_authorized') {
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : '960379903977296',
cookie : true,
xfbml : true,
version : 'v2.1'
});
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function checkin(location) {
// var location = document.getElementById("location").value;
var xmlhttp = new XMLHttpRequest();
var url = "http://bounce.grantadd.is/checkin.php";
var params = "location=" + location + "&userid=" + window.id;
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xmlhttp.send(params);
}
function checkParties() {
var url = "http://bounce.grantadd.is/checkparties.php?userid=";
url += window.id + "&friendCount=" + window.friends.data.length;
FB.api('/me/friends', function (response) {
if (response && !response.error) {
window.friends = response;
}
});
for (var i = 0; i < window.friends.data.length; i++) {
url += "&fid"+i+"=" ;
url += window.friends.data[i].id;
}
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
if (xmlhttp.status === 200) {
window.parties = eval(xmlhttp.response);
return window.parties.sort(function(a, b) {
return (a[1] + a[2]) < (b[1] + b[2]);
});
}
}
function checkGuests(pid) {
var xmlhttp = new XMLHttpRequest();
var url = "http://bounce.grantadd.is/checkguests.php?pid=" + pid;
xmlhttp.open("GET", url, false);
xmlhttp.send(null);
var friendsAtParty = new Array();
if (xmlhttp.status === 200) {
var friendIDs = eval(xmlhttp.response);
for (var i = 0; i < friendIDs.length; i++) {
for (var j = 0; j < window.friends.data.length; j++) {
if (friendIDs[i] == window.friends.data[j].id) {
friendsAtParty.push(window.friends.data[j].name);
}
}
}
}
return friendsAtParty;
}
</script>
<!--
Below we include the Login Button social plugin. This button uses
the JavaScript SDK to present a graphical Login button that triggers
the FB.login() function when clicked.
-->
<fb:login-button scope="user_friends" onlogin="checkLoginState();">
</fb:login-button>
<div id="status">
</div>
<input id="location"></input><br>
<button id="submit" onclick="checkin()">Check In</button><br>
<button id="where" onclick="checkParties()">Check Parties</button>
<script>
</script>
</body>
</html>