firewall_nat_edit.js 7.69 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
//<![CDATA[
var portsenabled = 1;
var dstenabled = 1;
var showsource = 0;

function ext_change() {
	if ((document.iform.srcbeginport.selectedIndex == 0) && portsenabled) {
		document.iform.srcbeginport_cust.disabled = 0;
	} else {
		document.iform.srcbeginport_cust.value = "";
		document.iform.srcbeginport_cust.disabled = 1;
	}
	if ((document.iform.srcendport.selectedIndex == 0) && portsenabled) {
		document.iform.srcendport_cust.disabled = 0;
	} else {
		document.iform.srcendport_cust.value = "";
		document.iform.srcendport_cust.disabled = 1;
	}
	if ((document.iform.dstbeginport.selectedIndex == 0) && portsenabled && dstenabled) {
		document.iform.dstbeginport_cust.disabled = 0;
	} else {
		document.iform.dstbeginport_cust.value = "";
		document.iform.dstbeginport_cust.disabled = 1;
	}
	if ((document.iform.dstendport.selectedIndex == 0) && portsenabled && dstenabled) {
		document.iform.dstendport_cust.disabled = 0;
	} else {
		document.iform.dstendport_cust.value = "";
		document.iform.dstendport_cust.disabled = 1;
	}

	if ((document.iform.localbeginport.selectedIndex == 0) && portsenabled) {
		document.iform.localbeginport_cust.disabled = 0;
	} else {
		document.iform.localbeginport_cust.value = "";
		document.iform.localbeginport_cust.disabled = 1;
	}

	if (!portsenabled) {
		document.iform.srcbeginport.disabled = 1;
		document.iform.srcendport.disabled = 1;
		document.iform.dstbeginport.disabled = 1;
		document.iform.dstendport.disabled = 1;
		document.iform.localbeginport_cust.disabled = 1;
	} else {
		document.iform.srcbeginport.disabled = 0;
		document.iform.srcendport.disabled = 0;
		document.iform.localbeginport_cust.disabled = 0;
		if( dstenabled ) {
			document.iform.dstbeginport.disabled = 0;
			document.iform.dstendport.disabled = 0;
		}
	}
}

function nordr_change() {
	if (document.iform.nordr.checked) {
		document.getElementById("localiptable").style.display = 'none';
		document.getElementById("lprtr").style.display = 'none';
		document.getElementById("assoctable").style.display = 'none';
	} else {
		document.getElementById("localiptable").style.display = '';
		document.getElementById("lprtr").style.display = portsenabled ? '' : 'none';
		document.getElementById("assoctable").style.display = '';
	}
}

function show_source() {
	if(portsenabled)
		document.getElementById("sprtable").style.display = '';

	document.getElementById("srctable").style.display = '';
	document.getElementById("showadvancedboxsrc").style.display = 'none';
	showsource = 1;
}

function check_for_aliases() {
	/*  if External port range is an alias, then disallow
	 *  entry of Local port
	 */
	for(i=0; i<customarray.length; i++) {
		if(document.iform.dstbeginport_cust.value == customarray[i]) {
			document.iform.dstendport_cust.value = customarray[i];
			document.iform.localbeginport_cust.value = customarray[i];
			document.iform.dstendport_cust.disabled = 1;
			document.iform.localbeginport.disabled = 1;
			document.iform.localbeginport_cust.disabled = 1;
			document.iform.dstendport_cust.disabled = 0;
			document.iform.localbeginport.disabled = 0;
			document.iform.localbeginport_cust.disabled = 0;
		}
		if(document.iform.dstbeginport.value == customarray[i]) {
			document.iform.dstendport_cust.value = customarray[i];
			document.iform.localbeginport_cust.value = customarray[i];
			document.iform.dstendport_cust.disabled = 1;
			document.iform.localbeginport.disabled = 1;
			document.iform.localbeginport_cust.disabled = 1;
			document.iform.dstendport_cust.disabled = 0;
			document.iform.localbeginport.disabled = 0;
			document.iform.localbeginport_cust.disabled = 0;
		}
		if(document.iform.dstendport_cust.value == customarray[i]) {
			document.iform.dstendport_cust.value = customarray[i];
			document.iform.localbeginport_cust.value = customarray[i];
			document.iform.dstendport_cust.disabled = 1;
			document.iform.localbeginport.disabled = 1;
			document.iform.localbeginport_cust.disabled = 1;
			document.iform.dstendport_cust.disabled = 0;
			document.iform.localbeginport.disabled = 0;
			document.iform.localbeginport_cust.disabled = 0;
		}
		if(document.iform.dstendport.value == customarray[i]) {
			document.iform.dstendport_cust.value = customarray[i];
			document.iform.localbeginport_cust.value = customarray[i];
			document.iform.dstendport_cust.disabled = 1;
			document.iform.localbeginport.disabled = 1;
			document.iform.localbeginport_cust.disabled = 1;
			document.iform.dstendport_cust.disabled = 0;
			document.iform.localbeginport.disabled = 0;
			document.iform.localbeginport_cust.disabled = 0;
		}

	}
}

function proto_change() {
	if (document.iform.proto.selectedIndex >= 0 && document.iform.proto.selectedIndex <= 2) {
		portsenabled = 1;
	} else {
		portsenabled = 0;
	}

	if (portsenabled) {
		document.getElementById("sprtable").style.display = showsource == 1 ? '':'none';
		document.getElementById("dprtr").style.display = '';
		document.getElementById("lprtr").style.display = document.iform.nordr.checked ? 'none' : '';
	} else {
		document.getElementById("sprtable").style.display = 'none';
		document.getElementById("dprtr").style.display = 'none';
		document.getElementById("lprtr").style.display = 'none';
		document.getElementById("dstbeginport").selectedIndex = 0;
		document.getElementById("dstbeginport_cust").value = "";
		document.getElementById("dstendport").selectedIndex = 0;
		document.getElementById("dstendport_cust").value = "";
		document.getElementById("localbeginport").selectedIndex = 0;
		document.getElementById("localbeginport_cust").value = "";
	}
}

function typesel_change() {
	switch (document.iform.srctype.selectedIndex) {
		case 1:	/* single */
			document.iform.src.disabled = 0;
154 155 156 157 158
			//document.iform.srcmask.value = "";
			//document.iform.srcmask.disabled = 1;
			jQuery('#srcmask').selectpicker('val','');
			jQuery('#srcmask').prop('disabled',true);
			jQuery('#srcmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
159 160 161
			break;
		case 2:	/* network */
			document.iform.src.disabled = 0;
162 163 164
			//document.iform.srcmask.disabled = 0;
			jQuery('#srcmask').prop('disabled',false);
			jQuery('#srcmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
165 166 167 168
			break;
		default:
			document.iform.src.value = "";
			document.iform.src.disabled = 1;
169 170 171 172
			//document.iform.srcmask.value = "";
			//document.iform.srcmask.disabled = 1;
			jQuery('#srcmask').selectpicker('val','');
			jQuery('#srcmask').prop('disabled',true);
173
			jQuery('#srcmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
174 175 176 177 178 179 180 181 182
			break;
	}
	if( dstenabled )
	{
		switch (document.iform.dsttype.selectedIndex) {
			case 1:	/* single */
				document.iform.dst.disabled = 0;
				document.iform.dstmask.value = "";
				document.iform.dstmask.disabled = 1;
183 184 185
				jQuery('#dstmask').selectpicker('val','');
				jQuery('#dstmask').prop('disabled',true);
				jQuery('#dstmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
186 187 188
				break;
			case 2:	/* network */
				document.iform.dst.disabled = 0;
189 190 191
				//document.iform.dstmask.disabled = 0;
				jQuery('#dstmask').prop('disabled',false);
				jQuery('#dstmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
192 193 194 195
				break;
			default:
				document.iform.dst.value = "";
				document.iform.dst.disabled = 1;
196 197 198 199 200
				//document.iform.dstmask.value = "";
				//document.iform.dstmask.disabled = 1;
				jQuery('#dstmask').selectpicker('val','');
				jQuery('#dstmask').prop('disabled',true);
				jQuery('#dstmask').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
201 202 203 204 205 206 207
				break;
		}
	}
}

function src_rep_change() {
	document.iform.srcendport.selectedIndex = document.iform.srcbeginport.selectedIndex;
208
	jQuery('.selectpicker').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
209 210 211 212
}

function dst_rep_change() {
	document.iform.dstendport.selectedIndex = document.iform.dstbeginport.selectedIndex;
213
	jQuery('.selectpicker').selectpicker('refresh');
Ad Schellevis's avatar
Ad Schellevis committed
214 215 216 217 218 219 220 221
}

function dst_change( iface, old_iface, old_dst ) {
	if ( ( old_dst == "" ) || ( old_iface.concat("ip") == old_dst ) ) {
		document.iform.dsttype.value = iface.concat("ip");
	}
}
//]]>