-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample2.html
More file actions
62 lines (33 loc) · 1019 Bytes
/
example2.html
File metadata and controls
62 lines (33 loc) · 1019 Bytes
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
<pre>
POT JS Example 2: Interactive, Verbosity, Path, Integrity
key <input id=key>
value <input id=value>
<button onclick="put()"> put </button>
<hr />
key <input id=search>
<button onclick="get()"> get </button>
value <input id=result>
<img src=favicon.ico>
</pre>
<script src="lib/pot-web.js" wasm="lib/pot.wasm" verbosity="3" integrity="sha384-U0jsr4Xjbd2QmJG7E7C6KDVLIYRHzJ8+sl1dgBb82ohr9sA6tJzhkxyZWfMHRBvV"></script>
<script>
var kvs
(async () => {
await pot.ready()
kvs = new pot.Kvs()
})()
// There is no catching of early calls of put() and get()
// in this example, which in theory could race the loading
// of pot.wasm and the creation of kvs.
const field = (id) => { return document.getElementById(id) }
async function put() {
key = field('key').value
value = field('value').value
await kvs.put(key, value)
}
async function get() {
key = field('search').value
value = await kvs.get(key)
field('result').value = value
}
</script>