Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4563e4647e
Fetching contributors…

Cannot retrieve contributors at this time

file 28 lines (23 sloc) 0.719 kb
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
%% Copyright (c) 2011 Joe Armstrong
%% See MIT-LICENSE for licensing information.
%% Time-stamp: <2011-02-12 10:51:26 joe>

-module(demo2).
-export([start/1]).

%% simple demo
%% once started Pid is a channel that csn be iused to talk
%% to the browser. Pid ! {cmd,Javascript}

start(Pid) ->
    Pid ! {eval,"document.body.innerHTML=''"},
    Pid ! {eval, "document.body.style.backgroundColor='orange';"},
    Pid ! {eval, button("click me")},
    %% now add a link
    event_loop(Pid).

button(X) ->
    ["document.body.innerHTML+=",
     "\"<button onclick='send(\\\"",X,"\\\")'>",X,"</button>\";"].

event_loop(Pid) ->
    receive
Any ->
io:format("??event loop:~p~n",[Any]),
event_loop(Pid)
    end.
Something went wrong with that request. Please try again.