summaryrefslogtreecommitdiff
path: root/util/generate_settings.awk
blob: dc9777565a85d4079bd0a9823e47200b5029f921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
$1 == "#" {
	$1 = ""; $2 = "";
	sub(/^[[:space:]]*/, "");
  print "<tr class='dwb_table_row'>"
	print "  <th class='dwb_table_headline' colspan='3'>" $0 "</th>"
	print "</tr>"
	next
}

$2 == "select" {
	id = $1; $1 = ""; $2 = ""; options = ""
	for (i = 3; $i ~ /^@/ && i <= NF; ++i) {
    value = substr($i, 2)
		gsub(/_/, " ", value)
		options = options "<option>" value "</option>"
		$i = ""
	}
	sub(/^[[:space:]]*/, "")
  if (NR % 2 == 0) {
    print "<tr class='dwb_table_row_even'>"
  }
  else {
    print "<tr class='dwb_table_row_odd'>"
  }
	print "  <td class='dwb_table_cell_left'>" id "</td>"
	print "  <td class='dwb_table_cell_middle'>" $0 "</td>"
	print "  <td class='dwb_table_cell_right'>"
        print "    <select id='" id "'>"
	print "      " options
        print "    </select>"
	print "  </td>"
	print "</tr>"
	next
}

NF > 0 {
	id = $1; type = $2; $1 = ""; $2 = ""
	sub(/^[[:space:]]*/, "")
  if (NR % 2 == 0) {
    print "<tr class='dwb_table_row_even'>"
  }
  else {
    print "<tr class='dwb_table_row_odd'>"
  }
	print "  <td class='dwb_table_cell_left'>" id "</td>"
	print "  <td class='dwb_table_cell_middle'>" $0 "</td>"
	print "  <td class='dwb_table_cell_right'><input id='" id "' type='" type "'></td>"
	print "</tr>"
}