add webif
[openwrt/svn-archive/archive.git] / openwrt / package / webif / files / usr / lib / webif / form.awk
1 # $1 = type
2 # $2 = form variable name
3 # $3 = form variable value
4 # $4 = (radio button) value of button
5 # $5 = string to append
6 # $6 = additional attributes
7
8 $1 ~ /^start_form/ {
9 print "<form method=\"POST\" action=\"" $2 "\" enctype=\"multipart/form-data\">"
10 print "<input type=\"hidden\" name=\"submit\" value=\"1\" />"
11 print "<table style=\"width: 90%; text-align: left;\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">"
12 print "<tbody>"
13 }
14 $1 ~ /^field/ {
15 if (field_open == 1) print "</td></tr>"
16 if ($3 != "") field_id=" id=\"" $3 "\""
17 else field_id=""
18 print "<tr" field_id "><td>" $2 "</td><td>"
19 field_open=1
20 }
21 $1 ~ /^checkbox/ {
22 if ($3==$4) checkbox_selected="checked=\"checked\" "
23 else checkbox_selected=""
24 print "<input id=\"" $2 "_" $4 "\" type=\"checkbox\" name=\"" $2 "\" value=\"" $4 "\" " checkbox_selected $6 " />"
25 }
26 $1 ~ /^radio/ {
27 if ($3==$4) radio_selected="checked=\"checked\" "
28 else radio_selected=""
29 print "<input id=\"" $2 "_" $4 "\" type=\"radio\" name=\"" $2 "\" value=\"" $4 "\" " radio_selected $6 " />"
30 }
31 $1 ~ /^text/ {
32 print "<input id=\"" $2 "\" type=\"text\" name=\"" $2 "\" value=\"" $3 "\" />" $4
33 }
34 $1 ~ /^submit/ {
35 print "<input type=\"submit\" name=\"" $2 "\" value=\"" $3 "\" />"
36 }
37 {
38 print $5
39 }
40 $1 ~ /^end_form/ {
41 if (field_open == 1) print "</td></tr>"
42 print "</tbody>"
43 print "</table>"
44 print "</form>"
45 }