forked from MrSwitch/hello.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
friends.html
85 lines (73 loc) · 2.51 KB
/
friends.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
<!DOCTYPE html>
<html>
<head>
<title>hello.js - Javascript API for OAuth2 authentication and REST services</title>
<link rel="stylesheet" href="/_packages/document.css" />
<script src="/_packages/document.js"></script>
<script src="client_ids.js"></script>
<style>ul:empty:after{content:'empty';font-weight:bold;color:#aaa;}</style>
</head>
<body>
<h1>hello.js - me/friends</h1>
<button onclick="getFriends('google', 'me/friends')">Get Google me/friends</button>
<button onclick="getFriends('facebook', 'me/friends')">Get Facebook me/friends</button>
<button onclick="getFriends('windows', 'me/friends')">Get Windows me/friends</button>
<button onclick="getFriends('yahoo', 'me/friends')">Get Yahoo me/friends</button>
<button onclick="getFriends('google', 'me/contacts')">Get Google me/contacts</button>
<button onclick="getFriends('windows', 'me/contacts')">Get Windows me/contacs</button>
<h2>Friends list</h2>
<ul id="list"></ul>
<button id="more" style="display:none;"></button>
<h2>Include hello.js and the modules</h2>
<p>One should merge these for performance.</p>
<script class="pre" src="../src/hello.js"></script>
<script class="pre" src="../src/modules/windows.js"></script>
<script class="pre" src="../src/modules/facebook.js"></script>
<script class="pre" src="../src/modules/google.js"></script>
<script class="pre" src="../src/modules/yahoo.js"></script>
<h2>Initiate</h2>
<script class="pre">
hello.init( {
windows : CLIENT_IDS_ALL.windows,
google : CLIENT_IDS_ALL.google,
facebook : CLIENT_IDS_ALL.facebook,
yahoo : CLIENT_IDS_ALL.yahoo
}
, {
redirect_uri:'../redirect.html',
oauth_proxy : OAUTH_PROXY_URL,
scope:"friends"
}
);
</script>
<h2>Build Button events</h2>
<script class="pre">
function getFriends(network, path){
var list = document.getElementById('list');
list.innerHTML = '';
var btn_more = document.getElementById('more');
btn_more.style.display = 'none';
// login
hello.login( network, {scope:'friends'}, function(auth){
if(!auth||auth.error){
console.log("Signin aborted");
return;
}
// Get the friends
// using path, me/friends or me/contacts
hello( network ).api( path , {limit:10}, function(r, next){
for(var i=0;i<r.data.length;i++){
var o = r.data[i];
var li = document.createElement('li');
li.innerHTML = o.name + (o.thumbnail?" <img src="+o.thumbnail+" />":'');
list.appendChild(li);
};
btn_more.onclick = next;
btn_more.innerHTML = "Next from "+network;
btn_more.style.display = 'block';
});
});
}
</script>
</body>
</html>