-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.html
78 lines (66 loc) · 1.72 KB
/
test.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
<html>
<head>
<title>Hub Test</title>
<script src="jschannel/src/jschannel.js"></script>
</head>
<body>
<ul id="links">
<li><a href="#" id="claim_badge">Claim Badge</a></li>
<li><a href="#" id="clear_badge">Clear Badges</a></li>
</ul>
<br />
<ul id="echoarea"/>
</body>
<script src="src/hub.js"></script>
<script>
var sampleBadge = {
"schema": "https://example.com/badge/1",
"mustSupport": [],
"issuer": "https://badger.mozilla.com/",
"title": "Example Badge",
"issuerName": "Mozilla",
"imageURL": "images/badge.png",
"badgeURL": "https://badger.mozilla.com/badges/asdf1234",
"issuee": [{"type": "email", "id": "thunder@mozilla.com"},
{"type": "openid", "id": "https://id.sandmill.org/"}]
};
function echo(s) {
document.getElementById("echoarea").innerHTML += "<li>" + s + "</li>";
}
function flushMessages() {
document.getElementById("echoarea").innerHTML = "";
}
function listBadges() {
Hub.getBadges("", function(list) {
echo("badges: " + JSON.stringify(list));
});
}
function deleteBadges() {
flushMessages();
echo("deleting badges");
Hub._clear(function() {
echo("done");
listBadges();
});
}
function addTestBadge() {
flushMessages();
echo("adding test badge");
Hub.saveBadge(sampleBadge, function(success) {
if (success) {
echo("badge added/refreshed into hub");
listBadges();
} else {
echo("oops, could not add badge to hub");
}
});
}
listBadges();
document.getElementById('claim_badge').addEventListener(
'click', addTestBadge, false
);
document.getElementById('clear_badge').addEventListener(
'click', deleteBadges, false
);
</script>
</html>