/[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

Diff of /lib/PXElator/html.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 45 by dpavlin, Wed Jul 29 22:04:58 2009 UTC revision 172 by dpavlin, Thu Aug 6 22:27:34 2009 UTC
# Line 2  package html; Line 2  package html;
2    
3  sub table {  sub table {
4          my $cols = shift;          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>" } @_;          my @td = map { "<td>$_</td>" } @_;
14          my $html = qq{<table>\n<tr>};          my $html = qq{<table>\n<tr>$th};
15          foreach ( 0 .. $#td ) {          foreach ( 0 .. $#td ) {
16                          $html .= $td[$_];                          $html .= $td[$_];
17                          $html .= qq{</tr>\n<tr>} if $_ % $cols == 1;                          $html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0;
18          }          }
19          $html .= qq{</tr>\n</table>};          $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";  warn "loaded";
50    
51  1;  1;

Legend:
Removed from v.45  
changed lines
  Added in v.172

  ViewVC Help
Powered by ViewVC 1.1.26