[erlang-questions] announce SEGB-0.1

James Churchman jameschurchman@REDACTED
Fri Feb 11 20:43:20 CET 2011


looks really cool!

two things tho, 

1) i cant get it to work, i get when visiting http://localhost:1234/generic.html
Uncaught ReferenceError: SVG is not defined
in chromium 
and 
generic.html:20ReferenceError: Can't find variable: SVG
in safari :-)

maybe its because i dot have genuine chrome on my mac, but the function SVG() does not exist

and 2)

im fairly sure that this in the docs is not quite correct
var glob = new Array();

To persist a variable outside the scope of eval we can evaluate: eval('var glob[Name] = ...'); sinceglob is defined outside of the scope of eval its value will be persisted outside the scope of eval.


I think that eval always runs at the scope that its at, but putting in "var" restricts the scope to either the eval or two the scope that its in (eg the function). I think its the latter. Simply leaving out the var statement (as it does in the code :-) ) makes it global (eg attach to the window object)

james

On 11 Feb 2011, at 18:08, Joe Armstrong wrote:

> Announcing SEBG-0.1
> 
> SEBG = Simple Erlang Browser Graphics
> 
> This is a system to push graphics to a browser.
> 
> Using this you can make interactive graphics in a websockets enabled browser
> in a few lines of code.
> 
> It consists of a simple web server. The browser
> opens a web socket and the web server spawns a process to
> handle the socket. I set up a middle man to handle the socket.
> Thereafter the handler can push asynchronous messages to the browser.
> 
> These message contain Javascript expressions. All the code in the
> browser does is wait for a message, eval it and wait for the next message.
> 
> Then I make sure jquery and Raphael are loaded, after which
> I send Javascript messages to the browser contain Javascript expressions
> that create SVG objects by calling library functions in Raphael
> 
> The code for all of this is surprisingly simple, and it is very easy to push
> asynchronous message to the browser.
> 
> I have also included a number of suggests for projects based on this.
> This list often gets request for suitable problems to solve. Building on
> this simple code it should be possible to implement simple multi-user
> games and so on. Being able to push asynchronous messages to the browser
> makes like very easy.
> 
> Have a look. The code is at
> 
> https://github.com/joearms/SEBG
> 
> Cheers
> 
> /Joe



More information about the erlang-questions mailing list