Skip to content

Commit 4632dbe

Browse files
committed
Merge scope change scope_map, popup dictionary support and tidy demos
1 parent ad55ab0 commit 4632dbe

23 files changed

+368
-186
lines changed

demos/albums.html

+3-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ <h2>Demo</h2>
5757

5858
<b class="column">Provider</b>
5959
<b class="column">Albums</b>
60-
<b class="column">Photos</b>
60+
<b class="column">Photos</b>
6161
<br />
6262
<div class="column">
6363
<button id="windows" onclick="getAlbums('windows')">Get Albums from Windows</button>
@@ -84,10 +84,7 @@ <h2>Source</h2>
8484
hello.on('auth.login', function(auth){
8585

8686
// Get Profile
87-
hello.api(auth.network+':me', function(r){
88-
if(!r||r.error){
89-
return;
90-
}
87+
hello(auth.network).api('me').then(function(r) {
9188
document.getElementById(auth.network).innerHTML = "Get Albums from " + r.name + " at "+auth.network+"";
9289
});
9390
});
@@ -102,7 +99,7 @@ <h3>Initiate HelloJS</h3>
10299
// Initiate hellojs
103100
hello.init( CLIENT_IDS, {
104101
scope: "files, photos",
105-
redirect_uri : "../redirect.html"
102+
redirect_uri: "../redirect.html"
106103
});
107104
</script>
108105

demos/amazon.html

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
3+
<link rel="stylesheet" href="/adorn/adorn.css"/>
4+
<link rel="stylesheet" href="./helper/alert.css"/>
5+
<script src="/adorn/adorn.js" async></script>
6+
7+
<script src="client_ids.js"></script>
8+
<script src="../src/hello.polyfill.js"></script>
9+
<script src="../src/hello.js"></script>
10+
<script src="../src/modules/amazon.js"></script>
11+
12+
<title>hello( amazon )</title>
13+
<h1>hello( amazon )</h1>
14+
15+
<script src="./helper/alert-https.js"></script>
16+
17+
<blockquote>
18+
<a href="https://login.amazon.com/documentation">Amazon Documentation</a>
19+
<a href="https://sellercentral.amazon.com/gp/homepage.html">Register App</a>
20+
</blockquote>
21+
22+
<button id='amazon' onclick="login('amazon');">amazon</button>
23+
<pre id="result">Signin to connect with Amazon</pre>
24+
<script class="pre">
25+
function login(network){
26+
27+
var amazon = hello(network);
28+
29+
amazon.login()
30+
.then( function(){
31+
// get user profile data
32+
return amazon.api( '/me' );
33+
})
34+
.then( function(p){
35+
document.getElementById( network ).innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ network +" as " + p.name;
36+
})
37+
.then(
38+
null,
39+
console.error.bind(console)
40+
);
41+
42+
}
43+
</script>
44+
45+
<script class="pre">
46+
hello.init({
47+
// Register app https://sellercentral.amazon.com/gp/homepage.html
48+
amazon : 'amzn1.application-oa2-client.5ac60070ee744ae7a241e10e48eae7ff'
49+
},{
50+
redirect_uri : '../redirect.html'
51+
});
52+
</script>

demos/dropbox.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ <h1>hello( dropbox )</h1>
2828

2929
dropbox.login().then(function() {
3030

31-
dropbox.api("me", function(p) {
31+
dropbox.api("me").then(function(p) {
3232
document.getElementById('profile').innerHTML = "Connected to dropbox as " + p.name;
3333
});
3434

@@ -40,7 +40,7 @@ <h1>hello( dropbox )</h1>
4040
</script>
4141
<script class="pre">
4242
hello.init({
43-
'dropbox' : DROPBOX_CLIENT_ID,
43+
'dropbox' : DROPBOX_CLIENT_ID,
4444
},
4545
{
4646
redirect_uri:'../redirect.html',
@@ -50,4 +50,4 @@ <h1>hello( dropbox )</h1>
5050
// And then sign subsequent requests
5151
oauth_proxy : OAUTH_PROXY_URL
5252
});
53-
</script>
53+
</script>

demos/flickr.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h1>hello( flickr )</h1>
1616

1717
hello.on('auth.login', function(r){
1818
// Get Profile
19-
hello(r.network).api('/me', function(p){
19+
hello(r.network).api('me').then(function(p) {
2020
document.getElementById('login').innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ r.network+" as " + p.name;
2121
});
2222
});
@@ -29,4 +29,4 @@ <h1>hello( flickr )</h1>
2929
oauth_proxy: OAUTH_PROXY_URL
3030
});
3131

32-
</script>
32+
</script>

demos/foursquare.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ <h1>hello( foursquare )</h1>
1616
hello.on('auth.login', function(r){
1717
// Get Profile
1818
console.log("auth.login");
19-
hello.api(r.network+':/me', function(p){
19+
hello(r.network).api('me').then(function(p) {
2020
document.getElementById(r.network).innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ r.network+" as " + p.name;
2121
});
2222
});
2323

2424
hello.init({
2525
foursquare : FOURSQUARE_CLIENT_ID
2626
}, {redirect_uri:'../redirect.html'});
27-
</script>
27+
</script>

demos/friends.html

+10-9
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ <h2>Initiate</h2>
4141
yahoo : CLIENT_IDS_ALL.yahoo
4242
}
4343
, {
44-
redirect_uri:'../redirect.html',
45-
oauth_proxy : OAUTH_PROXY_URL,
44+
redirect_uri:'../redirect.html',
45+
oauth_proxy : OAUTH_PROXY_URL,
4646
scope:"friends"
4747
}
4848
);
@@ -58,14 +58,10 @@ <h2>Build Button events</h2>
5858
btn_more.style.display = 'none';
5959

6060
// login
61-
hello.login( network, {scope:'friends'}, function(auth){
62-
if(!auth||auth.error){
63-
console.log("Signin aborted");
64-
return;
65-
}
61+
hello(network).login({scope:'friends'}).then(function(auth) {
6662
// Get the friends
6763
// using path, me/friends or me/contacts
68-
hello( network ).api( path , {limit:10}, function responseHandler(r){
64+
hello(network).api(path, {limit:10}).then(function responseHandler(r) {
6965
for(var i=0;i<r.data.length;i++){
7066
var o = r.data[i];
7167
var li = document.createElement('li');
@@ -80,9 +76,14 @@ <h2>Build Button events</h2>
8076
btn_more.innerHTML = "Next from "+network;
8177
btn_more.style.display = 'block';
8278
});
79+
}, function() {
80+
if(!auth||auth.error){
81+
console.log("Signin aborted");
82+
return;
83+
}
8384
});
8485
}
8586
</script>
8687

8788
</body>
88-
</html>
89+
</html>

demos/google.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ <h1>hello( google )</h1>
2020
// By defining response type to code, the OAuth flow that will return a refresh token to be used to refresh the access token
2121
// However this will require the oauth_proxy server
2222

23-
hello(network).login( { response_type:'code' }, log );
23+
hello(network).login({response_type: 'code'}, log);
2424
}
2525
</script>
2626

@@ -30,13 +30,13 @@ <h1>hello( google )</h1>
3030
hello.init({
3131
google : GOOGLE_CLIENT_ID
3232
},{
33-
redirect_uri:'../redirect.html',
34-
scope : 'friends'
33+
redirect_uri: '../redirect.html',
34+
scope: 'friends'
3535
});
3636
</script>
3737

3838
<script>
3939
function log(s){
4040
document.body.querySelector('.response').appendChild(document.createTextNode(JSON.stringify(s, true, 2)));
4141
}
42-
</script>
42+
</script>

demos/google_upload.html

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ <h1>hello.js to Google Drive</h1>
3838
<script class="pre">
3939
function upload(network){
4040

41-
hello(network).login(function(){
41+
var google = hello("google");
42+
google.login().then(function() {
4243

43-
hello("google").api('me/files', 'post', {
44+
google.api('me/files', 'post', {
4445
file : document.getElementById('file')
45-
}).complete(function(response){
46+
}).then(function(response) {
4647
log(response);
4748
});
4849

@@ -55,4 +56,4 @@ <h1>hello.js to Google Drive</h1>
5556
function log(s){
5657
document.body.querySelector('.response').appendChild(document.createTextNode(JSON.stringify(s, true, 2)));
5758
}
58-
</script>
59+
</script>

0 commit comments

Comments
 (0)