/[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 153 by dpavlin, Wed Aug 5 23:22:17 2009 UTC revision 187 by dpavlin, Sun Aug 9 21:59:17 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;
8    
9            if ( $cols < 0 ) {
10                    $cols = abs($cols);
11                    $th .= qq|<th>| . shift(@_) . qq|</td>| foreach ( 1 .. $cols );
12                    $th .= qq|</tr>\n<tr>|;
13            }
14    
15          my @td = map { "<td>$_</td>" } @_;          my @td = map { "<td>$_</td>" } @_;
16          my $html = qq{<table>\n<tr>};          my $html = qq{<table>\n<tr>$th};
17          foreach ( 0 .. $#td ) {          foreach ( 0 .. $#td ) {
18                          $html .= $td[$_];                          $html .= $td[$_];
19                          $html .= qq{</tr>\n<tr>} if $_ % $cols == 1;                          $html .= qq{</tr>\n<tr>} if ( $_ + 1 ) % $cols == 0;
20          }          }
21          $html .= qq{</tr>\n</table>};          $html .= qq{</tr>\n</table>};
22  }  }
# Line 29  sub tt { Line 39  sub tt {
39    
40  sub select {  sub select {
41          my $name = shift;          my $name = shift;
42          my $checked_option = shift;          my $selected_option = shift;
43          return join("\n"                  return join("\n"        
44                  , qq|<select type=select name=$name>|                  , qq|<select type=select name=$name>|
45                  , join("\n", map { my $checked = $_ eq $checked_option ? 'checked' : ''; qq|<option name=$_ $checked>$_</option>| } @_ )                  , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
46                  , qq|</select>|                  , qq|</select>|
47                  , qq|</form>|                  , qq|</form>|
48          );          );
49  }  }
50    
51    sub pre_dump {
52            my $data = shift;
53            my $dump = dump( $data );
54            $dump =~ s{"([^"]+)"(\s*=>)}{$1  $2}gs;
55            $dump =~ s{"([^"]*)"}{"<b>$1</b>"}gs;
56            qq|<pre>$dump</pre>|;
57    }
58    
59  warn "loaded";  warn "loaded";
60    
61  1;  1;

Legend:
Removed from v.153  
changed lines
  Added in v.187

  ViewVC Help
Powered by ViewVC 1.1.26