-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
149 lines (134 loc) · 5.85 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
<!DOCTYPE html>
<html>
<head>
<title>PhoneGap Test</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/jqm.css" rel="stylesheet">
<link href="css/jqmtheme.css" rel="stylesheet">
<style type="text/css">
#gmap
{
margin: auto;
height: 200px;
width: 80%;
}
</style>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header" data-position="fixed">
<h3>Bismillah</h3>
</div>
<div id="dvcon">
<div id="gmap"></div>
<button id="btnmap">Show Me on a Map!</button>
<hr>
<h3>Facebook Stuff</h3>
<div id="fbstat"></div>
<button id="btnfb" onClick="login();">Log Into Facebook</button>
<button onClick="login()">Login</button>
<button onClick="me()">Me</button>
<button onClick="getLoginStatus()">Get login</button>
<button onClick="logout()">Logout</button>
<div id="data">loading ...</div>
<div id="fb-root"></div>
<!-- cordova -->
<script type="text/javascript" src="phonegap.js"></script>
<!-- jQuery -->
<script type="text/javascript" src="js/jquery.js"></script>
<!--jQuery Mobile -->
<script type="text/javascript" src="js/jqm.js"></script>
<!-- Google Maps API -->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAAzvoouN8pYwaHlhYpSa7-EEy3sjYNwpI&sensor=false"></script>
<!-- cordova facebook plugin -->
<script type="text/javascript" src="cdv-plugin-fb-connect.js"></script>
<!-- facebook js sdk -->
<script type="text/javascript" src="facebook-js-sdk.js"></script>
<script type="text/javascript">
if ((typeof cordova == 'undefined') && (typeof Cordova == 'undefined')) alert('Cordova variable does not exist. Check that you have included cordova.js correctly');
if (typeof CDV == 'undefined') alert('CDV variable does not exist. Check that you have included cdv-plugin-fb-connect.js correctly');
if (typeof FB == 'undefined') alert('FB variable does not exist. Check that you have included the Facebook JS SDK file.');
FB.Event.subscribe('auth.login', function(response) {
alert('auth.login event');
});
FB.Event.subscribe('auth.logout', function(response) {
alert('auth.logout event');
});
FB.Event.subscribe('auth.sessionChange', function(response) {
alert('auth.sessionChange event');
});
FB.Event.subscribe('auth.statusChange', function(response) {
alert('auth.statusChange event');
});
/*function getSession() {
alert("session: " + JSON.stringify(FB.getSession()));
}
*/
function getLoginStatus() {
FB.getLoginStatus(function(response) {
if (response.status == 'connected') {
alert('logged in');
} else {
alert('not logged in');
}
});
}
var friendIDs = [];
var fdata;
function me() {
FB.api('/me/friends', { fields: 'id, name, picture' }, function(response) {
if (response.error) {
alert(JSON.stringify(response.error));
} else {
var data = document.getElementById('data');
fdata=response.data;
console.log("fdata: "+fdata);
response.data.forEach(function(item) {
var d = document.createElement('div');
d.innerHTML = "<img src="+item.picture+"/>"+item.name;
data.appendChild(d);
});
}
var friends = response.data;
console.log(friends.length);
for (var k = 0; k < friends.length && k < 200; k++) {
var friend = friends[k];
var index = 1;
friendIDs[k] = friend.id;
//friendsInfo[k] = friend;
}
console.log("friendId's: "+friendIDs);
});
}
function logout() {
FB.logout(function(response) {
alert('logged out');
});
}
function login() {
FB.login(
function(response) {
if (response.session) {
alert('logged in');
} else {
alert('not logged in');
}
},
{ scope: "email" }
);
}
document.addEventListener('deviceready', function() {
try {
alert('Device is ready! Make sure you set your app_id below this alert.');
FB.init({ appId: "497957010261019", nativeInterface: CDV.FB, useCachedDialogs: false });
document.getElementById('data').innerHTML = "";
} catch (e) {
alert(e);
}
}, false);
</script>
<div id="log"></div>
</div>
</div>
</body>
</html>