ipType、ipPattern、portPattern
三个参数变化,动态设置ip和端口默认值
This commit is contained in:
@@ -13,7 +13,19 @@ border:1px solid #eeeeee
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
switchIpType($("select[name$='ipType']"));
|
||||
$("select[name$='ipType']").each(function(){
|
||||
switchIpInfo(this,"ipType");
|
||||
})
|
||||
$("select[name$='ipType']").on("change",function(){
|
||||
switchIpInfo(this,"ipType");
|
||||
});
|
||||
$("select[name$='ipPattern']").on("change",function(){
|
||||
switchIpInfo(this,"ipPattern");
|
||||
});
|
||||
$("select[name$='portPattern']").on("change",function(){
|
||||
switchIpInfo(this,"portPattern");
|
||||
});
|
||||
|
||||
areaControlInit();
|
||||
$("input[name='isAreaEffective']").on('change',function(){
|
||||
var val=$(this).val();
|
||||
@@ -30,9 +42,6 @@ $(function(){
|
||||
$("#areaIsp").addClass("hidden");
|
||||
}
|
||||
});
|
||||
$("select[name$='ipType']").on("change",function(){
|
||||
switchIpType($(this));
|
||||
});
|
||||
$("input[name='areaType']").on('change',function(){
|
||||
var val=$(this).val();
|
||||
if($(this).is(":visible")){
|
||||
@@ -61,6 +70,11 @@ $(function(){
|
||||
},
|
||||
submitHandler: function(form){
|
||||
//loading('onloading...');
|
||||
//代表所有业务都隐藏了,提示必须增加一种业务数据
|
||||
if($(".boxSolid").length ==$(".boxSolid.hidden").length){
|
||||
top.$.jBox.tip("<spring:message code='one_more'/>", "<spring:message code='info'/>");
|
||||
return;
|
||||
}
|
||||
form.submit();
|
||||
},
|
||||
errorContainer: "#messageBox",
|
||||
@@ -221,7 +235,7 @@ var delContent=function(contentClassName,addBtnClassName){
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row ip">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_pattern"/></label>
|
||||
@@ -235,25 +249,7 @@ var delContent=function(contentClassName,addBtnClassName){
|
||||
<div for="voipIps[${status.index }].ipPattern"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="client_ip"/></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required" type="text" name="voipIps[${status.index }].srcIpAddress" value="${voipIp.srcIpAddress}">
|
||||
</div>
|
||||
<div for="voipIps[${status.index }].srcIpAddress"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<c:choose>
|
||||
<c:when test="${voipIp.cfgId==null}">
|
||||
<div class="row hidden port">
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div class="row port">
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="port_pattern"/></label>
|
||||
<div class="col-md-6">
|
||||
@@ -265,6 +261,17 @@ var delContent=function(contentClassName,addBtnClassName){
|
||||
<div for="voipIps[${status.index }].portPattern"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="client_ip"/></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required ipCheck" type="text" name="voipIps[${status.index }].srcIpAddress" value="${voipIp.srcIpAddress}">
|
||||
</div>
|
||||
<div for="voipIps[${status.index }].srcIpAddress"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="client_port"/></label>
|
||||
@@ -277,10 +284,10 @@ var delContent=function(contentClassName,addBtnClassName){
|
||||
</div>
|
||||
<c:choose>
|
||||
<c:when test="${voipIp.cfgId==null}">
|
||||
<div class="row hidden destIpPort">
|
||||
<div class="row hidden port">
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div class="row destIpPort">
|
||||
<div class="row port">
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
<div class="col-md-6">
|
||||
|
||||
@@ -54,6 +54,163 @@ var switchIpType=function(obj){
|
||||
}
|
||||
}
|
||||
}
|
||||
//ipType、ipPattern、portPattern选项变化时调用此方法,添加默认值
|
||||
var switchIpInfo=function(obj,type){
|
||||
var ipType="";
|
||||
var ipPattern="";
|
||||
var portPattern="";
|
||||
|
||||
var row=$(obj).parents('.row');
|
||||
|
||||
if(type=="ipType"){
|
||||
ipType=$(obj).val();
|
||||
ipPattern=row.siblings().find("select[name$='ipPattern']").val();
|
||||
portPattern=row.siblings().find("select[name$='portPattern']").val();
|
||||
}
|
||||
if(type=="ipPattern"){
|
||||
ipType=row.siblings().find("select[name$='ipType']").val();
|
||||
ipPattern=$(obj).val();
|
||||
portPattern=row.siblings().find("select[name$='portPattern']").val();
|
||||
}
|
||||
if(type=="portPattern"){
|
||||
ipType=row.siblings().find("select[name$='ipType']").val();
|
||||
ipPattern=row.siblings().find("select[name$='ipPattern']").val();
|
||||
portPattern=$(obj).val();
|
||||
}
|
||||
|
||||
var srcIp=row.siblings().find("input[name$='srcIpAddress']");
|
||||
var destIp=row.siblings().find("input[name$='destIpAddress']");
|
||||
var srcPort=row.siblings().find("input[name$='srcPort']");
|
||||
var destPort=row.siblings().find("input[name$='destPort']");
|
||||
|
||||
var ipV4Default=new Array();
|
||||
ipV4Default[0]="0.0.0.0/8"; //subnet
|
||||
ipV4Default[1]="0.0.0.0-1.1.1.1";//ip_range
|
||||
ipV4Default[2]="0.0.0.0"; //ip
|
||||
|
||||
var ipV6Default=new Array();
|
||||
ipV6Default[0]="::/64"; //subnet
|
||||
ipV6Default[1]="::-::";//ip_range
|
||||
ipV6Default[2]="::"; //ip
|
||||
|
||||
var portDefault=new Array();
|
||||
portDefault[0]="0";//port
|
||||
portDefault[1]="0/0";//port_mask
|
||||
|
||||
//IPv4设置默认值
|
||||
if(4==ipType){
|
||||
if(!$(srcIp).val()){
|
||||
if(ipPattern==1){
|
||||
$(srcIp).val(ipV4Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(srcIp).val(ipV4Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(srcIp).val(ipV4Default[2]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(srcIp).val(),ipV4Default) > -1 || $.inArray($(srcIp).val(),ipV6Default) > -1){ //是ipV4的默认值其中一个
|
||||
if(ipPattern==1){
|
||||
$(srcIp).val(ipV4Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(srcIp).val(ipV4Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(srcIp).val(ipV4Default[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$(destIp).val()){
|
||||
if(ipPattern==1){
|
||||
$(destIp).val(ipV4Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(destIp).val(ipV4Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(destIp).val(ipV4Default[2]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(destIp).val(),ipV4Default) > -1 || $.inArray($(destIp).val(),ipV6Default) > -1){ //是ipV4的默认值其中一个
|
||||
if(ipPattern==1){
|
||||
$(destIp).val(ipV4Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(destIp).val(ipV4Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(destIp).val(ipV4Default[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(6==ipType){
|
||||
if(!$(srcIp).val()){
|
||||
if(ipPattern==1){
|
||||
$(srcIp).val(ipV6Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(srcIp).val(ipV6Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(srcIp).val(ipV6Default[2]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(srcIp).val(),ipV4Default) > -1 || $.inArray($(srcIp).val(),ipV6Default) > -1){ //是ipV6的默认值其中一个
|
||||
if(ipPattern==1){
|
||||
$(srcIp).val(ipV6Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(srcIp).val(ipV6Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(srcIp).val(ipV6Default[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!$(destIp).val()){
|
||||
if(ipPattern==1){
|
||||
$(destIp).val(ipV6Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(destIp).val(ipV6Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(destIp).val(ipV6Default[2]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(destIp).val(),ipV4Default) > -1 || $.inArray($(destIp).val(),ipV6Default) > -1){ //是ipV6的默认值其中一个
|
||||
if(ipPattern==1){
|
||||
$(destIp).val(ipV6Default[0]);
|
||||
}else if(ipPattern==2){
|
||||
$(destIp).val(ipV6Default[1]);
|
||||
}else if(ipPattern==3){
|
||||
$(destIp).val(ipV6Default[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//设置源端口默认值
|
||||
if(!$(srcPort).val()){
|
||||
if(portPattern==1){
|
||||
$(srcPort).val(portDefault[0]);
|
||||
}else if(portPattern==2){
|
||||
$(srcPort).val(portDefault[1]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(srcPort).val(),portDefault) > -1){ //是ipV4的默认值其中一个
|
||||
if(portPattern==1){
|
||||
$(srcPort).val(portDefault[0]);
|
||||
}else if(portPattern==2){
|
||||
$(srcPort).val(portDefault[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
//设置目的端口默认值
|
||||
if(!$(destPort).val()){
|
||||
if(portPattern==1){
|
||||
$(destPort).val(portDefault[0]);
|
||||
}else if(portPattern==2){
|
||||
$(destPort).val(portDefault[1]);
|
||||
}
|
||||
}else{
|
||||
if($.inArray($(destPort).val(),portDefault) > -1){ //是port的默认值其中一个
|
||||
if(portPattern==1){
|
||||
$(destPort).val(portDefault[0]);
|
||||
}else if(portPattern==2){
|
||||
$(destPort).val(portDefault[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var areaControlInit=function(){
|
||||
if($("input[name='isAreaEffective']:checked").val()==1){
|
||||
$(".areaType").removeClass("hidden");
|
||||
@@ -87,10 +244,6 @@ var more=function(obj){
|
||||
$(obj).data("click-times",clickTimes+1);
|
||||
}
|
||||
if(clickTimes==1){
|
||||
$(".destIpPort").removeClass("hidden").removeClass("disabled");
|
||||
$(obj).data("click-times",clickTimes+1);
|
||||
}
|
||||
if(clickTimes==2){
|
||||
$(".protocol").removeClass("hidden").removeClass("disabled");
|
||||
$(obj).data("click-times",clickTimes+1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user