-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
50 lines (46 loc) · 1.55 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
<html>
<head> <title> Hello World from WASM </title> </head>
<body>
<textarea id="content-in">
</textarea>
<div id="content-out">
</div>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: center;
overflow: hidden;
}
textarea {
width: 50vw;
height: 100vh;
}
div {
width: 50vw;
height: 100vh;
}
textarea, div {
overflow-y: scroll;
}
</style>
<script src="./a.out.js"> </script>
<script>
Module.onRuntimeInitialized = _ => {
document.getElementById("content-in").oninput = function() {
// let result = Module.ccall("eat_and_poop", "string", ["string"], [`${e.target.value}`]);
const str_ptr = allocateUTF8(this.value);
const result = UTF8ToString(_eat_and_poop(str_ptr));
console.log(result);
document.getElementById("content-out").innerHTML = result;
_free(str_ptr);
}
}
</script>
</body>
</html>