-
Notifications
You must be signed in to change notification settings - Fork 9
/
client.js
47 lines (43 loc) · 1.32 KB
/
client.js
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
function boot(conf) {
function safeReload() {
if (window !== top) {
top.location = conf.canvasURL + window.location.pathname.substr(1)
} else {
window.location.reload()
}
}
// This is copy pasted from:
// https://developers.facebook.com/docs/reference/javascript/
window.fbAsyncInit = function() {
if (conf.reloadOnLogin) FB.Event.subscribe('auth.login', safeReload)
if (conf.reloadOnLogout) FB.Event.subscribe('auth.logout', safeReload)
FB.init({
appId: String(conf.appId),
status: true,
cookie: true,
xfbml: true
})
var disconnectBtn = document.getElementById('sample-disconnect')
if (disconnectBtn) {
disconnectBtn.onclick = function() {
FB.api({ method: 'auth.revokeauthorization' }, safeReload)
}
}
var logoutBtn = document.getElementById('sample-logout')
if (logoutBtn) {
logoutBtn.onclick = function() {
FB.logout()
}
}
}
// Load the Facebook JS SDK
window.setTimeout(function() {
(function(d) {
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = '//connect.facebook.net/en_US/all.js';
ref.parentNode.insertBefore(js, ref);
}(document));
}, 0)
}