/[pxelator]/lib/PXElator/html.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/html.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 172 - (show annotations)
Thu Aug 6 22:27:34 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 974 byte(s)
implement table header with negative witdh
1 package html;
2
3 sub table {
4 my $cols = shift;
5 my $th;
6
7 if ( $cols < 0 ) {
8 $cols = abs($cols);
9 $th .= qq|<th>| . shift(@_) . qq|</td>| foreach ( 1 .. $cols );
10 $th .= qq|</tr>\n<tr>|;
11 }
12
13 my @td = map { "<td>$_</td>" } @_;
14 my $html = qq{<table>\n<tr>$th};
15 foreach ( 0 .. $#td ) {
16 $html .= $td[$_];
17 $html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0;
18 }
19 $html .= qq{</tr>\n</table>};
20 }
21
22 sub tabs {
23 return unless @_;
24 my $html = qq{<table border=1>\n<tr>};
25 foreach my $row ( @_ ) {
26 $row =~ s{\t}{</td><td>}g;
27 $html .= qq|<tr><td>$row</td><tr>\n|;
28 }
29 $html .= qq|</table>|;
30 return $html;
31 }
32
33
34 sub tt {
35 qq|<tt>| . join(' ', @_) . qq|</tt>|;
36 }
37
38 sub select {
39 my $name = shift;
40 my $selected_option = shift;
41 return join("\n"
42 , qq|<select type=select name=$name>|
43 , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
44 , qq|</select>|
45 , qq|</form>|
46 );
47 }
48
49 warn "loaded";
50
51 1;

  ViewVC Help
Powered by ViewVC 1.1.26