From 49aaa6ddf0386e388fd3548a480b29e5b57c8e82 Mon Sep 17 00:00:00 2001 From: totoro Date: Sat, 19 Nov 2016 19:12:54 +0100 Subject: [PATCH] add missing text() with integer for HMTL_In_Form add get_Int_list() from web arg --- web/CXM_making_a_web_site.anubis | 19 +++++++++++++++++-- web/CXM_web_arg_utils.anubis | 28 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/web/CXM_making_a_web_site.anubis b/web/CXM_making_a_web_site.anubis index f490df9..2c933d5 100644 --- a/web/CXM_making_a_web_site.anubis +++ b/web/CXM_making_a_web_site.anubis @@ -1181,7 +1181,6 @@ public type HTML_Partial_Content: List(HTML_Head_Tag), HTML_Off_Form ). - public define List(HTML_Head_Tag) to_HTML_Head_Tag @@ -1252,6 +1251,7 @@ public type HTML_In_Form: 'HTML_In_Form' defines all the elements you may put within a form. We define a convenience function: + public define HTML_In_Form text_input(HTML_Label label, HTML_Id id, WebArgName name, InitialValue init, Int width) = text_input([], label, id, name, init, width). public define HTML_In_Form literal(Printable_tree t) = literal_pt(t). @@ -1369,7 +1369,22 @@ public define HTML_In_Form String s ) = text([],s). - + +public define HTML_In_Form + text + ( + List(Text_Option) lto, + Int i + ) = + text(lto, to_decimal(i)). + +public define HTML_In_Form + text + ( + Int i + ) = + text([],i). + public define HTML_In_Form radio_button (List(CoreAttrs) options, HTML_Label label, WebArgName n, WebArgValue value, Bool checked) = radio_button (options, label, html_Id(n.name), n, value, checked). diff --git a/web/CXM_web_arg_utils.anubis b/web/CXM_web_arg_utils.anubis index 110775a..5beaaae 100644 --- a/web/CXM_web_arg_utils.anubis +++ b/web/CXM_web_arg_utils.anubis @@ -190,7 +190,33 @@ public define Int failure then default_value, success(value) then value }. - + +public define List(Int) + get_Int_list + ( + List(Web_arg) l, + String name + ) = + if l is + { + [] then [], + [h . t] then + if h is web_arg(n, v) then + if n = name then + //println("matching int name "+name+" value "+v); + if decimal_scan(v) is + { + failure then get_Int_list(t, name), + success(value) then + [ value . get_Int_list(t, name)] + } + else + get_Int_list(t, name) + else + get_Int_list(t, name) + } +. + public define Maybe(Word32) get_Word32 ( -- libgit2 0.21.4