-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget.ur
50 lines (41 loc) · 2.02 KB
/
widget.ur
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
con t (value :: Type) (state :: Type) =
{ Create : transaction state,
Initialize : value -> transaction state,
AsWidget : state -> xbody,
Value : state -> signal value,
AsValue : value -> xbody }
con t' (value :: Type, state :: Type) = t value state
fun create [value] [state] (t : t value state) = t.Create
fun initialize [value] [state] (t : t value state) = t.Initialize
fun asWidget [value] [state] (t : t value state) = t.AsWidget
fun value [value] [state] (t : t value state) = t.Value
fun asValue [value] [state] (t : t value state) = t.AsValue
fun make [value] [state] r = r
val textbox = { Create = source "",
Initialize = source,
AsWidget = fn s => <xml><ctextbox source={s}/></xml>,
Value = signal,
AsValue = txt }
val checkbox = { Create = source False,
Initialize = source,
AsWidget = fn s => <xml><ccheckbox source={s}/></xml>,
Value = signal,
AsValue = txt }
val intbox = { Create = source "",
Initialize = fn n => source (show n),
AsWidget = fn s => <xml><ctextbox source={s}/></xml>,
Value = fn s => v <- signal s; return (Option.get 0 (read v)),
AsValue = txt }
val timebox = { Create = source "",
Initialize = fn n => source (show n),
AsWidget = fn s => <xml><ctextbox source={s}/></xml>,
Value = fn s => v <- signal s; return (Option.get minTime (read v)),
AsValue = fn t => if t = minTime then <xml><b>INVALID</b></xml> else txt t }
val urlbox = { Create = source "",
Initialize = source,
AsWidget = fn s => <xml><ctextbox source={s}/></xml>,
Value = signal,
AsValue = fn s =>
case checkUrl s of
None => <xml><b>[BLOCKED URL]</b></xml>
| Some url => <xml><a href={url}><tt>{[url]}</tt></a></xml> }