From: Alexander Marx Date: Thu, 11 Jul 2013 15:15:15 +0000 (+0200) Subject: Forward Firewall: added some java Script to automatically select radiobuttons when... X-Git-Url: http://git.ipfire.org/?p=people%2Fteissler%2Fipfire-2.x.git;a=commitdiff_plain;h=b88c88291bc62a7e8bc1ed784182a158d425a11f Forward Firewall: added some java Script to automatically select radiobuttons when dropdowns are changed. Some cleanup of the code --- diff --git a/html/cgi-bin/forwardfw.cgi b/html/cgi-bin/forwardfw.cgi index 061fe5f2c..0ab744392 100755 --- a/html/cgi-bin/forwardfw.cgi +++ b/html/cgi-bin/forwardfw.cgi @@ -99,6 +99,27 @@ my @protocols; &Header::getcgihash(\%fwdfwsettings); &Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); &Header::openbigbox('100%', 'center',$errormessage); +#### JAVA SCRIPT #### +print< + \$(document).ready(function() { + // Automatically select radio buttons when corresponding + // dropdown menu changes. + \$("select").change(function() { + var id = \$(this).attr("name"); + //When using SNAT or DNAT, check "USE NAT" Checkbox + if ( id === 'snat' || id === 'dnat') { + \$('#USE_NAT').prop('checked', true); + } + \$('#' + id).prop("checked", true); + }); + }); +function checkradio(a){ + \$(a).attr('checked', true); +} + +END + #### ACTION ##### if ($fwdfwsettings{'ACTION'} eq 'saverule') @@ -366,7 +387,7 @@ sub addrule { &error; if (-f "${General::swroot}/forward/reread"){ - print "
    $Lang::tr{'fwhost reread'}

"; + print "
    $Lang::tr{'fwhost reread'}

"; } &Header::openbox('100%', 'left', $Lang::tr{'fwdfw menu'}); print "
"; @@ -977,7 +998,7 @@ print< - "; #custom networks if (! -z $confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #custom hosts if (! -z $confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #custom groups if (! -z $configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print"
$Lang::tr{'fwhost stdnet'}
$Lang::tr{'fwhost stdnet'}
$Lang::tr{'fwhost cust net'}
$Lang::tr{'fwhost cust net'}
$Lang::tr{'fwhost cust addr'}
$Lang::tr{'fwhost cust addr'}
$Lang::tr{'fwhost cust grp'}
$Lang::tr{'fwhost cust grp'}
"; # CCD networks if( ! -z $configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ - print""; } #OVPN CCD Hosts foreach my $key (sort { ncmp($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){ if ($ccdhost{$key}[33] ne '' ){ - print"" ; + print"" ; } if ($show eq '1'){$show='';print"";} #OVPN N2N foreach my $key (sort { ncmp($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){ if ($ccdhost{$key}[3] eq 'net'){ - print"" ; + print"" ; } if ($show eq '1'){$show='';print"";} #IPsec netze @@ -1068,11 +1089,11 @@ END } } if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){ - print""; + print""; } if ($show eq '1'){$show='';print"";} - print"
$Lang::tr{'fwhost ccdnet'}$Lang::tr{'fwhost ccdnet'}
$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ccdhost'}$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ccdhost'}
$Lang::tr{'fwhost ovpn_n2n'}:
$Lang::tr{'fwhost ovpn_n2n'}:$Lang::tr{'fwhost ovpn_n2n'}
$Lang::tr{'fwhost ovpn_n2n'}
$Lang::tr{'fwhost ipsec net'}
$Lang::tr{'fwhost ipsec net'}
"; + print""; print"
"; } sub get_ip @@ -1514,7 +1535,7 @@ sub newrule #------SOURCE------------------------------------------------------- print< - $Lang::tr{'fwdfw sourceip'}Firewall + $Lang::tr{'fwdfw sourceip'}Firewall END print"
END &gen_dd_block('src','grp1'); print<
+

+ END print" +
$Lang::tr{'fwdfw use srcport'} $Lang::tr{'fwdfw man port'}
$Lang::tr{'fwdfw targetip'}Firewall
$Lang::tr{'fwdfw targetip'}Firewall

END &gen_dd_block('tgt','grp2'); print<
+

- - - + - + + END print""; + print""; $fwdfwsettings{'dnatport'}=~ tr/|/,/; - print""; + print""; print""; #SNAT - print""; + print""; print"
$Lang::tr{'fwdfw use srv'}$Lang::tr{'fwhost cust service'}
$Lang::tr{'fwdfw use srv'}$Lang::tr{'fwhost cust service'}
$Lang::tr{'fwhost cust srvgrp'}
$Lang::tr{'fwhost cust srvgrp'}
$Lang::tr{'fwdfw man port'}
$Lang::tr{'fwdfw man port'}
$Lang::tr{'fwhost icmptype'}
$Lang::tr{'fwdfw use nat'}
$Lang::tr{'fwdfw dnat'}
$Lang::tr{'fwdfw use nat'}
$Lang::tr{'fwdfw dnat'}IPFire:
Port:
Port:

$Lang::tr{'fwdfw snat'}
$Lang::tr{'fwdfw snat'}IPFire:
"; + print""; print"
"; &Header::closebox(); #---Activate/logging/remark------------------------------------- @@ -1711,8 +1732,7 @@ END } } print""; - print"$Lang::tr{'remark'}:"; - #print"$Lang::tr{'remark'}:"; + print"$Lang::tr{'remark'}:"; if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){ print "$Lang::tr{'fwdfw rulepos'}:$Lang::tr{'fwdfw timeframe'} -   + $Lang::tr{'fwdfw timeframe'} +   $Lang::tr{'time'}: $Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'} @@ -1746,15 +1766,13 @@ END - - - - - - - - - + + + + + + +

END #---ACTION------------------------------------------------------ if($fwdfwsettings{'updatefwrule'} ne 'on'){ @@ -1787,9 +1804,10 @@ END -
- -
+ +
+ +
END }else{ print<$title1
"; print""; - print""; + print""; foreach my $key (sort {$a <=> $b} keys %$hash){ $tdcolor=''; @tmpsrc=(); @@ -2158,7 +2176,7 @@ sub viewtablenew print""; #KEY print<$key   + END #RULETYPE (A,R,D) if ($$hash{$key}[0] eq 'ACCEPT'){ @@ -2232,12 +2250,11 @@ END #LOGGING print< -
-
+ END #TARGET &getcolor($$hash{$key}[5],$$hash{$key}[6],\%customhost); @@ -2287,51 +2304,45 @@ END $gif="/images/off.gif" } print< - - - + - - + - - + + END if (exists $$hash{$key-1}){ print< - + END }else{ print""; } if (exists $$hash{$key+1}){ print< - + END }else{ print""; @@ -2339,7 +2350,7 @@ END #REMARK if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){ print""; - print""; + print""; } if ($$hash{$key}[18] eq 'ON'){ #TIMEFRAME @@ -2355,7 +2366,7 @@ END my $weekdays=join(",",@days); if (@days){ print""; - print""; + print""; } } }
#$Lang::tr{'fwdfw source'}Log$Lang::tr{'fwdfw target'}$Lang::tr{'fwdfw action'}
#$Lang::tr{'fwdfw source'}Log$Lang::tr{'fwdfw target'}$Lang::tr{'fwdfw action'}
$key   + - +
-
+
-
+
-
+
-
+
-
+
-
   $$hash{$key}[16]
   $$hash{$key}[16]
   $weekdays   $$hash{$key}[26] - $$hash{$key}[27]
   $weekdays   $$hash{$key}[26] - $$hash{$key}[27]