CXM_widgets.anubis 2.05 KB
/*
 * Created by PyramIDE.
 * User: フランスのトトロ 
 * Date: 07/12/2014
 * Time: 18:10
 * © Calexium 
 */
 
read system/string.anubis
read tools/basis.anubis

read calexium_lib/web/CXM_making_a_web_site.anubis

public define HTML_In_Form
  ip_input
  (
    HtmlId      the_id,
    WebArgName  wan_prefix,
    String      ip
  )=
  with ip_fields = split(ip, '.'),
  if the_id is htmlId(id_str) then
  if wan_prefix is wan(field_prefix) then
  div([id(id_str)], 
  sequence(
  [ 
    text_input([class("ip_input")], "", htmlId(""), wan(field_prefix+"_0"), init(force_nth(0,ip_fields,"")), 3),
    text("."),
    text_input([class("ip_input")], "", htmlId(""), wan(field_prefix+"_1"), init(force_nth(1,ip_fields,"")), 3),
    text("."),
    text_input([class("ip_input")], "", htmlId(""), wan(field_prefix+"_2"), init(force_nth(2,ip_fields,"")), 3),
    text("."),
    text_input([class("ip_input")], "", htmlId(""), wan(field_prefix+"_3"), init(force_nth(3,ip_fields,"")), 3),
  ]))
  .

// ---------------------------------------------------------------------------

public define HTML_In_Form
  partial_ip_input
  (
    HtmlId        the_id,
    WebArgName    wan_prefix,
    List(String)  ip_fixed_part,
    String        ip
  )=
  with ip_fields = split(ip, '.'),
  if the_id is htmlId(id_str) then
  if wan_prefix is wan(field_prefix) then
  with make_field = (Int index)
                        |-> if index < length(ip_fixed_part) then
                              text([], force_nth(index, ip_fixed_part, ""))
                            else
                              text_input([class("ip_input")], 
                                         "", 
                                         htmlId(""), 
                                         wan(field_prefix + "_" + index), 
                                         init(force_nth(index, ip_fields, "")), 
                                         3),
  div([id(id_str)], 
  sequence(
  [ 
    make_field(0),
    text("."),
    make_field(1),
    text("."),
    make_field(2),
    text("."),
    make_field(3),
  ]))
  .