-
Notifications
You must be signed in to change notification settings - Fork 1
/
add.html
38 lines (31 loc) · 975 Bytes
/
add.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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>WebAssembly example</title>
<script src="add.js"></script>
<script>
function run_ws() {
var a = document.getElementById("a").value;
var b = document.getElementById("b").value;
a = Math.floor(parseFloat(a));
b = Math.floor(parseFloat(b));
ret = Module._add(a, b);
console.log(`${a} + ${b} = ${ret}`);
var r = document.getElementById("ret");
r.innerText = ret
}
</script>
</head>
<body>
<h1>WebAssembly in C</h1>
<div style="display: inline-block;">
<input id="a" type="number" />
<label>+</label>
<input id="b" type="number" />
<button id="run_button" onclick="run_ws()">=</button>
<label id="ret"></label>
</div>
</body>
</html>