-
Notifications
You must be signed in to change notification settings - Fork 0
/
browser.html
96 lines (75 loc) · 2.22 KB
/
browser.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!doctype html>
<title>Michelson interpreter in browser</title>
<style type="text/css" media="screen">
@import url('https://fonts.googleapis.com/css?family=Cousine|Merriweather');
body {
font-family: 'Merriweather', serif;
background: linear-gradient(to right, hsl(123,50%,95%) 0%,hsl(123,40%,90%) 43%, hsl(123,30%,90%) 69%, hsl(123,20%,90%) 100%);
}
textarea {
font-family: 'Cousine', monospace;
}
input {
font-family: 'Cousine', monospace;
width: 100%;
}
table.fill {
width: 100%;
}
#code_editor {
/* position: absolute;
top: 0;
right: 30%;
bottom: 0;
left: 0; */
width: 50vw;
height: 90vh;
}
td.side {
padding-left: 10px;
}
</style>
<table><tr><td>
<div id="code_editor">parameter unit;
storage unit;
return unit;
code { DUP;
DROP }
</div>
</td><td class="side">
<p>
Storage:<br>
<textarea id="instorage" cols="50" rows="10">Unit
</textarea>
<table class="fill">
<tr><td>Input:</td><td><input id="callinput" value="Unit"></td></tr>
</table>
<p> Output:<div id=calloutput></div>
<p> New storage: <div id=outstorage></div>
</td></tr></table>
<script src="ace-builds/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="binding.js"></script>
<script>
var michelsonjs = require("michelsonjs")
var editor = ace.edit("code_editor")
editor.setTheme("ace/theme/monokai")
var session = editor.getSession()
session.setMode("ace/mode/michelson")
function update() {
var res = michelsonjs.execute({
code:editor.getValue(),
storage:document.querySelector("#instorage").value,
input:document.querySelector("#callinput").value})
console.log(res)
if (res.storage) {
document.querySelector("#outstorage").textContent = res.storage
document.querySelector("#calloutput").textContent = res.ret
session.setAnnotations([])
}
else session.setAnnotations(res)
}
setInterval(update, 1000)
</script>
<!---
<script src="_build/default/browser.bc.js"></script>
--->