Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clean-libraries
Commits
dddacfd5
Commit
dddacfd5
authored
Nov 23, 2006
by
Rinus Plasmeijer
Browse files
Systeem voorbereid op submit forms maar die werken nog niet
parent
66f2e595
Changes
15
Expand all
Hide whitespace changes
Inline
Side-by-side
libraries/htmlGEC/EncodeDecode.dcl
View file @
dddacfd5
...
...
@@ -16,6 +16,28 @@ import htmlFormData
|
JustTesting
// No Server attached at all, intended for testing (in collaboration with Gast)
|
Internal
// No external server needed: a Clean Server is atached to this executable
// Triplet handling
::
Triplet
:==
(
String
,
Int
,
UpdValue
)
::
TripletUpdate
:==
(
Triplet
,
String
)
::
Triplets
:==
[
TripletUpdate
]
::
UpdValue
// the updates that can take place
=
UpdI
Int
// new integer value
|
UpdR
Real
// new real value
|
UpdB
Bool
// new boolean value
|
UpdC
String
// choose indicated constructor
|
UpdS
String
// new piece of text
encodeTriplet
::
!
Triplet
->
String
// encoding of triplets
decodeTriplet
::
!
String
->
Maybe
Triplet
// Form submission handling
callClean
::
!(
Script
->
ElementEvents
)
!
Mode
!
String
->
[
ElementEvents
]
submitscript
::
BodyTag
globalstateform
::
!
Value
->
BodyTag
// type driven encoding of strings, used to encode triplets
encodeInfo
::
!
a
->
String
|
gPrint
{|*|}
a
...
...
@@ -24,7 +46,7 @@ decodeInfo :: !String -> Maybe a | gParse{|*|} a
// serializing, de-serializing of iData states to strings stored in the html page
EncodeHtmlStates
::
![
HtmlState
]
->
String
DecodeHtmlStatesAndUpdate
::
!
ServerKind
(
Maybe
String
)
->
([
HtmlState
],
String
,
String
)
// + triplet + update
DecodeHtmlStatesAndUpdate
::
!
ServerKind
(
Maybe
String
)
->
(
!
[
HtmlState
],
!
Triplets
)
// hidden state stored in Client + triplets
// serializing, de-serializing of iData state stored in files
...
...
libraries/htmlGEC/EncodeDecode.icl
View file @
dddacfd5
...
...
@@ -9,6 +9,67 @@ import GenPrint, GenParse
import
dynamic_string
import
EstherBackend
derive
gParse
UpdValue
,
(,,)
derive
gPrint
UpdValue
,
(,,),
(,)
// form submission department....
// script for transmitting name and value of changed input
callClean
::
!(
Script
->
ElementEvents
)
!
Mode
!
String
->
[
ElementEvents
]
callClean
onSomething
Edit
_
=
[
onSomething
(
SScript
"toclean(this)"
)]
callClean
onSomething
Submit
myid
=
[
onSomething
(
SScript
(
"toclean2("
<+++
myid
<+++
")"
))]
callClean
onSomething
_
_
=
[]
submitscript
::
BodyTag
submitscript
=
BodyTag
[
Script
[]
(
SScript
(
" function toclean(inp)"
+++
" { document."
+++
globalFormName
+++
"."
+++
updateInpName
+++
".value=inp.name+
\"
=
\"
+inp.value;"
+++
"document."
+++
globalFormName
+++
".submit(); }"
))
,
Script
[]
(
SScript
(
" function toclean2(form)"
+++
" { "
+++
"form.hidden.value="
+++
"document."
+++
globalFormName
+++
"."
+++
globalInpName
+++
".value;"
+++
"form.submit();"
+++
"}"
))
]
// form that contains global state and empty input form for storing updated input
globalstateform
::
!
Value
->
BodyTag
globalstateform
globalstate
=
Form
[
Frm_Name
globalFormName
// , Frm_Action (MyPhP server)
,
Frm_Method
Post
,
Frm_Enctype
"multipart/form-data"
// what to do to enable large data ??
]
[
Input
[
Inp_Name
updateInpName
,
Inp_Type
Inp_Hidden
]
""
,
Input
[
Inp_Name
globalInpName
,
Inp_Type
Inp_Hidden
,
Inp_Value
globalstate
]
""
]
globalFormName
::
String
globalFormName
=:
"CleanForm"
updateInpName
::
String
updateInpName
=:
"UD"
globalInpName
::
String
globalInpName
=:
"GS"
selectorInpName
::
String
selectorInpName
=:
"CS"
// Serializing Html states...
EncodeHtmlStates
::
![
HtmlState
]
->
String
...
...
@@ -70,15 +131,15 @@ where
// reconstruct HtmlState out of the information obtained from browser
DecodeHtmlStatesAndUpdate
::
!
ServerKind
(
Maybe
String
)
->
([
HtmlState
],
String
,
String
)
DecodeHtmlStatesAndUpdate
::
!
ServerKind
(
Maybe
String
)
->
(
!
[
HtmlState
],
!
Triplets
)
DecodeHtmlStatesAndUpdate
serverkind
args
#
(_,
triplet
,
update
,
state
)
=
DecodeArguments
serverkind
args
=
([
states
\\
states
=:(
id
,_,_,
nstate
)
<-
DecodeHtmlStates
state
|
id
<>
""
||
nstate
<>
""
],
triplet
,
update
)
// to be sure that no rubbish is passed on
#
(_,
triplet
s
,
state
)
=
DecodeArguments
serverkind
args
=
([
states
\\
states
=:(
id
,_,_,
nstate
)
<-
DecodeHtmlStates
state
|
id
<>
""
||
nstate
<>
""
],
triplet
s
)
// to be sure that no rubbish is passed on
// Parse and decode low level information obtained from server
// In case of using a php script and external server:
DecodeArguments
::
!
ServerKind
(
Maybe
String
)
->
(!
String
,!
String
,!
String
,!
String
)
DecodeArguments
::
!
ServerKind
(
Maybe
String
)
->
(!
String
,!
Triplets
,!
String
)
DecodeArguments
External
_
=
DecodePhpArguments
where
// DecodePhpArguments :: (!String,!String,!String,!String) // executable, id + update , new , state
...
...
@@ -86,16 +147,14 @@ where
#
input
=
[
c
\\
c
<-:
GetArgs
|
not
(
isControl
c
)
]
// get rid of communication noise
#
(
thisexe
,
input
)
=
mscan
'#'
input
// get rid of garbage
#
input
=
skipping
[
'#UD='
]
input
#
(
update
,
input
)
=
mscan
'='
input
#
(
triplet
,
input
)
=
mscan
'='
input
#
(
new
,
input
)
=
mscan
';'
input
#
input
=
skipping
[
'GS='
]
input
#
(
state
,
input
)
=
mscan
';'
input
=:
case
toString
update
of
"CS"
=
(
toString
thisexe
,
decodeChars
new
,
""
,
toString
state
)
else
=
(
toString
thisexe
,
decodeChars
update
,
toString
new
,
toString
state
)
/* =: case (decodeChars thisexe, decodeChars update, decodeChars new, decodeChars state) of
(thisexe,"CS",new,state) = (thisexe,new,"",state)
else = else*/
// "CS" = (toString thisexe, decodeChars new, "", toString state)
// else = (toString thisexe, decodeChars triplet, toString new, toString state)
else
=
(
"clean"
,
[(
calcTriplet
(
decodeChars
triplet
)
""
,
toString
new
)],
toString
state
)
GetArgs
::
String
GetArgs
=:
foldl
(+++)
""
[
strings
\\
strings
<-:
getCommandLine
]
...
...
@@ -104,43 +163,55 @@ where
DecodeArguments
Internal
(
Just
args
)
=
DecodeCleanServerArguments
args
where
DecodeCleanServerArguments
::
!
String
->
(!
String
,!
String
,!
String
,!
String
)
// executable, id + update , new , state
DecodeCleanServerArguments
::
!
String
->
(!
String
,!
Triplets
,!
String
)
// executable, id + update , new , state
DecodeCleanServerArguments
args
#
input
=
[
c
\\
c
<-:
args
|
not
(
isControl
c
)
]
// get rid of communication noise
#
(
thisexe
,
input
)
=
mscan
'\"'
input
// get rid of garbage
#
input
=
skipping
[
'UD
\"
'
]
input
#
(
update
,
input
)
=
mscan
'='
input
// should give triplet
#
(
new
,
input
)
=
mscan
'-'
input
// should give
update
value <<< *** Bug for negative integers??? ***
#
(
triplet
,
input
)
=
mscan
'='
input
// should give triplet
#
(
new
,
input
)
=
mscan
'-'
input
// should give
triplet
value <<< *** Bug for negative integers??? ***
#
(_,
input
)
=
mscan
'='
input
#
input
=
skipping
[
'
\"
GS
\"
'
]
input
#
(
found
,
index
)
=
FindSubstr
[
'---'
]
input
#
state
=
if
found
(
take
index
input
)
[
''
]
=
case
toString
update
of
"CS"
=
(
"clean"
,
decodeChars
new
,
""
,
toString
state
)
else
=
(
"clean"
,
decodeChars
update
,
toString
new
,
toString
state
)
=
case
toString
triplet
of
""
=
(
"clean"
,
[],
toString
state
)
"CS"
=
(
"clean"
,
[(
calcTriplet
(
decodeChars
new
)
""
,
""
)],
toString
state
)
else
=
(
"clean"
,
[(
calcTriplet
(
decodeChars
triplet
)
(
toString
new
),
toString
new
)],
toString
state
)
calcTriplet
::
String
String
->
Triplet
calcTriplet
s
newstring
=
case
parseString
s
of
Just
(
id
,
pos
,
UpdS
_)
=
(
id
,
pos
,
UpdS
newstring
)
Just
triplet
=
triplet
_
=
(
"Parse Error!"
,
0
,
UpdS
s
)
// traceHtmlInput utility used to see what kind of rubbish is received
traceHtmlInput
::
!
ServerKind
!(
Maybe
String
)
->
BodyTag
traceHtmlInput
serverkind
args
=:(
Just
string
)
=
BodyTag
[
Br
,
B
[]
"State values received from client when application started:"
,
Br
,
STable
[]
[
[
B
[]
"Triplet:"
,
Txt
triplet
]
,[
B
[]
"Update:"
,
Txt
updates
]
STable
[]
[
[
B
[]
"Triplet
s
:"
,
Br
]
,
showTriplet
triplets
,[
B
[]
"Id:"
,
B
[]
"Lifespan:"
,
B
[]
"Format:"
,
B
[]
"Value:"
]
:
[
[
Txt
id
,
Txt
(
showl
life
),
Txt
(
showf
storage
),
Txt
(
shows
storage
state
)]
\\
(
id
,
life
,
storage
,
state
)
<-
htmlState
]
]
,
Br
// , Txt string
,
Txt
string
// , Txt (decodeString string)
]
where
(
htmlState
,
triplet
,
update
s
)
=
DecodeHtmlStatesAndUpdate
serverkind
args
(
htmlState
,
triplets
)
=
DecodeHtmlStatesAndUpdate
serverkind
args
showl
life
=
toString
life
showf
storage
=
case
storage
of
PlainString
->
"String"
;
_
->
"S_Dynamic"
shows
PlainString
s
=
s
shows
StaticDynamic
d
=
toStr
(
string_to_dynamic`
d
)
// "cannot show dynamic value"
showTriplet
[]
=
[]
showTriplet
[
triplet
:
triplets
]
=
[
Txt
(
printToString
triplet
),
Br
:
showTriplet
triplets
]
showl
life
=
toString
life
showf
storage
=
case
storage
of
PlainString
->
"String"
;
_
->
"S_Dynamic"
shows
PlainString
s
=
s
shows
StaticDynamic
d
=
toStr
(
string_to_dynamic`
d
)
// "cannot show dynamic value"
toStr
dyn
=
ShowValueDynamic
dyn
<+++
" :: "
<+++
ShowTypeDynamic
dyn
...
...
@@ -160,7 +231,7 @@ where
ThisExe
::
!
ServerKind
->
String
ThisExe
External
#
(
thisexe
,_,_
,_
)
=
DecodeArguments
External
Nothing
#
(
thisexe
,_,_)
=
DecodeArguments
External
Nothing
=
thisexe
ThisExe
Internal
=
"clean"
...
...
@@ -211,9 +282,19 @@ where
encodeString
::
!
String
->
String
encodeString
s
=
/* see also urlEncode */
string_to_string52
s
// using the whole alphabet
//encodeString s = urlEncode s
decodeString
::
!
String
->
*
String
decodeString
s
=
/* see also urlDecode */
string52_to_string
s
// using the whole alphabet
//decodeString s = urlDecode s
// to encode triplets in htmlpages
encodeTriplet
::
!
Triplet
->
String
// encoding of triplets
encodeTriplet
triplet
=
encodeInfo
triplet
decodeTriplet
::
!
String
->
Maybe
Triplet
// decoding of triplets
decodeTriplet
triplet
=
decodeInfo
triplet
// utility functions based on low level encoding - decoding
...
...
libraries/htmlGEC/Examples/Conf Management System/ConfManager.prj
View file @
dddacfd5
This diff is collapsed.
Click to expand it.
libraries/htmlGEC/Examples/Simple Examples/balanceTree.prj
View file @
dddacfd5
This diff is collapsed.
Click to expand it.
libraries/htmlGEC/Examples/Simple Workflows/workflowExamples.icl
View file @
dddacfd5
...
...
@@ -21,8 +21,9 @@ where
=
mkHtml
"test"
[
idform
.
form
<=>
html
]
hst
where
persistent
tasks
tst
#
tst
=
setTaskAttribute
Persistent
tst
// # tst = setTaskAttribute Database tst
// # tst = setTaskAttribute Persistent tst
#
tst
=
setTaskAttribute
StaticDynamic
tst
#
tst
=
setTaskAttribute
Database
tst
=
tasks
tst
...
...
libraries/htmlGEC/Examples/WebShopDeLuxe/cdShop.prj
View file @
dddacfd5
This diff is collapsed.
Click to expand it.
libraries/htmlGEC/htmlButtons.icl
View file @
dddacfd5
...
...
@@ -128,23 +128,23 @@ gForm{|Button|} (init,formid) hst
v
=:(
LButton
size
bname
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Button
,
Inp_Value
(
SV
bname
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
bname
))
,
`
Inp_Std
[
Std_Style
(
"width:"
<+++
size
)]
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
])
""
]
},(
incrHSt
1
hst
))
v
=:(
PButton
(
height
,
width
)
ref
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Image
,
Inp_Value
(
SV
ref
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
ref
))
,
`
Inp_Std
[
Std_Style
(
"width:"
<+++
width
<+++
" height:"
<+++
height
)]
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
,
Inp_Src
ref
])
""
]
},
incrHSt
1
hst
)
...
...
@@ -157,22 +157,22 @@ gForm{|CheckBox|} (init,formid) hst
v
=:(
CBChecked
name
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Checkbox
,
Inp_Value
(
SV
name
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
name
))
,
Inp_Checked
Checked
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
])
""
]
},
incrHSt
1
hst
)
v
=:(
CBNotChecked
name
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Checkbox
,
Inp_Value
(
SV
name
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
name
))
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
])
""
]
},
incrHSt
1
hst
)
...
...
@@ -182,22 +182,22 @@ gForm{|RadioButton|} (init,formid) hst
v
=:(
RBChecked
name
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Radio
,
Inp_Value
(
SV
name
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
name
))
,
Inp_Checked
Checked
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
])
""
]
},
incrHSt
1
hst
)
v
=:(
RBNotChecked
name
)
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[
Inp_Disabled
Disabled
]
[]
++
,
form
=
[
Input
(
onMode
formid
.
mode
[]
[]
[
Inp_Disabled
Disabled
]
[]
++
[
Inp_Type
Inp_Radio
,
Inp_Value
(
SV
name
)
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdS
name
))
,
`
Inp_Events
[
OnClick
callClean
]
,
`
Inp_Events
(
callClean
OnClick
Edit
""
)
])
""
]
},
incrHSt
1
hst
)
...
...
@@ -207,11 +207,11 @@ gForm{|PullDownMenu|} (init,formid) hst
v
=:(
PullDown
(
size
,
width
)
(
menuindex
,
itemlist
))
=
(
{
changed
=
False
,
value
=
v
,
form
=
[
Select
(
onMode
formid
.
mode
[]
[
Sel_Disabled
Disabled
]
[]
++
,
form
=
[
Select
(
onMode
formid
.
mode
[]
[]
[
Sel_Disabled
Disabled
]
[]
++
[
Sel_Name
(
"CS"
)
,
Sel_Size
size
,
`
Sel_Std
[
Std_Style
(
"width:"
<+++
width
<+++
"px"
)]
,
`
Sel_Events
[
OnChange
callClean
]
,
`
Sel_Events
(
callClean
OnChange
Edit
""
)
])
[
Option
[
Opt_Value
(
encodeTriplet
(
formid
.
id
,
cntr
,
UpdC
(
itemlist
!!
j
)))
...
...
@@ -236,9 +236,9 @@ gForm{|TextArea|} (init,formid) hst
#
(
cntr
,
hst
)
=
CntrHSt
hst
=
(
{
changed
=
False
,
value
=
formid
.
ival
,
form
=
[
Form
[
Frm_Method
Post
,
`
Frm_Events
[
OnSubmit
callClean
]
]
,
form
=
[
Form
[
Frm_Method
Post
,
`
Frm_Events
(
callClean
OnSubmit
Edit
""
)
]
[
mkSTable
[
[
Textarea
[
Txa_Name
"message"
,
Txa_Rows
row
,
Txa_Cols
col
]
""
]
,
[
mkSTable
[[
Input
[
Inp_Type
Inp_Submit
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
+2
,
UpdS
string
)),
Inp_Value
(
SV
"Set"
),
`
Inp_Events
[
OnClick
callClean
]
]
""
,
[
mkSTable
[[
Input
[
Inp_Type
Inp_Submit
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
+2
,
UpdS
string
)),
Inp_Value
(
SV
"Set"
),
`
Inp_Events
(
callClean
OnClick
Edit
""
)
]
""
,
Input
[
Inp_Type
Inp_Reset
,
Inp_Name
"reset"
,
Inp_Value
(
SV
"Reset"
)]
""
]]
]
...
...
@@ -270,7 +270,7 @@ where
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
updval
))
,
Inp_Size
size
,
`
Inp_Std
[
EditBoxStyle
,
Std_Title
"::Password"
]
,
`
Inp_Events
[
OnChange
callClean
]
,
`
Inp_Events
(
callClean
OnChange
Edit
""
)
]
""
,
incrHSt
1
hst
)
mkPswInput
size
(
init
,{
mode
=
Display
})
sval
_
hst
...
...
libraries/htmlGEC/htmlFormData.dcl
View file @
dddacfd5
...
...
@@ -29,7 +29,8 @@ import GenEq
|
Temp
// form setting is not stored at all, only lives temporaly in the Clean application
::
Mode
// one can choose:
=
Edit
// an editable form
=
Edit
// an editable form where every change is commited to the server
|
Submit
// an editable form where the whole content is commited on submit
|
Display
// a non-editable form
|
NoForm
// do not generate a form, only a value
...
...
@@ -119,7 +120,7 @@ reuseFormId :: !(FormId a) !d -> FormId d // reuse id for new type (only to b
initID
::
!(
FormId
d
)
->
InIDataId
d
// (Init,FormId a)
setID
::
!(
FormId
d
)
!
d
->
InIDataId
d
// (Set,FormId a)
onMode
::
!
Mode
a
a
a
->
a
// chose arg depending on Edit, Display, NoForm
onMode
::
!
Mode
a
a
a
a
->
a
// chose arg depending on Edit,
Submit,
Display, NoForm
// manipulating initial values
...
...
libraries/htmlGEC/htmlFormData.icl
View file @
dddacfd5
...
...
@@ -88,10 +88,11 @@ initID formid = (Init,formid)
setID
::
!(
FormId
d
)
!
d
->
InIDataId
d
// (Set,FormId a)
setID
formid
na
=
(
Set
,
setFormId
formid
na
)
onMode
::
!
Mode
a
a
a
->
a
onMode
Edit
e1
e2
e3
=
e1
onMode
Display
e1
e2
e3
=
e2
onMode
NoForm
e1
e2
e3
=
e3
onMode
::
!
Mode
a
a
a
a
->
a
onMode
Edit
e1
e2
e3
e4
=
e1
onMode
Submit
e1
e2
e3
e4
=
e2
onMode
Display
e1
e2
e3
e4
=
e3
onMode
NoForm
e1
e2
e3
e4
=
e4
toViewId
::
!
Init
!
d
!(
Maybe
d
)
->
d
toViewId
Init
d
Nothing
=
d
...
...
libraries/htmlGEC/htmlFormlib.icl
View file @
dddacfd5
...
...
@@ -210,7 +210,7 @@ vertlistFormButs nbuts showbuts (init,formid) hst
=
(
{
form
=
pdbuts
.
form
++
bbuts
.
form
++
[[
toHtml
(
"nr "
<+++
(
i
+1
)
<+++
" / "
<+++
length
list
.
value
)
<.||.>
(
onMode
formid
.
mode
(
if
showbuts
(
del
<.=.>
ins
<.=.>
app
<.=.>
copy
<.=.>
paste
)
EmptyBody
)
EmptyBody
EmptyBody
)
(
onMode
formid
.
mode
(
if
showbuts
(
del
<.=.>
ins
<.=.>
app
<.=.>
copy
<.=.>
paste
)
EmptyBody
)
EmptyBody
EmptyBody
EmptyBody
)
\\
del
<-
del
.
form
&
ins
<-
ins
.
form
&
app
<-
app
.
form
&
copy
<-
copy
.
form
&
paste
<-
paste
.
form
&
i
<-
[
bbuts
.
value
..]]
<=|>
list
.
form
%
betweenindex
...
...
libraries/htmlGEC/htmlHandler.icl
View file @
dddacfd5
...
...
@@ -50,7 +50,8 @@ doHtmlServer :: !(*HSt -> (Html,!*HSt)) !*World -> *World
doHtmlServer
userpage
world
=
StartServer
80
[(
"clean"
,
\_
_
a
->
doHtmlServer2
(
conv
a
)
userpage
)]
world
where
conv
args
=
foldl
(+++)
""
(
map
snd
args
)
conv
args
=
foldl
(+++)
""
[
name
+++
"="
+++
value
+++
";"
\\
(
name
,
value
)
<-
args
]
// conv args = foldl (+++) "" (map snd args)
doHtmlServer2
::
String
.(*
HSt
->
(
Html
,!*
HSt
))
*
World
->
([
String
],
String
,*
World
)
doHtmlServer2
args
userpage
world
...
...
@@ -109,7 +110,7 @@ doHtmlPage serverkind args userpage inout world
#
(
allformbodies
,
world
)
=
storeFormStates
states
world
#
{
worldC
,
gerda
,
inout
}
=
print_to_stdout
(
Html
(
Head
headattr
[
extra_style
:
headtags
])
(
Body
(
extra_body_attr
++
attr
)
[
debugInput
,
debufOutput
,
allformbodies
:
bodytags
]))
(
Body
(
extra_body_attr
++
attr
)
[
allformbodies
:
bodytags
++[
debugInput
,
debufOutput
]
]))
world
#
world
=
closeGerda`
gerda
worldC
=
(
inout
,
world
)
...
...
@@ -151,7 +152,7 @@ where
,
mkHSt
states
world
)
#
(
viewform
,{
states
,
world
})
// make a form for it
=
g
Form
{|*|}
(
init
,
if
(
init
==
Const
)
vformid
(
reuseFormId
formid
view
))
(
mkHSt
states
world
)
=
mk
Form
(
init
,
if
(
init
==
Const
)
vformid
(
reuseFormId
formid
view
))
(
mkHSt
states
world
)
|
viewform
.
changed
&&
not
isupdated
// important: redo it all to handle the case that a user defined specialisation is updated !!
=
calcnextView
True
(
Just
viewform
.
value
)
states
world
...
...
@@ -207,7 +208,8 @@ where
(
Just
(
sid
,
pos
,
UpdB
b
),
_,
fs
)
=
(
Just
(
pos
,
UpdB
b
),
findState
(
nformid
sid
)
fs
world
)
(_,_,
fs
)
=
case
getTriplet
fs
of
(
Just
(
sid
,
pos
,
UpdS
s
),
Just
ns
,
fs
)
=
(
Just
(
pos
,
UpdS
ns
),
findState
(
nformid
sid
)
fs
world
)
(
Just
(
sid
,
pos
,
UpdS
s
),
_,
fs
)
=
(
Just
(
pos
,
UpdS
anyInput
),
findState
(
nformid
sid
)
fs
world
)
(
Just
(
sid
,
pos
,
UpdS
s
),
_,
fs
)
=
(
Just
(
pos
,
UpdS
s
),
findState
(
nformid
sid
)
fs
world
)
// (Just (sid,pos,UpdS s), _,fs) = (Just (pos,UpdS anyInput),findState (nformid sid) fs world)
(
upd
,
new
,
fs
)
=
(
Nothing
,
findState
formid
fs
world
)
|
otherwise
=
(
Nothing
,
findState
formid
fs
world
)
...
...
@@ -232,6 +234,27 @@ where
// gForm: automatically derives a Html form for any Clean type
mkForm
::
!(
InIDataId
a
)
!*
HSt
->
*(
Form
a
,
!*
HSt
)
|
gForm
{|*|}
a
mkForm
(
init
,
formid
=:{
mode
=
Submit
})
hst
#
(
form
,
hst
)
=
gForm
{|*|}
(
init
,
formid
)
hst
#
hidden
=
Input
[
Inp_Name
"hidden"
,
Inp_Type
Inp_Hidden
,
Inp_Value
(
SV
""
)
]
""
#
submit
=
Input
[
Inp_Type
Inp_Button
,
Inp_Value
(
SV
"Submit"
)
,
`
Inp_Events
(
callClean
OnClick
Submit
formid
.
id
)
]
""
#
clear
=
Input
[
Inp_Type
Inp_Reset
,
Inp_Value
(
SV
"Clear"
)]
""
#
sform
=
[
Form
[
Frm_Method
Post
,
Frm_Name
formid
.
id
]
(
form
.
form
++
[
hidden
,
Br
,
submit
,
clear
])
]
=
({
form
&
form
=
sform
}
,
hst
)
mkForm
inidataid
hst
=
gForm
{|*|}
inidataid
hst
generic
gForm
a
::
!(
InIDataId
a
)
!*
HSt
->
*(
Form
a
,
!*
HSt
)
gForm
{|
Int
|}
(
init
,
formid
)
hst
...
...
@@ -331,7 +354,7 @@ where
where
styles
=
case
formid
.
mode
of
Edit
->
[
`
Sel_Std
[
Std_Style
width
,
EditBoxStyle
]
,
`
Sel_Events
[
OnChange
callClean
]
,
`
Sel_Events
(
callClean
OnChange
Edit
""
)
]
_
->
[
`
Sel_Std
[
Std_Style
width
,
DisplayBoxStyle
]
,
Sel_Disabled
Disabled
...
...
@@ -473,22 +496,17 @@ gUpd{|(->)|} gUpdArg gUpdRes mode f
// small utility functions
mkInput
::
!
Int
!(
InIDataId
d
)
Value
UpdValue
!*
HSt
->
(
BodyTag
,*
HSt
)
mkInput
size
(
init
,
formid
=:{
mode
=
Edit
})
val
updval
hst
=:{
cntr
}
mkInput
size
(
init
,
formid
=:{
mode
})
val
updval
hst
=:{
cntr
}
|
mode
==
Edit
||
mode
==
Submit
=
(
Input
[
Inp_Type
Inp_Text
,
Inp_Value
val
,
Inp_Name
(
encodeTriplet
(
formid
.
id
,
cntr
,
updval
))
,
Inp_Size
size
,
`
Inp_Std
[
EditBoxStyle
,
Std_Title
(
showType
val
)]
,
`
Inp_Events
[
OnChange
callClean
]
,
`
Inp_Events
if
(
mode
==
Edit
)
(
callClean
OnChange
formid
.
mode
""
)
[
]
]
""
,
setCntr
(
cntr
+1
)
hst
)
where
showType
(
SV
str
)
=
"::String"
showType
(
NQV
str
)
=
"::String"
showType
(
IV
i
)
=
"::Int"
showType
(
RV
r
)
=
"::Real"
showType
(
BV
b
)
=
"::Bool"
mkInput
size
(
init
,{
mode
=
Display
})
val
_
hst
=:{
cntr
}
|
mode
==
Display
=
(
Input
[
Inp_Type
Inp_Text
,
Inp_Value
val
,
Inp_ReadOnly
ReadOnly
...
...
@@ -496,12 +514,17 @@ mkInput size (init,{mode = Display}) val _ hst=:{cntr}
,
Inp_Size
size
]
""
,
setCntr
(
cntr
+1
)
hst
)
mkInput
size
(
init
,_)
val
_
hst
=:{
cntr
}
=
(
EmptyBody
,
setCntr
(
cntr
+1
)
hst
)
=
(
EmptyBody
,
setCntr
(
cntr
+1
)
hst
)
where
showType
(
SV
str
)
=
"::String"
showType
(
NQV
str
)
=
"::String"
showType
(
IV
i
)
=
"::Int"
showType
(
RV
r
)
=
"::Real"
showType
(
BV
b
)
=
"::Bool"
toHtml
::
a
->
BodyTag
|
gForm
{|*|}
a
toHtml
a
#
(
na
,_)
=
g
Form
{|*|}
(
Set
,
mkFormId
"__toHtml"
a
<@
Display
)
(
mkHSt
emptyFormStates
undef
)
#
(
na
,_)
=
mk
Form
(
Set
,
mkFormId
"__toHtml"
a
<@
Display
)
(
mkHSt
emptyFormStates
undef
)
=
BodyTag
na
.
form
toHtmlForm
::
!(*
HSt
->
*(
Form
a
,*
HSt
))
->
[
BodyTag
]
|
gForm
{|*|},
gUpd
{|*|},
gPrint
{|*|},
gParse
{|*|},
TC
a
...
...
libraries/htmlGEC/htmlSettings.dcl
View file @
dddacfd5
...
...
@@ -28,5 +28,5 @@ radioButtonSeparator :== '.' // used as extension for family of radiobuttons
// OPTIONS WHICH CAN BE SET OFF AND ON