3 use Data::Dump qw/dump/;
12 $th .= qq|<th>| . shift(@_) . qq|</td>| foreach ( 1 .. $cols );
13 $th .= qq|</tr>\n<tr>|;
16 my @td = map { "<td>$_</td>" } @_;
17 my $html = qq{<table>\n<tr>$th};
20 foreach ( 0 .. $#td ) {
22 if ( ( $_ + 1 ) % $cols == 0 ) {
23 $zebra = $row++ % 2 == 0 ? qq{ style="background: #eee"} : '';
24 $html .= qq{</tr>\n<tr$zebra>};
27 $html .= qq{</tr>\n</table>};
32 my $html = qq{<table border=1>\n<tr>};
33 foreach my $row ( @_ ) {
34 $row =~ s{\t}{</td><td>}g;
35 $html .= qq|<tr><td>$row</td><tr>\n|;
37 $html .= qq|</table>|;
43 qq|<tt>| . join(' ', @_) . qq|</tt>| if @_;
48 my $selected_option = shift;
49 unshift @_, '' unless $selected_option;
51 , qq|<select type=select name=$name>|
52 , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
58 qq|<pre>| . join(' ', @_) . qq|</pre>| if @_;
63 my $dump = dump( $data );
64 $dump =~ s{"([^"]+)"(\s*=>)}{$1 $2}gs;
65 $dump =~ s{"([^"]*)"}{"<b>$1</b>"}gs;
70 my ($ip,$conf,$format) = @_;
71 my @editable = splice(@_,3);
73 warn "# conf ",dump( $ip, $conf, $format, [ @editable ] );
79 my $html = $conf->{$name};
81 if ( $format eq 'edit' && grep { m/^$name$/ } @editable ) {
82 $size = length($html);
83 ( $name, qq|<input name=$name value="$html" size=$size>| )
85 if ( $name eq 'amt' ) {
86 my $amt_ip = amt::ip($ip,$html);
87 $html = qq|<a title="$html" href=http://$amt_ip:16992/logon.htm target=$amt_ip>$amt_ip</a>|;
89 if ( $format ne 'inline' ) {
90 my $power = amt::power_on($ip);
93 ? qq|<a href=/amt/PowerDown/$ip title="turn off">on</a>|
94 : qq|<a href=/amt/PowerUp/$ip title="turn on" >off</a>|
96 client::conf( $ip, 'power' => $power ? 'on' : 'off' );
98 } elsif ( $name eq 'ssh' ) {
99 $html =~ s{\s(\S{16}).+(\S{16})\s}{ $1..$2 };
101 } elsif ( $name eq 'kvm' ) {
102 $html = qq|<a href="/start_stop/kvm?nr=$html">$html</a>|;
104 $html = qq|<tt>$html</tt>|
106 $html =~ s{\b(\S+)\t(\S+)\t(\S+)\b}{<b title="$1/$2">$3</b> }gs;
108 if ( $format =~ /edit|table/ ) {
111 qq|<div class="config $name"><em>$name</em> $html</div>|
114 } grep { length($conf->{$_}) > 0 } sort keys %$conf;
116 $format eq 'inline' ? join("\n", @opts) : @opts;