[erlang-questions] how: ot: real time web pages?

Joe Armstrong erlang@REDACTED
Sun Dec 2 11:24:27 CET 2007


It is extremely doable - it takes about 25-50 lines of javascript, and
a little erlang http server

Here is an outline of the method.

1) Wrap the regions you want to change with unique tags
    <div id="12345"> ... </id>

2) To change the content within this tag you need to execute a
javascript statement

    document.getElemenById("12345").innerHTML = "..... some html""

3) To do this you need some javascript that calls erlang - the erlang
should NOT return immediately
but return when the next update is required. The erlang return value
should return a string which contains the
"document.getElementByCommand command" - on getting the return value
the javascript just "eval's" the result

4) Every time erlang returns you update the region on the page and
immediately call erlang again
which suspends until the next update comes.

I don't actually have short example of this - I have code for this
wrapped up in a lot of other
junk that obscure the simplicity of the solution.

At this stage I would really recommend that you learn javascript. I
started by doing the exercises at

http://www.w3schools.com/js/

To do anything nice in a browser you need to learn javascript.

You also need to setup some server side stuff ( a little http server -
this can be as easy or  difficult
as you like ...)


/Joe




On Dec 2, 2007 8:25 AM, Jouni Rynö <Jouni.Ryno@REDACTED> wrote:
> I start from what I would like to have:
> A web page with a real time updated display of numerical values and
> graphs. Think about typical process displays in industry,
> temperatures, voltages and some graphs showing parameter history.
> Maybe some graphical layout of hardware, to show how each parameter
> is connected to each other.
>
> To achieve that, I would need a  web page template format, where I can:
> - define named text fields, which shall be updated
> - define named graphics, which can be updated
> - and some code to generate the real page and connection functions
> for (comet style?) communication with the page and erlang process
> feeding the data
>
> Currently I have all that implemented as Tcl/Tk canvas (thanks to Ola
> Samuelsson and ewish, which was distributed with Erlang back in 97 or
> so?)
>
> As my understanding of "javascript" is practically zero, I would like
> get a hint on how to do this. Googling shows a lot of options, most
> of the systems not quite being there. Should it be simply javascript
> and svg, changes updated via attributes. Or canvas tag (complicated
> with text fields?) Or haxe and flash (for which I did not find
> examples, how the update mechanism would work) Or something else?
>
> Is this doable? Some examples existing already?
>
> Jouni
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list