-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtry-js2rho.html
46 lines (40 loc) · 1.2 KB
/
try-js2rho.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
<!doctype html>
<html>
<head>
<title>Try js2rho</title>
</head>
<body>
<h1>Try js2rho</h1>
<form id="js2rho">
<textarea rows="30" cols="50" name="js"></textarea>
<textarea rows="30" cols="50" name="rho" readonly="true" float="right"></textarea>
<br />
<button type="button">translate</button>
</form>
</body>
<hr />
<address>
<a href="https://www.madmode.com/">Dan Connolly</a>
</address>
<script src="https://unpkg.com/esprima@~4.0/dist/esprima.js"></script>
<script type="module">
import { js2rho } from './lib/js2rho.js';
console.log('hi');
const harden = Object.freeze;
function translate(inputField, outputField) {
console.log('click!');
const jsCode = inputField.value;
const buf = [];
const wr = harden({
write(txt) {
buf.push(txt);
},
});
js2rho(jsCode, wr);
outputField.value = buf.join('');
}
const ui = document.querySelector('#js2rho');
const [inF, outF] = [ui.querySelector('*[name="js"]'), ui.querySelector('*[name="rho"]')];
ui.querySelector('button').addEventListener('click', () => translate(inF, outF));
</script>
</html>