forked from squint-cljs/squint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
53 lines (51 loc) · 1.76 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
51
52
53
<!DOCTYPE html>
<html>
<head>
<title>Clava</title>
<meta content="width=device-width, initial-scale=1" name="viewport">
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.9/dist/es-module-shims.js"></script>
<script type="importmap">
{
"imports": {
"clavascript": "https://cdn.jsdelivr.net/npm/clavascript@0.0.0-alpha.38/index.js",
"clavascript/core.js": "https://cdn.jsdelivr.net/npm/clavascript@0.0.0-alpha.38/core.js",
"clavascript/string.js": "https://cdn.jsdelivr.net/npm/clavascript@0.0.0-alpha.38/string.js"
}
}
</script>
<script type="module">
import { compileString } from 'clavascript'
var counter = 0;
window.compile = () => {
counter = counter + 1;
let code = document.querySelector('#cljsCode').value;
let js = compileString(code);
document.querySelector('#compiledCode').innerText = js;
const encodedJs = encodeURIComponent(js);
const dataUri = 'data:text/javascript;charset=utf-8;eval=' + counter + ',' + encodedJs;
import(dataUri);
}
console.log('done')
</script>
</head>
<body>
<div style="float: right;">
<a href="https://github.com/clavascript/clava"><img src="https://img.shields.io/github/stars/clavascript/clava.svg?style=social&label=Star"></a></div>
<div>
<textarea rows="6" cols="80" id="cljsCode">(def x {:a 1})
(assoc! x :b 2)
(js/alert (pr-str x))
</textarea>
</div>
<div>
<button onClick="compile()">
Compile!
</button>
</div>
<div>
<pre><code id="compiledCode"></code></pre>
</div>
</body>
</html>