-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
92 lines (78 loc) · 2.26 KB
/
index.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
87
88
89
90
91
92
<html>
<head>
<title>Toy blockchain</title>
<style>
html {
font-family: 'Ubuntu',Tahoma,sans-serif;
background-color: #fdfdfd;
color: #111;
margin-left: 50px;
}
.container {
display: flex;
flex-direction: row;
width: 100vw;
}
.box {
background-color: white;
display: flex;
flex-direction: column;
padding: 30px;
margin: 30px;
border: 2px solid black;
max-width: 500px;
border-radius: 10px;
}
input {
height: 30px;
width: 400px;
margin-bottom: 10px;
}
button {
width: 100px;
height: 40px;
}
</style>
</head>
<body style='margin: 40px'>
<div style='width: 100vw;'>
<h1 style='margin-left: 30px;'>Simplest possible blockchain demo<h1>
<h4 style='margin-left: 30px;'><a href='https://github.com/sgoedecke/blockchain-js-demo'>Source</a> | <a href='https://sgoedecke.github.io/blockchain-for-beginners/'>Explanation</a></h4>
</div>
<div class='container'>
<div class='box'>
<h2>Add to the blockchain!</h2>
<input id='newBlock' />
<button onClick='newBlock()'>Create block</button>
<br>
<h2>Encounter new chain</h2>
<input id='newChain' placeholder='Paste a serialized chain here' />
<button onClick='newChain()'>Encounter chain</button>
</div>
<div class='box'>
<h2>What's in the blockchain:</h2>
<p id='chainValues'></p>
<p id='serializedChain' style='font-family: monospace;'></p>
</div>
</div>
<script src='./blockchain.js'></script>
<script>
var client = blockChainClient()
function updateDisplay() {
document.getElementById('serializedChain').innerHTML = client.serializeChain()
document.getElementById('chainValues').innerHTML = client.read()
}
function newBlock() {
var content = document.getElementById('newBlock').value
client.write(content)
updateDisplay()
}
function newChain() {
var chain = document.getElementById('newChain').value
client.encounterNewChain(chain)
updateDisplay()
}
updateDisplay()
</script>
</body>
</html>