From b1aa38049665c6e5df85f5b0b8634e95a8584355 Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 22 Sep 2012 23:26:35 +0200 Subject: changed "Firewall: Virtual IP Address: Edit" page to always have the same options available (if applicable) for IPalias/CARP/ProxyArp/other --- usr/local/www/firewall_virtual_ip_edit.php | 147 ++++++++++++----------------- 1 file changed, 60 insertions(+), 87 deletions(-) (limited to 'usr/local/www/firewall_virtual_ip_edit.php') diff --git a/usr/local/www/firewall_virtual_ip_edit.php b/usr/local/www/firewall_virtual_ip_edit.php index f91fa79..6b7d6ef 100755 --- a/usr/local/www/firewall_virtual_ip_edit.php +++ b/usr/local/www/firewall_virtual_ip_edit.php @@ -276,97 +276,71 @@ function get_radio_value(obj) } return null; } -function enable_change(enable_over) { - var note = document.getElementById("typenote"); - var carpnote = document.createTextNode(""); - var proxyarpnote = document.createTextNode(""); - var ipaliasnote = document.createTextNode(""); - if ((get_radio_value(document.iform.mode) == "carp") || enable_over) { - document.iform.vhid.disabled = 0; - document.iform.password.disabled = 0; - document.iform.advskew.disabled = 0; - document.iform.advbase.disabled = 0; - document.iform.type.disabled = 1; - document.iform.subnet_bits.disabled = 0; +function set_note(noteMessage){ + var note = document.getElementById("typenote"); + if (note.firstChild != null) + note.removeChild(note.firstChild); + if (noteMessage) + note.appendChild(noteMessage); +} +function enable_change() { + var carpnote = document.createTextNode(""); + var proxyarpnote = document.createTextNode(""); + var ipaliasnote = document.createTextNode(""); + + $mode = get_radio_value(document.iform.mode); + + document.iform.password.disabled = $mode != "carp"; + document.iform.vhid.disabled = $mode != "carp"; + document.iform.advskew.disabled = $mode != "carp"; + document.iform.advbase.disabled = $mode != "carp"; + document.iform.type.disabled = $mode in {"carp":1,"ipalias":1}; + + if ($mode in {"carp":1,"ipalias":1}) + document.iform.type.selectedIndex = 0;// single-adress + switch($mode) + { + case "carp" : set_note(carpnote); break; + case "ipalias" : set_note(ipaliasnote); break; + case "proxyarp": set_note(proxyarpnote); break; + default: set_note(undefined); + } + typesel_change(); +} + +function typesel_change() { + switch (document.iform.type.selectedIndex) { + case 0: // single document.iform.subnet.disabled = 0; + document.iform.subnet_bits.disabled = (get_radio_value(document.iform.mode) == "proxyarp") || (get_radio_value(document.iform.mode) == "other"); document.iform.noexpand.disabled = 1; jQuery('#noexpandrow').css('display','none'); - if (note.firstChild == null) { - note.appendChild(carpnote); - } else { - note.removeChild(note.firstChild); - note.appendChild(carpnote); - } - } else { - document.iform.vhid.disabled = 1; - document.iform.password.disabled = 1; - document.iform.advskew.disabled = 1; - document.iform.advbase.disabled = 1; - document.iform.type.disabled = 0; - document.iform.subnet_bits.disabled = 1; + break; + case 1: // network document.iform.subnet.disabled = 0; + document.iform.subnet_bits.disabled = 0; document.iform.noexpand.disabled = 0; jQuery('#noexpandrow').css('display',''); - if (note.firstChild == null) { - note.appendChild(proxyarpnote); - } else { - note.removeChild(note.firstChild); - note.appendChild(proxyarpnote); - } - } - if (get_radio_value(document.iform.mode) == "other") { - document.iform.type.disabled = 1; - if (note.firstChild != null) { - note.removeChild(note.firstChild); - } - document.iform.subnet.disabled = 0; + //document.iform.range_from.disabled = 1; + //document.iform.range_to.disabled = 1; + break; + case 2: // range + document.iform.subnet.disabled = 1; + document.iform.subnet_bits.disabled = 1; document.iform.noexpand.disabled = 1; jQuery('#noexpandrow').css('display','none'); - } - if (get_radio_value(document.iform.mode) == "ipalias") { - document.iform.type.disabled = 1; - note.removeChild(note.firstChild); - note.appendChild(ipaliasnote); + //document.iform.range_from.disabled = 0; + //document.iform.range_to.disabled = 0; + break; + case 3: // IP alias + document.iform.subnet.disabled = 1; document.iform.subnet_bits.disabled = 0; - document.iform.subnet.disabled = 0; document.iform.noexpand.disabled = 1; jQuery('#noexpandrow').css('display','none'); + //document.iform.range_from.disabled = 0; + //document.iform.range_to.disabled = 0; + break; } - typesel_change(); -} -function typesel_change() { - switch (document.iform.type.selectedIndex) { - case 0: // single - document.iform.subnet.disabled = 0; - if((get_radio_value(document.iform.mode) == "proxyarp")) document.iform.subnet_bits.disabled = 1; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - break; - case 1: // network - document.iform.subnet.disabled = 0; - document.iform.subnet_bits.disabled = 0; - document.iform.noexpand.disabled = 0; - jQuery('#noexpandrow').css('display',''); - //document.iform.range_from.disabled = 1; - //document.iform.range_to.disabled = 1; - break; - case 2: // range - document.iform.subnet.disabled = 1; - document.iform.subnet_bits.disabled = 1; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - //document.iform.range_from.disabled = 0; - //document.iform.range_to.disabled = 0; - break; - case 3: // IP alias - document.iform.subnet.disabled = 1; - document.iform.subnet_bits.disabled = 0; - document.iform.noexpand.disabled = 1; - jQuery('#noexpandrow').css('display','none'); - //document.iform.range_from.disabled = 0; - //document.iform.range_to.disabled = 0; - break; - } } //--> @@ -380,14 +354,14 @@ function typesel_change() { - > - > + > - > + > - > @@ -526,8 +500,7 @@ function typesel_change() { -- cgit v1.1