-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathpassive-negotiation.html
75 lines (64 loc) · 3.17 KB
/
passive-negotiation.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<link rel="tokenscript" href="EntryToken.xml"/>
<link rel="tokenscript" href="BOOKY.xml"/>
<!-- this is for token negotiation! -->
<!-- OG: meta tag allow only "scheme,name,http-equiv,content,charset". we can use "name,content" to stay document valid-->
<!-- <meta name="token" content="entry-token"/>-->
<!-- <meta name="token.filter" content="objectClass=entrytoken"/>-->
<meta name="token.filter" content="objectClass=booky"/>
<!-- <meta name="token-expiry" content=">=2018-04-04"/>-->
<!-- if without linked TokenScript, consider a synax like this
<meta tokens-accepted="ethereum:1/0x63cCEF733a093E5Bd773b41C96D3eCE361464942/"/>
-->
<title>Showing the cards in a web page</title>
<link rel="stylesheet" href="ts.css">
<script type="text/javascript" src="inc/web3.min.js"></script>
<script type="text/javascript" src="inc/ethers-5.0.umd.min.js"></script>
<script type="module" src="tokenscript-bootstrap.js" ></script>
<script type="text/javascript">
// the following event is triggered every time when a token is negotiated
// and that is why an event listener is used in place of a promise;
// the event will be triggered if the user clicks one of the tokens that fits the negotiation criteria
// in the TokenBar.
// OG: parse XML, load external files etc (but dont parse token-specific data) + code blocked until all files fetched completely
window.addEventListener("ontokennegotiation", async (e) => {
console.log('ontokennegotiation fired. token name received: ' + e.detail);
// might be renderIn, need to find a comfortable method for seasoned React JS user
// OG: parse token-specific data, render iframe content
// tokenCard.render(document.getElementById("card_container")).then(()=>{
// console.log('render done');
// });
// alternatively, tokenCard.renderAsItem(…)
document.getElementById("enter_button").onclick = (event) => {
console.log('click fired');
/*
token.enterAction().then(e=>{
}
// … code to handle the result of enter action.
)
*/
};
document.getElementById("render_events").onclick = (event) => {
console.log('render_events fired');
let tokenNode = document.querySelector('.ts_token_bar .ts_token_wrap');
if (!tokenNode) {
console.log('No token in the list');
return;
}
let token = tokenNode.tokenInstance;
token.renderEventCards().then(console.log).catch(console.log);
};
});
</script>
</head>
<body>
<h1>Demonstration of showing a card in a web page</h1>
<h2>Token Card will be in the top right corner of the screen</h2>
<!--<div id="card_container"></div>-->
<p><button id="enter_button">Enter (not implemented yet)</button></p>
<p><button id="render_events">Event values to console</button></p>
</body>
</html>