-
Notifications
You must be signed in to change notification settings - Fork 10
/
index.html
233 lines (199 loc) · 9.02 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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>svahne/browserl @ GitHub</title>
<style type="text/css">
body {
margin-top: 1.0em;
background-color: #ffffff;
font-family: Helvetica, Arial, FreeSans, san-serif;
color: #000000;
}
#container {
margin: 0 auto;
width: 700px;
}
h1 { font-size: 3.8em; color: #000000; margin-bottom: 3px; }
h1 .small { font-size: 0.4em; }
h1 a { text-decoration: none }
h2 { font-size: 1.5em; color: #000000; }
h3 { text-align: center; color: #000000; }
a { color: #000000; }
.description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;}
.download { float: right; }
pre { background: #000; color: #fff; padding: 15px;}
hr { border: 0; width: 80%; border-bottom: 1px solid #aaa}
.footer { text-align:center; padding-top:30px; font-style: italic; }
</style>
<!--[if IE]>
<script type="text/vbscript" src="vbarray.vbscript"></script>
<![endif]-->
<script type="text/javascript" src="sockjs/sockjs-0.2.min.js"></script>
<script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="term/term.js"></script>
<script type="text/javascript" src="hapint/hapint.es"></script>
<script type="text/javascript" src="zlib/zlib.js"></script>
<script type="text/javascript" src="browserl.js"></script>
<style type="text/css">
.term
{
font-family: Courier New, Courier;
background-color: White;
color: black;
display:block;
float:left;
border: solid 1px #000000;
padding: 2px;
margin: 10px;
}
</style>
</head>
<body>
<a href="https://github.com/svahne/browserl"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a>
<div id="container">
<div class="download">
<a href="https://github.com/svahne/browserl/zipball/master">
<img border="0" width="90" src="https://github.com/images/modules/download/zip.png"></a>
<a href="https://github.com/svahne/browserl/tarball/master">
<img border="0" width="90" src="https://github.com/images/modules/download/tar.png"></a>
</div>
<h1><a href="https://github.com/svahne/browserl">browserl</a>
<span class="small">by <a href="https://github.com/svahne">svahne</a></span></h1>
<div class="description">
An Erlang Emulator written in javascript
</div>
<div id="terminal" class="term"></div><br>
<div id="statusconsole"></div>
<br clear="all">
<h2>How to set up and start</h2>
<p id="first">
1. Clone or download source code to a local directory:
<pre>git clone git://github.com/svahne/browserl
cd browserl
</pre>
2. Start a web server of your choice
<p>For instance, with inets you would start Erlang in the browserl base directory
and then at the Erlang shell prompt do:
<pre>inets:start(), inets:start(httpd, [{port, 3333}, {server_name,""},
{server_root,"."}, {document_root,"."}]).</pre>
You would typically want to be behind a firewall if you do this.
<p>3. Open 127.0.0.1:3333/index.html in your browser.
<p>Optionally:
<p>4. Add your own beam files.
<p>You can either add your files to beams/beamfiles.tar, e.g:
<pre>tar --append --file beams/beamfiles.tar myfile.beam</pre>
or you could add them to the list of arguments given to the run() function
(in this example the run() function is called from index.html).
<pre>run(mod, fun, args, ['start.boot', 'beamfiles.tar', 'mybeam']); </pre>
<p> run() takes as its' arguments the initial module, function and arguments and a
list of beamfiles (without the .beam extension!) or tarballs containing
beamfiles. The initial module, function
and arguments can point directly to your own module which might typically be
what you want for simple programs with limited dependencies towards the
Erlang/OTP libraries. If you point to your own initial function you should
be prepared for that e.g. io:format() will not work since it requires some
basic io servers to be started which is normally done during the boot. BIF
calls like js:eval/1, js:call/3, etc will always work.
<h2>Dependencies</h2>
<p>Known to boot in:
Chrome 3-8, 11-16 (fastest, loads to shell prompt in
less than a second when hosted on same network),
Firefox 3.0, 3.5, 3.6, 4, 5, 6, 7, 8,
Internet Explorer 8, 9,
Safari 4.0, 5.0.5, 5.1,
Opera 11, 11.5, 11.6,
Epiphany 3.2,
Konqueror 4.7,
iPhone 4,
HTC Wildfire running Android 2.2.
Currently, the Erlang/OTP system will boot, but the terminal
javascript will not accept user input in IE and the mobile
browsers.
</p>
<p>Only limited support for binaries and ets tables have been
added so far. Floats will not always work, especially not the
presentation in the shell due to a dependency on binaries. In the
example above math.beam is missing so no floats.</p>
<p>Only the most commonly used bifs have been implemented, and
arguments are not always checked. Files
and networking is not supported or expected to work, although some
initial hacks have been made in order to get the test server
running.</p>
<p>Is able to start Common test and the test server, and passes
the standard OTP tests suites for lists, arrays,
dicts, random numbers and queues.</p>
<h2>Accessing javascript objects and the DOM</h2>
<p>The following functions are likely to change, and only shown here as a proof of concept.
<p><b>js:eval(String) -> true</b>
<p><DD>String = string()</DD>
<p><b>Example:</b>
<pre>js:eval("document.getElementById('first').innerHTML = 'some text'").</pre>
<p><b>js:call(JsObject, Function, Arguments) -> js_object()
<br>js:get(JsObject, Property) -> js_object()
<br>js:set(JsObject, Property, Value) -> true</b>
<p><DD>JsObject = window | document | js_object()
<DD> Function = atom()
<DD>Property = atom()
<DD>Arguments = [ atom() ]
<DD>Value = atom() | string() | js_object()</DD>
<p><b>Examples:</b>
<pre>Doc = js:get(window, document).
MyElem = js:call(Doc, getElementById, [first]).
MyElem = js:call(document, getElementById, [first]).
OldContents = js:get(MyElem, innerHTML).
js:set(MyElem, innerHTML, "some text").
js:set(MyElem, innerHTML, OldContents).</pre>
<h2>License</h2>
<p>Dual licensed under the MIT and GPL v3 licenses.</p>
<h2>Authors</h2>
<p>Fredrik Svahn (fredrik.svahn@gmail.com)
<br/> </p>
<h2>Contact</h2>
<p>Fredrik Svahn (fredrik.svahn@gmail.com)
<br/> </p>
<h2>Download</h2>
<p>
You can download this project in either
<a href="https://github.com/svahne/browserl/zipball/master">zip</a> or
<a href="https://github.com/svahne/browserl/tarball/master">tar formats.
</p>
<p>You can also clone the project with <a href="http://git-scm.com">Git</a> by running:
<pre>$ git clone git://github.com/svahne/browserl</pre>
</p>
<div class="footer">
get the source code on GitHub : <a href="https://github.com/svahne/browserl">svahne/browserl</a>
</div>
</div>
<script type="text/javascript">
try {
var term = new Terminal('terminal');
var mod = 'otp_ring0';
var fun = 'start';
var random = Math.round(Math.random()*1000000);
var args = arrayToList([0, arrayToList(['-root', '/otp_src_R14B04',
'-progname', 'erl',
'-async_shell_start',
'-mode', 'minimal', '--',
'-home', '/tmp', '--'])]);
var args_distr = arrayToList([0,
arrayToList(['-root', '/otp_src_R14B04',
'-progname', 'erl',
'-async_shell_start',
'-sname', 'browser'+random+'@somehost',
'-no_epmd',
'-proto_dist', 'browserl',
'--',
'-home', '/tmp', '--'])]);
//Uncomment the following line to call your own function test:start().
// run('test', 'start', arrayToList([]), ['start.boot', 'beamfiles.tar', 'test.beam']);
//Uncomment following line to test the distributed version
// run(mod, fun, args_distr, ['start.boot', 'beamfiles.tar']);
//Uncomment following line to run a non-distributed system
run(mod, fun, args, ['start.boot', 'beamfiles.tar']);
} catch (e) {
document.getElementById("statusconsole").innerHTML = e.toString();
}
</script>
</body>
</html>