[cisco-stats] Simplified CSS style handling for interfaces
authorMaximilian Wilhelm <max@rfc2324.org>
Sat, 5 Jan 2008 23:36:24 +0000 (00:36 +0100)
committerMaximilian Wilhelm <max@rfc2324.org>
Sat, 5 Jan 2008 23:36:24 +0000 (00:36 +0100)
Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>

cisco-stats/generate_cisco_port_configuration_overview

index 09626fe..a1a133d 100755 (executable)
@@ -332,7 +332,9 @@ sub print_interfaces ($) { # print_interfaces (\%interfaces_of_$type) {{{
                my $int_ref = $interfaces_hash->{$int};
 
                print "\t   <tr>\n";
-               my $int_class="";
+
+               # Port mode (access or trunk)
+               my $int_class="port_name " . $int_ref->{mode} . "_port";
 
                # IntName [(IntDesc)] \[IntMode [UNLIMITED]\]
                my $int_string = "$int_ref->{name} ";
@@ -340,19 +342,16 @@ sub print_interfaces ($) { # print_interfaces (\%interfaces_of_$type) {{{
                        $int_string .= "($int_ref->{desc}) ";
                }
 
-               # Port mode (access or trunk)
-               $int_class = "$int_ref->{mode}" . "_port";
-
                $int_string .= "[";
                if ($int_ref->{mode} eq 'trunk' && ! defined $int_ref->{trunk_allowed_vlans}) {
                        $int_string .= "UNLIMITED ";
-                       $int_class = "unlimited_trunk";
+                       $int_class .= " unlimited_trunk";
                }
                $int_string .= "$int_ref->{mode}]";
 
                # Is the port shutdown?
                if ($int_ref->{disabled}) {
-                       $int_string = "<strike>$int_string</strike>";
+                       $int_class .= " linethrough";
                }
 
                # Print it
@@ -362,11 +361,12 @@ sub print_interfaces ($) { # print_interfaces (\%interfaces_of_$type) {{{
 
                # Print X'es
                foreach my $vlan_id (@vlan_list) {
+                       my $css_class = "x";
+
                        if ($int_ref->{disabled}) {
-                               print " <td class=\"x_linethrough\">";
-                       } else {
-                               print " <td class=\"x\">";
+                               $css_class .= " linethrough";
                        }
+                       print " <td class=\"$css_class\">";
 
                        if (($int_ref->{mode} eq 'access' && $int_ref->{access_vlan} == $vlan_id) ||
                            ($int_ref->{mode} eq 'trunk' && (! defined $int_ref->{trunk_allowed_vlans} || grep {/^$vlan_id$/} @{$int_ref->{trunk_allowed_vlans}})) )  {
@@ -422,27 +422,21 @@ print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1
                border-right: 1px solid black;
          }
 
-         .border_right_2px_solid {
+         .port_name {
                border-right: 2px solid black;
          }
 
          .trunk_port {
-               border-right: 2px solid black;
-
                color: #000080;
                font-weight: bold;
          }
 
          .unlimited_trunk {
-               border-right: 2px solid black;
-
                color: #FF0000;
                font-weight: bold;
          }
 
          .access_port {
-               border-right: 2px solid black;
-
                color: #000000;
          }
 
@@ -451,9 +445,7 @@ print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1
                vertical-align: middle;
          }
 
-         .x_linethrough {
-               text-align: center;
-               vertical-align: middle;
+         .linethrough {
                text-decoration: line-through;
          }
         </style>
@@ -470,7 +462,7 @@ print '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1
 
 # Generate table row with vlan IDs
 my $vlan_row = '         <tr>
-          <th class="border_right_2px_solid">Interface \ Vlan</th>
+          <th class="port_name">Interface \ Vlan</th>
 ';
 
 # Generate a column for each used vlan