From fda8c915d66a8cabe813cc05afc1f2d560e74fab Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Wed, 16 Oct 2013 14:55:20 +0200 Subject: [PATCH] Firewall: Fixed JQuery code for fwhosts. This is BETA2 base --- html/cgi-bin/fwhosts.cgi | 98 ++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 60 deletions(-) diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi index 9369c22d10..4f909cdf6d 100755 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -88,58 +88,42 @@ unless (-e $configsrvgrp) { system("touch $configsrvgrp"); } #### JAVA SCRIPT #### print< + var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"]; + var update_protocol = function() { + var protocol = \$("#protocol").val(); + + if (protocol === undefined) + return; + + // Check if we are dealing with a protocol, that knows ports. + if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) { + \$("#PORT").show(); + } else { + \$("#PORT").hide(); + } + + // Handle ICMP. + if (protocol === "ICMP") { + \$("#PROTOKOLL").show(); + } else { + \$("#PROTOKOLL").hide(); + } + }; + \$(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); - }); - // When protokol is not ICMP hide icmp-types - if ( \$("#PROT").val() === 'ICMP') { - \$('PROTOKOLL').hide(); - } - // When protocol dropdown is changed, check if we selected icmp - then show icmp-types - \$("#prt").change(function(){ - if ( \$("#PROT").val() === 'ICMP' ){ - \$('PROTOKOLL').show(); - } - else{ - \$('PROTOKOLL').hide(); - } - }); + var protocol = \$("#protocol").val(); + + // Handle ICMP. + if (protocol === "ICMP") { + \$("#PROTOKOLL").show(); + \$("#PORT").hide(); + } else { + \$("#PROTOKOLL").hide(); + \$("#PORT").show(); + } + \$("#protocol").change(update_protocol); + update_protocol(); }); -function hide_elements(){ - var elementNames = hide_elements.arguments; - for (var i=0; i END @@ -1344,9 +1328,9 @@ sub addservice $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'}; } print< +
-
$Lang::tr{'fwhost srv_name'}:
$Lang::tr{'fwhost prot'}:
$Lang::tr{'fwhost prot'}:
+
$Lang::tr{'fwhost icmptype'} END - - }else{ + }else{ print""; } print<
- - END - #if ($fwhostsettings{'PROT'} ne 'ICMP'){ - #print""; - #} &Header::closebox(); &viewtableservice; } -- 2.39.5