forked from Mrman/Facebook-friend-selector
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
200 lines (142 loc) · 6.5 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Facebook Friend Selector</title>
<link rel="stylesheet" href="css/std.css" />
<link rel="stylesheet" href="css/fbfriendselector.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="js/fbfriendselector.js"></script>
<style>
body { font-family: sans-serif; color: #333; }
p { clear: left; }
#results { padding: 10px; border: 1px solid #333; font-family: monospace; }
</style>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : '310899418967373', // App ID
channelURL : '/channel.html', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
xfbml : true // parse XFBML
});
FB.getLoginStatus(function (res) {
var logged_in = res.status == "connected" ? true : false;
fbInit(logged_in);
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "https://connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
function fbInit(logged_in) {
if (logged_in) {
FB.api('/me', function (res) {
var img_url = 'https://graph.facebook.com/' + res.id + '/picture';
$('#fb-user img').attr('src', img_url);
$('#fb-user div').text("Your name is: " + res.name);
});
} else {
FB.Event.subscribe('auth.login', function () {
window.location = "http://fbfs.craig-saunders.co.uk/";
});
$('#fb-user').hide();
$('#fb-login').show();
}
}
</script>
<!-- end facebook-connect -->
<script type="text/javascript">
$(document).ready(function () {
$("#fb-login").hide();
var selector1, selector2, logActivity, callbackFriendSelected, callbackFriendUnselected, callbackMaxSelection, callbackSubmit;
// When a friend is selected, log their name and ID
callbackFriendSelected = function(friendId) {
var friend, name;
friend = FBFriendSelector.getFriendById(friendId);
name = friend.name;
logActivity('Selected ' + name + ' (ID: ' + friendId + ')');
};
// When a friend is deselected, log their name and ID
callbackFriendUnselected = function(friendId) {
var friend, name;
friend = FBFriendSelector.getFriendById(friendId);
name = friend.name;
logActivity('Unselected ' + name + ' (ID: ' + friendId + ')');
};
// When the maximum selection is reached, log a message
callbackMaxSelection = function() {
logActivity('Selected the maximum number of friends');
};
// When the user clicks OK, log a message
callbackSubmit = function(selectedFriendIds) {
logActivity('Clicked OK with the following friends selected: ' + selectedFriendIds.join(", "));
};
// Initialise the Friend Selector with options that will apply to all instances
FBFriendSelector.init({debug: true});
// Create some Friend Selector instances
selector1 = FBFriendSelector.newInstance({
callbackFriendSelected : callbackFriendSelected,
callbackFriendUnselected : callbackFriendUnselected,
callbackMaxSelection : callbackMaxSelection,
callbackSubmit : callbackSubmit,
});
selector2 = FBFriendSelector.newInstance({
callbackFriendSelected : callbackFriendSelected,
callbackFriendUnselected : callbackFriendUnselected,
callbackMaxSelection : callbackMaxSelection,
callbackSubmit : callbackSubmit,
maxSelection : 3,
autoDeselection : true
});
$("#nomax").click(function (e) {
e.preventDefault();
selector1.showFriendSelector();
});
$("#maxset").click(function (e) {
e.preventDefault();
selector2.showFriendSelector();
});
logActivity = function (message) {
$("#results").append('<div>' + new Date() + ' - ' + message + '</div>');
};
});
</script>
</head>
<body>
<div id="fb-root"></div>
<h1>Facebook friend selector</h1>
<br />
<p>This is a forked project from the <a href="http://labs.thesedays.com/blog/2011/06/20/the-missing-facebook-interface-component-for-friend-selection/" target="_blank">These Days Facebook friends selector</a>.</p>
<p>This project provides a clean interface for Facebook integrated applications to allow users to select friends from their friend lists.</p>
<p>Please respect your users and adhere to the <a href="http://developers.facebook.com/policy/" target="_blank">Facebook Platform Policies</a> when using this plugin.</p>
<p>The interface permits friend selection instances with a set maximum of friends to select, or no limit of friends that cab be selected.</p>
<br />
<p>Find the source for this plugin here (github): <a href="https://github.com/Mrman/Facebook-friend-selector">Facebook-friend-selector</a></p>
<div id="fb-login" class="fb-login-button" style="margin-top: 15px;" data-show-faces="false" data-width="500"></div>
<br />
<h2>Examples</h2>
<p>Login above and approve the example app then click the below links (the app is blank and doesn't use your data).</p>
<ul>
<li><a href="#" id="nomax">No max friend selector</a></li>
<li><a href="#" id="maxset">3 max friend selector</a></li>
</ul>
<!-- Container div for the friend selector -->
<div id="FBFriendSelector"></div>
<!-- Show the user is signed in -->
<div id="fb-user">
<h3>FB Status: Logged in!</h3>
<img src="" />
<div></div>
</div>
<br />
<div id="results">
<p>ACTIVITY LOG</p>
</div>
</body>
</html>