From c2feff64bc74812cc5160d3438c9c8c2eed225c0 Mon Sep 17 00:00:00 2001 From: Darren Embry Date: Thu, 5 Apr 2012 19:10:13 -0400 Subject: restore default dropdown values of 24/64 bits now that feature #2320 behavor is a bit different regarding change of existing set value when switching between ipv4 and ipv6 --- usr/local/www/vpn_ipsec_phase2.php | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'usr/local/www/vpn_ipsec_phase2.php') diff --git a/usr/local/www/vpn_ipsec_phase2.php b/usr/local/www/vpn_ipsec_phase2.php index ef246c6..a97f7d5 100644 --- a/usr/local/www/vpn_ipsec_phase2.php +++ b/usr/local/www/vpn_ipsec_phase2.php @@ -296,13 +296,29 @@ function change_mode() { } function typesel_change_local(bits) { + var value = document.iform.mode.options[index].value; + if (typeof(bits) === "undefined") { + if (value === "tunnel") { + bits = 24; + } + else if (value === "tunnel6") { + bits = 64; + } + } + var address_is_blank = !/\S/.test(document.iform.localid_address.value); switch (document.iform.localid_type.selectedIndex) { case 0: /* single */ document.iform.localid_address.disabled = 0; + if (address_is_blank) { + document.iform.localid_netbits.value = 0; + } document.iform.localid_netbits.disabled = 1; break; case 1: /* network */ document.iform.localid_address.disabled = 0; + if (address_is_blank) { + document.iform.localid_netbits.value = bits; + } document.iform.localid_netbits.disabled = 0; break; case 3: /* none */ @@ -312,6 +328,9 @@ function typesel_change_local(bits) { default: document.iform.localid_address.value = ""; document.iform.localid_address.disabled = 1; + if (address_is_blank) { + document.iform.localid_netbits.value = 0; + } document.iform.localid_netbits.disabled = 1; break; } @@ -320,18 +339,37 @@ function typesel_change_local(bits) { function typesel_change_remote(bits) { + var value = document.iform.mode.options[index].value; + if (typeof(bits) === "undefined") { + if (value === "tunnel") { + bits = 24; + } + else if (value === "tunnel6") { + bits = 64; + } + } + var address_is_blank = !/\S/.test(document.iform.remoteid_address.value); switch (document.iform.remoteid_type.selectedIndex) { case 0: /* single */ document.iform.remoteid_address.disabled = 0; + if (address_is_blank) { + document.iform.remoteid_netbits.value = 0; + } document.iform.remoteid_netbits.disabled = 1; break; case 1: /* network */ document.iform.remoteid_address.disabled = 0; + if (address_is_blank) { + document.iform.remoteid_netbits.value = bits; + } document.iform.remoteid_netbits.disabled = 0; break; default: document.iform.remoteid_address.value = ""; document.iform.remoteid_address.disabled = 1; + if (address_is_blank) { + document.iform.remoteid_netbits.value = 0; + } document.iform.remoteid_netbits.disabled = 1; break; } -- cgit v1.1