Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.