annotate example/persona.html @ 47:f2474ffcee96

avoid namespace collisions; buckle your safety-belt
author Jeff Hammel <jhammel@mozilla.com>
date Mon, 30 Dec 2013 10:12:25 -0800
parents 54a53bbe5be9
children d66d6c10cfe4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 <html>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 <head>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 <title>bistyauth Mozilla persona test page</title>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 <!-- Suppressing Compatability Mode for IE
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 https://developer.mozilla.org/en-US/Persona/Quick_Setup?redirectlocale=en-US&redirectslug=Persona%2FQuick_Setup#Suppressing_Compatibility_Mode -->
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 <meta http-equiv="X-UA-Compatible" content="IE=Edge">
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
32
f462dc131d57 example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 30
diff changeset
10 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 <script src="https://login.persona.org/include.js"></script>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 <script>
40
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
13 var nclicks = 0;
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
14
33
67439bcdac48 example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
15 $(document).ready(function() {
28
0f57029d663d example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
16
30
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
17 var currentUser = null;
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
18
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
19 navigator.id.watch({
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
20 loggedInUser: currentUser,
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
21 onlogin: function(assertion) {
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
22 // A user has logged in! Here you need to:
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
23 // 1. Send the assertion to your backend for verification and to create a session.
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
24 // 2. Update your UI.
45
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
25 $.ajax({type: 'POST',
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
26 url: '/auth/login', // This is a URL on your website.
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
27 data: {assertion: assertion},
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
28 success: function(res, status, xhr) { window.location.reload(); },
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
29 error: function(xhr, status, err) {
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
30 navigator.id.logout();
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
31 alert("Login failure: " + err);
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
32 }
30
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
33 });
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
34 },
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
35 onlogout: function() {
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
36 // A user has logged out! Here you need to:
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
37 // Tear down the user's session by redirecting the user or making a call to your backend.
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
38 // Also, make sure loggedInUser will get set to null on the next page load.
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
39 // (That's a literal JavaScript null. Not false, 0, or undefined. null.)
45
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
40 // $.ajax({
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
41 // type: 'POST',
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
42 // url: '/auth/logout', // This is a URL on your website.
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
43 // success: function(res, status, xhr) { window.location.reload(); },
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
44 // error: function(xhr, status, err) { alert("Logout failure: " + err); }
54a53bbe5be9 bitsyauth/__init__.py example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 41
diff changeset
45 // });
30
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
46 }
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
47 });
28
0f57029d663d example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 23
diff changeset
48
41
d4522af2c6e5 refactor
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
49
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
50 var signinLink = document.getElementById('signin');
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
51 if (signinLink) {
41
d4522af2c6e5 refactor
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
52 signinLink.onclick = function() {
d4522af2c6e5 refactor
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
53 navigator.id.request();
40
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
54 nclicks += 1;
41
d4522af2c6e5 refactor
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
55 $('#clickcounter').append('<li>This is click ' + nclicks + '</li>');
40
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
56 };
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
57 }
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
58
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
59 var signoutLink = document.getElementById('signout');
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
60 if (signoutLink) {
37
6b5946843928 example/persona.html example/wsgibrowserid.py
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
61 signoutLink.onclick = function() { navigator.id.logout(); };
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
62 }
33
67439bcdac48 example/persona.html
Jeff Hammel <jhammel@mozilla.com>
parents: 32
diff changeset
63 });
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
64 </script>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
65 </head>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
66
30
0bf52646061b example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents: 29
diff changeset
67 <body>
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
68 <h1>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
69 <a href="https://login.persona.org/">Mozilla persona</a>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
70 <a href="http://k0s.org/hg/bitsyauth/">bitsyauth</a>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
71 test page
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
72 </h1>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
73
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
74 <div>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
75 <a id="signin">sign in</a>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
76 </div>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
77
40
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
78 <ul id="clickcounter">
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
79 </ul>
cb1d21648588 count clicks the hard way
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
80
23
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
81 <h2>Resources</h2>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
82 <ul>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
83 <li>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
84 <a href="https://developer.mozilla.org/en-US/Persona/branding">
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
85 branding
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
86 </a>:
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
87 buttons and what not
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
88 </li>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
89 </ul>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
90
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
91 </body>
21124b238feb stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
92 </html>