Commit a13f30f7 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

*** empty log message ***

parent 4793cd36
......@@ -4,24 +4,50 @@ import StdEnv, StdHtml
// choose one of the following variants
Start world = doHtmlServer (singleUserTask count) world
// Start world = doHtmlServer (multiUserTask 3 [] countMU) world
// Start world = doHtmlServer (multiUserTask 3 [setTaskAttribute Persistent] countMU) world
//Start world = doHtmlServer (singleUserTask count) world
Start world = doHtmlServer (multiUserTask 3 [] countMU) world
//Start world = doHtmlServer (multiUserTask 3 [setTaskAttribute Persistent] countMU) world
//Start world = doHtmlServer countIData world
// Change the type to any type one can apply addition to
initVal :: Int
initVal = createDefault
// single user: give first value, then give second, then show sum
count tst
# (v1,tst) = STask "Set" initVal tst
# (v2,tst) = STask "Set" initVal tst
# tst = returnF [Hr []] tst
# tst = returnF [Txt "+",Hr []] tst
= returnTask (v1 + v2) tst
// multi user varian
countMU tst
# (v1,tst) = ((1,"number") @: STask "Set" initVal) tst // user 1
# (v2,tst) = ((2,"number") @: STask "Set" initVal) tst // user 2
# tst = returnF [Hr []] tst // user 0
# tst = returnF [Txt "+",Hr []] tst // user 0
= returnTask (v1 + v2) tst // user 0
// Change the type to any type one can apply addition to
initVal :: Int
initVal = createDefault
// iData variant to show what iTasks do automatically for you
countIData hst
# ((d1,v1),t1,hst) = myEdit "v1" 0 hst
# ((d2,v2),t2,hst) = myEdit "v2" 0 hst
= mkHtml "Solution using iData without iTasks"
[ t1
, if d1 t2 EmptyBody
, if d2 (BodyTag [Txt "+",Hr [],toHtml (v1 + v2)]) EmptyBody
] hst
where
myEdit name val hst
# (idata,hst) = mkEditForm (Init, nFormId name (HideMode False,val) <@ Submit) hst
# nval = snd idata.value
# done = idata.changed || fst idata.value == HideMode True
| done
# (idata,hst) = mkEditForm (Set, nFormId name (HideMode done,nval) <@ Display) hst
= ((True,nval),BodyTag idata.form,hst)
= ((False,nval),BodyTag idata.form,hst)
\ No newline at end of file
......@@ -17,6 +17,7 @@ instance toInt PullDownMenu // Current index in pull down list
instance toString PullDownMenu // Corresponding element in pull down list
derive gEq HtmlDate, HtmlTime, PasswordBox
instance == HtmlDate, HtmlTime, PasswordBox
instance == (DisplayMode a) | == a
derive gLexOrd HtmlDate, HtmlTime
instance < HtmlDate, HtmlTime
instance toString HtmlDate, HtmlTime
......
......@@ -386,6 +386,14 @@ instance == PasswordBox where (==) pb1 pb2 = pb1 === pb2
instance == HtmlTime where (==) ht1 ht2 = ht1 === ht2
instance == HtmlDate where (==) hd1 hd2 = hd1 === hd2
instance == (DisplayMode a) | == a
where
(==) (DisplayMode a) (DisplayMode b) = a == b
(==) (EditMode a) (EditMode b) = a == b
(==) (HideMode a) (HideMode b) = a == b
(==) EmptyMode EmptyMode = True
(==) _ _ = False
derive gLexOrd HtmlTime, HtmlDate
instance < HtmlTime where (<) ht1 ht2 = gEq{|*|} (gLexOrd{|*|} ht1 ht2) LT
instance < HtmlDate where (<) hd1 hd2 = gEq{|*|} (gLexOrd{|*|} hd1 hd2) LT
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment