-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (28 loc) · 889 Bytes
/
Copy pathindex.js
File metadata and controls
36 lines (28 loc) · 889 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
import * as wasm from "wasm-fa";
var input = document.getElementById('myInput');
input.addEventListener('input', function () {
this.value = this.value.replace(/[^01*()+]/g, '');
});
input.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
handleClick();
}
});
let button = document.querySelector("button");
button.addEventListener("click", () => {
handleClick();
});
function handleClick() {
var input = document.getElementById('myInput');
var value = input.value;
value = value.replace(/\+/g, '\|');
var result = wasm.get_ans(value);
let [ans, rg, dot] = result.split('@');
var output = document.getElementById('output');
var outputrg = document.getElementById('rg');
output.textContent = ans;
outputrg.textContent = rg;
d3.select("#graph").graphviz()
.renderDot(dot);
console.log(result);
}