-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
48 lines (27 loc) · 982 Bytes
/
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
<textarea id="output_area" style="width:100%; height:50%"></textarea>
<!-- Button for triggering c++ multiply method -->
<button onclick="multiplyInCpp(event.clientX,event.clientY)" style="width:100%; height:50%">Show Result</button>
<script>
function output(text) {
document.getElementById("output_area").append(text + "\n\n");
}
var Module = {
'print': function (text) {
output("print\n" + text);
},
'printErr': function (text) {
output("printErr\n" + text);
},
};
async function multiplyInCpp(x, y) {
// invoke multiply method from cpp only after initialization of Module
ReadyToLoad().then((Module) => {
output(Module.ccall('multiply', // name of C++ function
'number', // return type
['number','number'], // argument types
[x, y])); // arguments
});
}
</script>
<script src="multiply.js"></script>
<script src="multiply_in.js"></script>