From a5cb9aca7838837e41f34b5d29c3584f708444f0 Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Tue, 15 Oct 2013 12:05:13 +0200 Subject: [PATCH] Firewall: Try to clean up JS code part 1 --- html/cgi-bin/forwardfw.cgi | 78 ++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 36 deletions(-) diff --git a/html/cgi-bin/forwardfw.cgi b/html/cgi-bin/forwardfw.cgi index f8f14add26..c190846d27 100755 --- a/html/cgi-bin/forwardfw.cgi +++ b/html/cgi-bin/forwardfw.cgi @@ -101,6 +101,39 @@ my @protocols; print< \$(document).ready(function() { + // Hide sourceport area when no sourceport is used + if (! \$("#USE_SRC_PORT").attr("checked")) { + toggle_elements('srcport'); + } + // Hide targetport area when no targetport is used + if (! \$("#USESRV").attr("checked")) { + toggle_elements('targetport'); + } + // When nat not used, hide it + if (! \$("#USENAT").attr("checked")) { + toggle_elements('natpart'); + } + // When Prot not icmp, hide icmp-types + if (! \$("#PROT option[value='ICMP']").attr('select')) { + document.getElementById('PROTOKOLL').style.display='none'; + } + // When protocol dropdown is changed, check if we selected icmp - then show icmp-types + \$("#prt").change(function(){ + if ( document.getElementById("PROT").value === 'ICMP' ){ + document.getElementById('PROTOKOLL').style.display='block'; + } + else{ + document.getElementById('PROTOKOLL').style.display='none'; + } + }); + // Show Sourceport area when "use sourceport" checkbox is clicked + \$( "#spt" ).click(function() { + toggle_elements('srcport'); + }); + // Show Targetport area when "use Targetport" checkbox is clicked + \$( "#tpt" ).click(function() { + toggle_elements('targetport'); + }); // Automatically select radio buttons when corresponding // dropdown menu changes. \$("select").change(function() { @@ -142,18 +175,6 @@ function hide_elements() document.getElementById(elementName).style.display='none'; } } -function getdropdown() -{ - d = document.getElementById("PROT").value; - if ( d == 'ICMP' ) - { - document.getElementById('PROTOKOLL').style.display='block'; - } - else - { - document.getElementById('PROTOKOLL').style.display='none'; - } -} END @@ -1604,7 +1625,7 @@ END &Header::openbox('100%', 'left', 'NAT'); print< - $Lang::tr{'fwdfw use nat'} + $Lang::tr{'fwdfw use nat'}
@@ -1638,9 +1659,6 @@ END } print"
$Lang::tr{'fwdfw dnat'}
"; print"


"; - if ($fwdfwsettings{'USE_NAT'} ne 'ON'){ - print""; - } &Header::closebox(); #---TARGET------------------------------------------------------ &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'}); @@ -1670,8 +1688,8 @@ END #---PROTOCOL------------------------------------------------------ &Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'}); print< - END if ($fwdfwsettings{'PROT'} eq ''){ print""; @@ -1687,7 +1705,7 @@ END print""; } } - print""; + print""; print<
$Lang::tr{'fwhost icmptype'}



END - if ($fwdfwsettings{'PROT'} ne 'ICMP'){ - print""; - } #SOURCEPORT print<
- - -
$Lang::tr{'fwdfw use srcport'}
+
+ +
$Lang::tr{'fwdfw use srcport'}
END @@ -1721,14 +1736,11 @@ END
$Lang::tr{'fwdfw man port'}

END - if ($fwdfwsettings{'USE_SRC_PORT'} ne 'ON'){ - print""; - } #TARGETPORT print<
- -
$Lang::tr{'fwdfw use srv'}
+
+
$Lang::tr{'fwdfw use srv'}
$Lang::tr{'fwhost cust service'}


END - if ($fwdfwsettings{'USESRV'} ne 'ON'){ - print""; - } - if ($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){ - print""; - } &Header::closebox; #---Activate/logging/remark------------------------------------- &Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'}); -- 2.39.2