-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
110 lines (72 loc) · 2.57 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
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="./src/facebox.js"></script>
<link rel="stylesheet" type="text/css" href="./src/facebox.css"/>
</head>
<body>
<div id="fb-root"></div>
<script>
$(document).ready(function() {
$.facebox.settings.closeImage = 'src/closelabel.png';
$.facebox.settings.loadingImage = 'src/loading.gif';
window.fbAsyncInit = function() {
FB.init({
appId : '180811402007050',
status : true,
cookie : true,
xfbml : true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
$("a#logoutlink").css("display", "inline");
var user_id;
FB.api("/me", function(response) {
user_id = response["id"];
$('div#loginstatus').text("You are logged in. Your user id is " + user_id);
$.get("/fbtestget?user_id=" + user_id, function(data) {
console.log('getting data from web service (if exists)');
if(data == "userdne") {
FB.api("/me/photos", function(response) {
console.log("photos received (from fb api call)");
var photos = response["data"];
for(var i = 0; i < photos.length; i++) {
photos[i] = photos[i]["source"];
}
$.post("/fbtestpage?user_id=" + user_id + "&img_urls=" + JSON.stringify(photos), function(data, status) {console.log("POST images");});
show_images(photos);
});
}
else show_images(JSON.parse(data));
$('a[rel*=facebox]').facebox();
});
});
}
});
};
(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/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
});
function show_images(images) {
for(var i = 0; i < images.length; i++) {
var img_url = images[i];
$('div#images').append("<div><a href='" + img_url + "' rel='facebox'><div style='width:200px; height:200px; background-size:cover; background-repeat:no-repeat; float:left; background-image:url(" + img_url + ");'></div></a></div>");
}
}
function logout() {
FB.logout(function(response){window.location.reload();});
}
</script>
<div id="loginstatus"></div>
<fb:login-button show-faces="true" width="200" max-rows="1" scope="user_photos"></fb:login-button>
<br/>
<a href="javascript:logout();" id="logoutlink" style="display:none;">Click Me to log out</a>
<div id="images">
</div>
</body>
</html>