Skip to content

Instantly share code, notes, and snippets.

@yminsky
Created February 7, 2016 14:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save yminsky/bc8e39c1b31ea79e405c to your computer and use it in GitHub Desktop.
table server : { Temperature : float,
Uptime: int }
task initialize = fn () =>
dml (DELETE FROM server WHERE TRUE);
dml (INSERT INTO server(Temperature, Uptime) VALUES({[0.0]}, {[0]}))
style selected
val main : transaction page =
initial <- oneRow1 (SELECT * FROM server);
temperature <- source initial.Temperature;
uptime <- source initial.Uptime;
seled <- source False;
mode <- source "Temperature";
return <xml><body>
<ccheckbox source={seled}/> Selected<br/>
<cselect source={mode}>
<coption>Temperature</coption>
<coption>Uptime</coption>
</cselect><br/>
<hr/>
<span dynClass={seled <- signal seled;
return (if seled then selected else null)}>
<dyn signal={mode <- signal mode;
case mode of
"Temperature" =>
temperature <- signal temperature;
return <xml>{[temperature]} degrees</xml>
| "Uptime" =>
uptime <- signal uptime;
return <xml>{[uptime]} days</xml>
| _ => error <xml>oh dear</xml>}/>
</span>
</body></xml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment