Commit c247833f84f1ae3ca557fbd7489da75f22b860cf
1 parent
f14ca7a6
Not a very nice patch allowing to remove javascript from web forms
Showing
1 changed file
with
32 additions
and
0 deletions
Show diff stats
calexium_lib/web/CXM_making_a_web_site.anubis
| @@ -1032,6 +1032,14 @@ public define HTML_In_Form | @@ -1032,6 +1032,14 @@ public define HTML_In_Form | ||
| 1032 | ) = | 1032 | ) = |
| 1033 | actioner(conn,targ,asp,action_name,extra_ops,[]). | 1033 | actioner(conn,targ,asp,action_name,extra_ops,[]). |
| 1034 | 1034 | ||
| 1035 | +public define HTML_In_Form | ||
| 1036 | + actioner | ||
| 1037 | + ( | ||
| 1038 | + Actioner_Connection conn, | ||
| 1039 | + Actioner_Target targ, | ||
| 1040 | + Actioner_Aspect asp, | ||
| 1041 | + ) = | ||
| 1042 | + actioner(conn, targ, asp, "", [], []). | ||
| 1035 | 1043 | ||
| 1036 | 1044 | ||
| 1037 | public define HTML_In_Form | 1045 | public define HTML_In_Form |
| @@ -1144,6 +1152,9 @@ public type HTML_Off_Form: | @@ -1144,6 +1152,9 @@ public type HTML_Off_Form: | ||
| 1144 | Maybe((String,List((String,String)))) action), | 1152 | Maybe((String,List((String,String)))) action), |
| 1145 | label (String name), | 1153 | label (String name), |
| 1146 | form (String form_name, List(CoreAttrs), HTML_In_Form content), | 1154 | form (String form_name, List(CoreAttrs), HTML_In_Form content), |
| 1155 | + form (String form_name, List(CoreAttrs), | ||
| 1156 | + String action_name, List((String,String)) extra_ops, | ||
| 1157 | + HTML_In_Form content), | ||
| 1147 | div (List(CoreAttrs), HTML_Off_Form content), | 1158 | div (List(CoreAttrs), HTML_Off_Form content), |
| 1148 | div_empty (List(CoreAttrs)). | 1159 | div_empty (List(CoreAttrs)). |
| 1149 | 1160 | ||
| @@ -3101,6 +3112,10 @@ define Printable_tree | @@ -3101,6 +3112,10 @@ define Printable_tree | ||
| 3101 | text, "</a>" | 3112 | text, "</a>" |
| 3102 | ], | 3113 | ], |
| 3103 | javascript(s,h) then | 3114 | javascript(s,h) then |
| 3115 | + if action_name = "" then // special case where URL (so the action_name) is provided by the form itself | ||
| 3116 | + // so javascript isn't needed. This is the standard HMTL way. | ||
| 3117 | + ["<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " />"] | ||
| 3118 | + else | ||
| 3104 | [s,"<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"] | 3119 | [s,"<input type=\"submit\" value=\"",text,"\"", format_attrs(options), " onclick=\"",h,"\" />"] |
| 3105 | } | 3120 | } |
| 3106 | ], | 3121 | ], |
| @@ -3928,6 +3943,23 @@ define Printable_tree | @@ -3928,6 +3943,23 @@ define Printable_tree | ||
| 3928 | format(cinfo,fn,sn,ic_v,c,is_https), | 3943 | format(cinfo,fn,sn,ic_v,c,is_https), |
| 3929 | "</form>" | 3944 | "</form>" |
| 3930 | ] | 3945 | ] |
| 3946 | + form(fn,attributs, action_name, extra_ops, c) then | ||
| 3947 | + with url = make_actioner_url(cinfo, same, same, | ||
| 3948 | + sn, action_name, extra_ops, is_https), | ||
| 3949 | + [ | ||
| 3950 | + "<form name=\"f",fn,"\"", | ||
| 3951 | + format(cinfo,sn,ic_v,any_coreattrs(attributs),format_element,is_https), | ||
| 3952 | + " method=\"post\"", | ||
| 3953 | + enctype(c), | ||
| 3954 | + " action=\"" + url + "\">", | ||
| 3955 | +// " action=\"http", | ||
| 3956 | +// if is_https then "s" else "", | ||
| 3957 | +// "://",common_name,":",http_port,"/\">", | ||
| 3958 | + // action is set dynamically by | ||
| 3959 | + // the actioner using JavaScript | ||
| 3960 | + format(cinfo,fn,sn,ic_v,c,is_https), | ||
| 3961 | + "</form>" | ||
| 3962 | + ] | ||
| 3931 | div(options, e) then | 3963 | div(options, e) then |
| 3932 | format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), | 3964 | format(cinfo,sn,ic_v,any_div(options, e),format_element,is_https), |
| 3933 | div_empty(options) then | 3965 | div_empty(options) then |