82 | 1. Clone or download source code to a local directory: 83 |
git clone git://github.com/svahne/browserl 84 | cd browserl 85 |86 | 2. Start a web server of your choice 87 |
For instance, with inets you would start Erlang in the browserl base directory 88 | and then at the Erlang shell prompt do: 89 |
inets:start(), inets:start(httpd, [{port, 3333}, {server_name,""}, 90 | {server_root,"."}, {document_root,"."}]).91 | You would typically want to be behind a firewall if you do this. 92 |
3. Open 127.0.0.1:3333/index.html in your browser. 93 |
Optionally: 94 |
4. Add your own beam files. 95 |
You can either add your files to beams/beamfiles.tar, e.g: 96 |
tar --append --file beams/beamfiles.tar myfile.beam97 | or you could add them to the list of arguments given to the run() function 98 | (in this example the run() function is called from index.html). 99 |
run(mod, fun, args, ['start.boot', 'beamfiles.tar', 'mybeam']);100 |
run() takes as its' arguments the initial module, function and arguments and a 101 | list of beamfiles (without the .beam extension!) or tarballs containing 102 | beamfiles. The initial module, function 103 | and arguments can point directly to your own module which might typically be 104 | what you want for simple programs with limited dependencies towards the 105 | Erlang/OTP libraries. If you point to your own initial function you should 106 | be prepared for that e.g. io:format() will not work since it requires some 107 | basic io servers to be started which is normally done during the boot. BIF 108 | calls like js:eval/1, js:call/3, etc will always work. 109 | 110 |
Known to boot in: 112 | Chrome 3-8, 11-16 (fastest, loads to shell prompt in 113 | less than a second when hosted on same network), 114 | Firefox 3.0, 3.5, 3.6, 4, 5, 6, 7, 8, 115 | Internet Explorer 8, 9, 116 | Safari 4.0, 5.0.5, 5.1, 117 | Opera 11, 11.5, 11.6, 118 | Epiphany 3.2, 119 | Konqueror 4.7, 120 | iPhone 4, 121 | HTC Wildfire running Android 2.2. 122 | Currently, the Erlang/OTP system will boot, but the terminal 123 | javascript will not accept user input in IE and the mobile 124 | browsers. 125 |
126 | 127 | 128 |Only limited support for binaries and ets tables have been 129 | added so far. Floats will not always work, especially not the 130 | presentation in the shell due to a dependency on binaries. In the 131 | example above math.beam is missing so no floats.
132 |Only the most commonly used bifs have been implemented, and 133 | arguments are not always checked. Files 134 | and networking is not supported or expected to work, although some 135 | initial hacks have been made in order to get the test server 136 | running.
137 | 138 |Is able to start Common test and the test server, and passes 139 | the standard OTP tests suites for lists, arrays, 140 | dicts, random numbers and queues.
141 | 142 |The following functions are likely to change, and only shown here as a proof of concept. 144 |
js:eval(String) -> true 145 |
Example: 148 |
js:eval("document.getElementById('first').innerHTML = 'some text'").149 | 150 |
js:call(JsObject, Function, Arguments) -> js_object()
151 |
js:get(JsObject, Property) -> js_object()
152 |
js:set(JsObject, Property, Value) -> true
153 |
154 |
Examples: 161 |
Doc = js:get(window, document). 162 | MyElem = js:call(Doc, getElementById, [first]). 163 | MyElem = js:call(document, getElementById, [first]). 164 | OldContents = js:get(MyElem, innerHTML). 165 | js:set(MyElem, innerHTML, "some text"). 166 | js:set(MyElem, innerHTML, OldContents).167 | 168 | 169 |
Dual licensed under the MIT and GPL v3 licenses.
171 | 172 | 173 | 174 |Fredrik Svahn (fredrik.svahn@gmail.com)
176 |
Fredrik Svahn (fredrik.svahn@gmail.com)
182 |
187 | You can download this project in either 188 | zip or 189 | tar formats. 190 |
191 |You can also clone the project with Git by running: 192 |
$ git clone git://github.com/svahne/browserl193 | 194 | 195 | 198 | 199 |
t |