Created
February 7, 2016 14:22
-
-
Save yminsky/bc8e39c1b31ea79e405c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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