- After looking at other .cgi files I realised that I had named the variables based on their dhcp usage only. However colouryellow or color20 etc can be used not only in a row but also in a cell or a column. Rather than ending up with multiple copies of the same colour for rows, cells, columns etc I have simplified the variable names to just the colour. They can then be used in whatever situation is wanted. The rest of the cgi code will give the view of what structure the colour is being applied to. - This will limit the number of different css variables defined in the header.pl file
Tested-by: Adolf Belka adolf.belka@ipfire.org Signed-off-by: Adolf Belka adolf.belka@ipfire.org --- config/cfgroot/header.pl | 10 +++++----- html/cgi-bin/dhcp.cgi | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) mode change 100644 => 100755 html/cgi-bin/dhcp.cgi
diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index cd56e574f..e4d917161 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -43,19 +43,19 @@ $Header::viewsize = 150; $Header::errormessage = ''; $Header::extraHead = <<END <style> - .row-color20 { + .color20 { background-color: $color{'color20'}; } - .row-color22 { + .color22 { background-color: $color{'color22'}; } - .row-colouryellow { + .colouryellow { background-color: $Header::colouryellow; } - .cell-orange { + .orange { background-color: orange; } - .cell-red { + .red { background-color: red; } </style> diff --git a/html/cgi-bin/dhcp.cgi b/html/cgi-bin/dhcp.cgi old mode 100644 new mode 100755 index 28b00215c..f45703f0b --- a/html/cgi-bin/dhcp.cgi +++ b/html/cgi-bin/dhcp.cgi @@ -844,11 +844,11 @@ foreach my $line (@current1) { }
if ($dhcpsettings{'KEY1'} eq $key) { - print "<tr class='row-colouryellow'>"; + print "<tr class='colouryellow'>"; } elsif ($key % 2) { - print "<tr class='row-color22'>"; + print "<tr class='color22'>"; } else { - print "<tr class='row-color20'>"; + print "<tr class='color20'>"; }
print <<END @@ -1078,13 +1078,13 @@ foreach my $line (@current2) {
if ($dhcpsettings{'KEY2'} eq $key) { print "<tr>"; - $col="class='row-colouryellow'"; + $col="class='colouryellow'"; } elsif ($key % 2) { print "<tr>"; - $col="class='row-color20'"; + $col="class='color20'"; } else { print "<tr>"; - $col="class='row-color22'"; + $col="class='color22'"; } my $TAG0 = ''; my $TAG1 = ''; @@ -1100,10 +1100,10 @@ foreach my $line (@current2) { $TAG3 = '</b>'; } if ($ipoutside{$temp[1]} > 0) { - $TAG4 = "class='cell-orange'" if ($dhcpsettings{'KEY2'} ne $key); + $TAG4 = "class='orange'" if ($dhcpsettings{'KEY2'} ne $key); } if ($ipinrange{$temp[1]} > 0) { - $TAG4 = "class='cell-red'" if ($dhcpsettings{'KEY2'} ne $key); + $TAG4 = "class='red'" if ($dhcpsettings{'KEY2'} ne $key); }
print <<END @@ -1166,9 +1166,9 @@ print <<END <tr> <td> </td> <td> </td> - <td class='base cell-orange'>$Lang::tr{'ip address outside subnets'}</td> + <td class='base orange'>$Lang::tr{'ip address outside subnets'}</td> <td>  </td> - <td class='base cell-red'>$Lang::tr{'dhcp fixed ip address in dynamic range'}</td> + <td class='base red'>$Lang::tr{'dhcp fixed ip address in dynamic range'}</td> <td> </td> <td> </td> $dup
- This updates the updatexlrator.cgi page to the same central use of extraHead from header.pl and simplifying of css variables where appropriate. - The variables for the percentage bar will also be able to be used in other cgi pages with a percent bar.
Tested-by: Adolf Belka adolf.belka@ipfire.org Signed-off-by: Adolf Belka adolf.belka@ipfire.org --- config/cfgroot/header.pl | 25 ++++++++++++++++ html/cgi-bin/updatexlrator.cgi | 54 +++++----------------------------- 2 files changed, 32 insertions(+), 47 deletions(-)
diff --git a/config/cfgroot/header.pl b/config/cfgroot/header.pl index e4d917161..955ed2646 100644 --- a/config/cfgroot/header.pl +++ b/config/cfgroot/header.pl @@ -58,6 +58,31 @@ $Header::extraHead = <<END .red { background-color: red; } + .table1colour { + background-color: $Header::table1colour; + } + .table2colour { + background-color: $Header::table2colour; + } + .percent-box { + border-style: solid; + border-width: 1px; + border-color: #a0a0a0; + width: 100px; + height: 10px; + } + .percent-bar { + background-color: #a0a0a0; + border-style: solid; + border-width: 1px; + border-color: #e2e2e2; + } + .percent-space { + background-color: #e2e2e2; + border-style: solid; + border-width: 1px; + border-color: #e2e2e2; + } </style> END ; diff --git a/html/cgi-bin/updatexlrator.cgi b/html/cgi-bin/updatexlrator.cgi index 47d3cca42..09f9f5de1 100644 --- a/html/cgi-bin/updatexlrator.cgi +++ b/html/cgi-bin/updatexlrator.cgi @@ -105,46 +105,6 @@ my @metadata=(); &General::readhash("${General::swroot}/proxy/settings", %proxysettings); &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", %color);
-###--- HTML HEAD ---### -my $extraHead = <<END -<style> - .row-color20 { - background-color: $color{'color20'}; - } - .row-color22 { - background-color: $color{'color22'}; - } - .row-table1colour { - background-color: $Header::table1colour; - } - .row-table2colour { - background-color: $Header::table2colour; - } - .percent-box { - border-style: solid; - border-width: 1px; - border-color: #a0a0a0; - width: 100px; - height: 10px; - } - .percent-bar { - background-color: #a0a0a0; - border-style: solid; - border-width: 1px; - border-color: #e2e2e2; - } - .percent-space { - background-color: #e2e2e2; - border-style: solid; - border-width: 1px; - border-color: #e2e2e2; - } -</style> -END -; -###--- END HTML HEAD ---### - - $xlratorsettings{'ACTION'} = ''; $xlratorsettings{'ENABLE_LOG'} = 'off'; $xlratorsettings{'PASSIVE_MODE'} = 'off'; @@ -409,7 +369,7 @@ $selected{'NOT_ACCESSED_LAST'}{$xlratorsettings{'NOT_ACCESSED_LAST'}} = "selecte
&Header::showhttpheaders();
-&Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, $extraHead); +&Header::openpage($Lang::tr{'updxlrtr configuration'}, 1, $Header::extraHead);
&Header::openbigbox('100%', 'left', '', $errormessage);
@@ -572,9 +532,9 @@ END
$id++; if ($id % 2) { - print "<tr class='row-table1colour'>\n"; } + print "<tr class='table1colour'>\n"; } else { - print "<tr class='row-table2colour'>\n"; } + print "<tr class='table2colour'>\n"; }
$filesize = $size_updatefile; 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/; @@ -863,9 +823,9 @@ foreach (@vendors)
$id++; if ($id % 2) { - print "<tr class='row-color20'>\n"; } + print "<tr class='color20'>\n"; } else { - print "<tr class='row-color22'>\n"; } + print "<tr class='color22'>\n"; }
print "<td class='base' align='center'><nobr> ";
@@ -1202,9 +1162,9 @@ END
$id++; if ($id % 2) { - print "<tr class='row-table1colour'>\n"; } + print "<tr class='table1colour'>\n"; } else { - print "<tr class='row-table2colour'>\n"; } + print "<tr class='table2colour'>\n"; }
$filesize = $size_updatefile; 1 while $filesize =~ s/^(-?\d+)(\d{3})/$1.$2/;