From 2e99ab8bf8a1dc79d1c411281bd82a19acf1c9dc Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Fri, 12 Jul 2013 08:01:01 +0200 Subject: [PATCH 1/1] Forward Firewall: added some javascript to automatically select radiobuttons when dropdowns are changed --- html/cgi-bin/fwhosts.cgi | 94 +++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 39 deletions(-) diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 73dabaadb..d7a519a37 100755 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -80,6 +80,24 @@ unless (-e $configsrvgrp) { system("touch $configsrvgrp"); } &Header::openpage($Lang::tr{'fwhost hosts'}, 1, ''); &Header::openbigbox('100%', 'center'); +#### 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); + }); + }); + +END + ## ACTION #### if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'}) { @@ -373,8 +391,7 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' ) } &addnet; &viewtablenet; - }else - { + }else { &addnet; &viewtablenet; } @@ -1066,10 +1083,10 @@ sub showmenu &Header::openbox('100%', 'left',$Lang::tr{'fwhost menu'}); print "$Lang::tr{'fwhost welcome'}"; print<
- - -

+

+ + +

END &Header::closebox(); @@ -1083,20 +1100,20 @@ sub addnet $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'}; print<
- $Lang::tr{'name'}: + + - + END if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on') { - print ""; }else{ print "
$Lang::tr{'name'}:
$Lang::tr{'fwhost netaddress'}:
$Lang::tr{'netmask'}:
$Lang::tr{'remark'}:




"; + print ""; } - print "
"; + print "
"; &Header::closebox(); } sub addhost @@ -1107,11 +1124,11 @@ sub addhost $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'}; print<
- $Lang::tr{'name'}: + + - + END if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on') @@ -1119,9 +1136,9 @@ END print "
$Lang::tr{'name'}:
IP/MAC:
$Lang::tr{'remark'}:


"; }else{ - print " "; + print " "; } - print "
"; + print "
"; &Header::closebox(); } sub addgrp @@ -1147,8 +1164,8 @@ sub addgrp my $rem=$fwhostsettings{'remark'}; if ($fwhostsettings{'update'} eq ''){ print<
- $Lang::tr{'fwhost addgrpname'} + +
$Lang::tr{'fwhost addgrpname'}
$Lang::tr{'remark'}:


END @@ -1166,7 +1183,7 @@ END
- "; if (! -z $confignet){ - print""; } if (! -z $confighost){ - print" + END } my $count=0; @@ -1385,7 +1402,7 @@ END print" "; } my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]); - print""; + print""; print< @@ -1399,7 +1416,7 @@ END { print""; }else{ - print""; + print""; } $count++; } @@ -1419,7 +1436,7 @@ sub viewtablehost }else{ print< - + END } my $count=0; @@ -1430,15 +1447,15 @@ END else{ print" ";} my ($ip,$sub)=split(/\//,$customhost{$key}[2]); $customhost{$key}[4]=~s/\s+//g; - print""; + print""; print< + + END if($customhost{$key}[4] == '0') { @@ -1490,8 +1507,8 @@ sub viewtablegrp if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr{'fwhost empty'};} $grpname=$customgrp{$key}[0]; $remark="$customgrp{$key}[1]"; - if($count >=2){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'}"; #OVPN networks if (! -z $configccdnet){ - print"
$Lang::tr{'fwhost ccdnet'}$Lang::tr{'fwhost ccdnet'}$Lang::tr{'fwhost ovpn_n2n'}$Lang::tr{'fwhost ovpn_n2n'}$Lang::tr{'fwhost ipsec net'}$Lang::tr{'fwhost ipsec net'}"; - print"
"; + print"
"; &Header::closebox(); } sub addservice @@ -1370,7 +1387,7 @@ sub viewtablenet }else{ print< -
$Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'remark'}$Lang::tr{'used'}
$Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'remark'}$Lang::tr{'used'}
$customnetwork{$key}[0]
".&Header::colorize($colnet)."$customnetwork{$key}[3]$customnetwork{$key}[4]x$customnetwork{$key}[0]".&Header::colorize($colnet)."$customnetwork{$key}[3]$customnetwork{$key}[4]x
$Lang::tr{'name'}$Lang::tr{'fwhost ip_mac'}$Lang::tr{'remark'}$Lang::tr{'used'}
$Lang::tr{'name'}$Lang::tr{'fwhost ip_mac'}$Lang::tr{'remark'}$Lang::tr{'used'}
$customhost{$key}[0]
".&Header::colorize($ip)."$customhost{$key}[3]$customhost{$key}[4]x$customhost{$key}[0]".&Header::colorize($ip)."$customhost{$key}[3]$customhost{$key}[4]x -
";} - print "
$grpname    "; + if($count gt 2){ print"
";} + print "
$grpname   "; print " $Lang::tr{'remark'}:  $remark   " if ($remark ne ''); print "$Lang::tr{'used'}: $customgrp{$key}[4]x"; if($customgrp{$key}[4] == '0') @@ -1548,7 +1565,7 @@ sub viewtableservice &General::readhasharray("$configsrv", \%customservice); print< - $Lang::tr{'fwhost srv_name'}$Lang::tr{'fwhost prot'}$Lang::tr{'fwhost port'}ICMP$Lang::tr{'fwhost used'} + $Lang::tr{'fwhost srv_name'}$Lang::tr{'fwhost prot'}$Lang::tr{'fwhost port'}ICMP$Lang::tr{'fwhost used'} END foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice) { @@ -1614,9 +1631,9 @@ sub viewtableservicegrp } $remark="$customservicegrp{$key}[1]"; if($count >=2){print"";} - print "
$grpname     "; - print "$Lang::tr{'remark'}:  $remark " if ($remark ne ''); - print "  $Lang::tr{'used'}: $customservicegrp{$key}[3]x"; + print "
$grpname    "; + print "$Lang::tr{'remark'}:  $remark " if ($remark ne ''); + print "  $Lang::tr{'used'}: $customservicegrp{$key}[3]x"; if($customservicegrp{$key}[3] == '0') { print"
"; @@ -1676,7 +1693,6 @@ sub checkip } sub checksubnet { - my %hash=%{(shift)}; &General::readhasharray("$confignet", \%hash); foreach my $key (keys %hash) { -- 2.39.2