forked from MrSwitch/hello.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.html
86 lines (66 loc) · 2.25 KB
/
events.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
<!DOCTYPE html>
<html>
<head>
<title>hello.js - Login Events</title>
<link rel="stylesheet" href="/adorn/adorn.css" />
<script src="/adorn/adorn.js" async></script>
<script src="client_ids.js"></script>
<script class="pre" src="../src/hello.js"></script>
<script src="../src/modules/windows.js"></script>
<script src="../src/modules/facebook.js"></script>
<script src="../src/modules/google.js"></script>
<script>
function dump_login(e){
log( "dump_login", "auth.login", e );
}
function dump_logout(e){
log( "dump_logout", "auth.logout", e );
}
function log(target, name,obj){
document.querySelector('.'+target).appendChild(document.createTextNode(name + ':' + JSON.stringify(obj,true,2)));
}
</script>
</head>
<body>
<h1>hello.js - Login Events</h1>
<p>Global events are bound via <code>hello.on(eventname, handler)</code>.</p>
<h2>auth.login</h2>
<p>Triggered per network, whenever a user logs in, or opens a page within the same origin with a valid session.</p>
<button onclick="login('google')">Login Google</button>
<button onclick="login('facebook')">Login Facebook</button>
<button onclick="login('windows')">Login Windows</button>
<script class="pre">
// Bind the login handler
hello.on( "auth.login", dump_login);
</script>
<script class="pre">
// Login button click handler
function login(network){
hello(network).login();
}
</script>
<button style="float:right;" onclick="this.nextElementSibling.innerHTML='';">Clear</button>
<pre class="dump_login"></pre>
<h2>auth.logout</h2>
<p>Triggered per network, whenever a user logs out.</p>
<button onclick="logout('google')">Logout Google</button>
<button onclick="logout('facebook')">Logout Facebook</button>
<button onclick="logout('windows')">Logout Windows</button>
<script class="pre">
// Bind the logout handler
hello.on( "auth.logout", dump_logout);
</script>
<pre class="dump_logout"></pre>
<script class="pre">
// Logout button click handler
function logout(network){
hello(network).logout();
}
</script>
<h2>Initiate</h2>
<p>Call <code>hello.init</code> last, otherwise the on-page-load events will not fire.</p>
<script class="pre">
hello.init( CLIENT_IDS, {redirect_uri:'../redirect.html'} );
</script>
</body>
</html>