This repository has been archived by the owner on May 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (63 loc) · 1.63 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
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>MLScala</title>
<script src="./js/target/scala-2.12/mlscala-fastopt.js"></script>
<style>
* {
font-size: 100%;
font: inherit;
}
body {
margin: 10px auto 0;
width: 90%;
font-size: 200%;
font-family: monospace;
}
div#container {
position: absolute;
top: 50px;
bottom: 40%;
width: 90%;
}
textarea#code {
display: block;
width: 100%;
margin: 0 auto;
padding: 5px;
height: 100%;
}
input#run {
margin-left: 10px;
border-radius: 5px;
height: 30px;
border: 1px solid #375EAB;
font-size: 16px;
background: #375EAB;
color: white;
top: 1px;
}
</style>
</head>
<body>
<div id="header">min-ML interpreter<input type="button" value="Run" id="run"></div>
<div id="container">
<textarea id="code">let rec fact = fun x -> if x < 1 then 1 else x * fact(x - 1);;
print (fact 6);;</textarea>
<div id="output"></div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function() {
const textArea = document.querySelector('#code');
const output = document.querySelector('#output');
const run = document.querySelector('#run');
run.addEventListener('click', function() {
const code = textArea.value;
const result = ML.interpret(code.replace(/(\r?\n|\r\n?)/g, ''));
output.innerText = result;
});
});
</script>
</body>
</html>