/[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 172 by dpavlin, Thu Aug 6 22:27:34 2009 UTC revision 315 by dpavlin, Thu Aug 27 19:58:18 2009 UTC
# Line 1  Line 1 
1  package html;  package html;
2    
3    use Data::Dump qw/dump/;
4    
5  sub table {  sub table {
6          my $cols = shift;          my $cols = shift;
7          my $th;          my $th;
# Line 12  sub table { Line 14  sub table {
14    
15          my @td = map { "<td>$_</td>" } @_;          my @td = map { "<td>$_</td>" } @_;
16          my $html = qq{<table>\n<tr>$th};          my $html = qq{<table>\n<tr>$th};
17            my $row = 0;
18    
19          foreach ( 0 .. $#td ) {          foreach ( 0 .. $#td ) {
20                          $html .= $td[$_];                          $html .= $td[$_];
21                          $html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0;                          if ( ( $_ + 1 ) % $cols == 0 ) {
22                                    $zebra = $row++ % 2 == 0 ? qq{ style="background: #eee"} : '';
23                                    $html .= qq{</tr>\n<tr$zebra>};
24                            };
25          }          }
26          $html .= qq{</tr>\n</table>};          $html .= qq{</tr>\n</table>};
27  }  }
# Line 32  sub tabs { Line 39  sub tabs {
39                    
40    
41  sub tt {  sub tt {
42          qq|<tt>| . join(' ', @_) . qq|</tt>|;          qq|<tt>| . join(' ', @_) . qq|</tt>| if @_;
43  }  }
44    
45  sub select {  sub select {
46          my $name = shift;          my $name = shift;
47          my $selected_option = shift;          my $selected_option = shift;
48            unshift @_, '' unless $selected_option;
49          return join("\n"                  return join("\n"        
50                  , qq|<select type=select name=$name>|                  , qq|<select type=select name=$name>|
51                  , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )                  , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
# Line 46  sub select { Line 54  sub select {
54          );          );
55  }  }
56    
57    sub pre {
58            qq|<pre>| . join(' ', @_) . qq|</pre>| if @_;
59    }
60    
61    sub pre_dump {
62            my $data = shift;
63            my $dump = dump( $data );
64            $dump =~ s{"([^"]+)"(\s*=>)}{$1  $2}gs;
65            $dump =~ s{"([^"]*)"}{"<b>$1</b>"}gs;
66            qq|<pre>$dump</pre>|;
67    }
68    
69  warn "loaded";  warn "loaded";
70    
71  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26