修复indexOf异常

This commit is contained in:
wangxin
2018-08-20 20:49:40 +08:00
parent bfb5d0f476
commit 738099ca4e

View File

@@ -368,14 +368,14 @@ $(function(){
regionCode=$("input[name='action']").attr("regionCode"); regionCode=$("input[name='action']").attr("regionCode");
} }
if(regionCode){ if(regionCode){
$("[id='cfgRegionCode']").each(function(){ $("[id^='cfgRegionCode']").each(function(){
if($(this).attr("id")==("cfgRegionCode"+regionCode)){ if($(this).attr("id")==("cfgRegionCode"+regionCode)){
$(this).attr("name","cfgRegionCode"); $(this).attr("name","cfgRegionCode");
}else{ }else{
$(this).removeAttr("name"); $(this).removeAttr("name");
} }
}); });
$("[id='cfgType']").each(function(){ $("[id^='cfgType']").each(function(){
if($(this).attr("id")==("cfgType"+regionCode)){ if($(this).attr("id")==("cfgType"+regionCode)){
$(this).attr("name","cfgType"); $(this).attr("name","cfgType");
}else{ }else{
@@ -389,155 +389,150 @@ $(function(){
direction=$("input[name='cfgRegionCode']").attr("direction"), direction=$("input[name='cfgRegionCode']").attr("direction"),
protocol=$("input[name='cfgRegionCode']").attr("protocol"); protocol=$("input[name='cfgRegionCode']").attr("protocol");
//ip端口处理 //ip端口处理
if(ipPortShow.indexOf('1')>-1){//展示源IP,端口 if(ipPortShow){
$("input[name='srcIpAddress']").parents(".form-group").removeClass("hidden"); if(ipPortShow.indexOf('1')>-1){//展示源IP,端口
$("input[name='srcPort']").parents(".form-group").removeClass("hidden"); $("input[name='srcIpAddress']").parents(".form-group").removeClass("hidden");
}else{ $("input[name='srcPort']").parents(".form-group").removeClass("hidden");
$("input[name='srcIpAddress']").parents(".form-group").addClass("hidden"); }else{
$("input[name='srcPort']").parents(".form-group").addClass("hidden"); $("input[name='srcIpAddress']").parents(".form-group").addClass("hidden");
$("input[name='srcPort']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('2')>-1){//展示目的IP,端口
$("input[name='destIpAddress']").parents(".form-group").removeClass("hidden");
$("input[name='destPort']").parents(".form-group").removeClass("hidden");
}else{
$("input[name='destIpAddress']").parents(".form-group").addClass("hidden");
$("input[name='destPort']").parents(".form-group").addClass("hidden");
}
} }
if(ipPortShow.indexOf('2')>-1){//展示目的IP,端口 if(ipType){
$("input[name='destIpAddress']").parents(".form-group").removeClass("hidden"); var arr=ipType.split(',');
$("input[name='destPort']").parents(".form-group").removeClass("hidden"); $("select[name='ipType'] option").each(function(){
}else{ var has=false;
$("input[name='destIpAddress']").parents(".form-group").addClass("hidden"); for(var type in arr){
$("input[name='destPort']").parents(".form-group").addClass("hidden"); if($(this).val()==arr[type]){
} has=true;
var arr=ipType.split(','); if($(this).attr("disabled")){
$("select[name='ipType'] option").each(function(){ $(this).removeAttr("disabled")
var has=false; }
for(var type in arr){ break;
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
} }
break;
} }
} if(!has){
if(!has){ $(this).attr("disabled",true);
$(this).attr("disabled",true);
}
});
arr=ipPattern.split(',');
$("select[name='ipPattern'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
arr=portPattern.split(',');
$("select[name='portPattern'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
arr=direction.split(',');
$("select[name='direction'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
arr=protocol.split(',');
$("select[name='protocol'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
//处理自定义字段
var serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType");
/*if(serviceType.indexOf("ipaddr")>-1){
if($(this).val()==32){
if($("[name='protocol']").find("option[value='1']").length==0){
$("[name='protocol']").append('<option class="icmp" value="1" <c:if test="${_cfg.protocol==1}">selected</c:if>><spring:message code="ICMP"/></option>');
}
}else{
if($("[name='protocol'] option[value='1']")){
if($("[name='protocol'] option[value='1']").is(":selected")){
$("[name='protocol'] option[value='1']").removeAttr("selected");
$("[name='protocol']").val(0);
}
$("[name='protocol'] option[value='1']").remove();
}
}
$("[name='protocol']").selectpicker("render");
$("[name='protocol']").selectpicker("refresh");
}*/
if(serviceType.indexOf("ipaddr")>-1){
if($(this).val()==32){
$("select[name='protocol'] option").each(function(){
if($(this).attr("value")==32){
$(this).removeAttr("disabled");
} }
}); });
}else{
} }
} if(ipPattern){
if(serviceType.indexOf("ipmulitiplex")>-1){ arr=ipPattern.split(',');
$(".ipmulitiplex").removeClass("hidden"); $("select[name='ipPattern'] option").each(function(){
}else{ var has=false;
$(".ipmulitiplex").addClass("hidden"); for(var type in arr){
} if($(this).val()==arr[type]){
if(serviceType.indexOf("ratelimit")>-1){ has=true;
if($(this).val()==64){ if($(this).attr("disabled")){
$(".ratelimit").removeClass("hidden"); $(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
}
if(portPattern){
arr=portPattern.split(',');
$("select[name='portPattern'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
}
if(direction){
arr=direction.split(',');
$("select[name='direction'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
}
if(protocol){
arr=protocol.split(',');
$("select[name='protocol'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
}
//处理自定义字段
var serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType");
if(serviceType){
if(serviceType.indexOf("ipaddr")>-1){
if($(this).val()==32){
$("select[name='protocol'] option").each(function(){
if($(this).attr("value")==1){
$(this).removeAttr("disabled");
}
});
}
}
if(serviceType.indexOf("ipmulitiplex")>-1){
$(".ipmulitiplex").removeClass("hidden");
}else{
$(".ipmulitiplex").addClass("hidden");
}
if(serviceType.indexOf("ratelimit")>-1){
if($(this).val()==64){
$(".ratelimit").removeClass("hidden");
}else{
$(".ratelimit").addClass("hidden");
}
}else{ }else{
$(".ratelimit").addClass("hidden"); $(".ratelimit").addClass("hidden");
} }
}else{ if($(this).val()==0x20||$(this).val()==0x60){
$(".ratelimit").addClass("hidden"); $("input[name='isAreaEffective']").each(function(){
} if($(this).val()==0){
if($(this).val()==0x20||$(this).val()==0x60){ $(this).click();
$("input[name='isAreaEffective']").each(function(){ }
if($(this).val()==0){ })
$(this).click(); }
}
})
} }
} }
}); });
//选择hex cfgkeywords需校验十六进制 //选择hex cfgkeywords需校验十六进制
$("select[name$='isHexbin']").each(function(){ $("select[name$='isHexbin']").each(function(){
@@ -1369,40 +1364,47 @@ var initCommIpVal=function(){
if($("input[name='action']:checked").length>0){ if($("input[name='action']:checked").length>0){
regionCode=$("input[name='action']:checked").attr("regionCode"); regionCode=$("input[name='action']:checked").attr("regionCode");
serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType"); serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType");
if(serviceType.indexOf("ipaddr")>-1&&$("input[name='action']:checked").val()==32){
$("[name='protocol']").append('<option class="icmp" value="1" <c:if test="${_cfg.protocol==1}">selected</c:if>><spring:message code="ICMP"/></option>');
$("[name='protocol']").selectpicker("render");
$("[name='protocol']").selectpicker("refresh");
}
}else{ }else{
regionCode=$("input[name='action']").attr("regionCode"); regionCode=$("input[name='action']").attr("regionCode");
serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType"); serviceType=$("#cfgRegionCode"+regionCode).attr("serviceType");
if(serviceType.indexOf("ipaddr")>-1&&$("input[name='action']").val()==32){ }
$("[name='protocol']").append('<option class="icmp" value="1" <c:if test="${_cfg.protocol==1}">selected</c:if>><spring:message code="ICMP"/></option>'); if(serviceType){
$("[name='protocol']").selectpicker("render"); if(serviceType.indexOf("ipaddr")>-1&&$("input[name='action']:checked").val()==32){
$("[name='protocol']").selectpicker("refresh"); $("select[name='protocol'] option").each(function(){
if($(this).attr("value")==1){
$(this).removeAttr("disabled");
}
});
} }
} if(serviceType&&serviceType.indexOf("ipaddr")>-1&&$("input[name='action']").val()==32){
if(serviceType.indexOf("ipmulitiplex")>-1){ $("select[name='protocol'] option").each(function(){
$(".ipmulitiplex").removeClass("hidden"); if($(this).attr("value")==1){
$("input[name='isAreaEffective']").each(function(){ $(this).removeAttr("disabled");
if($(this).val()==0){ }
$(this).click(); });
}
if(serviceType.indexOf("ipmulitiplex")>-1){
$(".ipmulitiplex").removeClass("hidden");
$("input[name='isAreaEffective']").each(function(){
if($(this).val()==0){
$(this).click();
}
})
$(".areaInfo").addClass("hidden");
}else{
$(".areaInfo").removeClass("hidden");
$(".ipmulitiplex").addClass("hidden");
}
if(serviceType.indexOf("ratelimit")>-1){
if($("input[name='action']").val()==64||$("input[name='action']:checked").val()==64){
$(".ratelimit").removeClass("hidden");
}else{
$(".ratelimit").addClass("hidden");
} }
})
$(".areaInfo").addClass("hidden");
}else{
$(".areaInfo").removeClass("hidden");
$(".ipmulitiplex").addClass("hidden");
}
if(serviceType.indexOf("ratelimit")>-1){
if($("input[name='action']").val()==64||$("input[name='action']:checked").val()==64){
$(".ratelimit").removeClass("hidden");
}else{ }else{
$(".ratelimit").addClass("hidden"); $(".ratelimit").addClass("hidden");
} }
}else{
$(".ratelimit").addClass("hidden");
} }
$("#cfgRegionCode"+regionCode).attr("name","cfgRegionCode"); $("#cfgRegionCode"+regionCode).attr("name","cfgRegionCode");
$("#cfgType"+regionCode).attr("name","cfgType"); $("#cfgType"+regionCode).attr("name","cfgType");
@@ -1420,99 +1422,111 @@ var initCommIpVal=function(){
direction=$("input[name='cfgRegionCode']").attr("direction"), direction=$("input[name='cfgRegionCode']").attr("direction"),
protocol=$("input[name='cfgRegionCode']").attr("protocol"); protocol=$("input[name='cfgRegionCode']").attr("protocol");
//ip端口处理 //ip端口处理
if(ipPortShow.indexOf('1')>-1){//展示源IP,端口 if(ipPortShow){
$("input[name='srcIpAddress']").parents(".form-group").removeClass("hidden"); if(ipPortShow.indexOf('1')>-1){//展示源IP,端口
$("input[name='srcPort']").parents(".form-group").removeClass("hidden"); $("input[name='srcIpAddress']").parents(".form-group").removeClass("hidden");
}else{ $("input[name='srcPort']").parents(".form-group").removeClass("hidden");
$("input[name='srcIpAddress']").parents(".form-group").addClass("hidden"); }else{
$("input[name='srcPort']").parents(".form-group").addClass("hidden"); $("input[name='srcIpAddress']").parents(".form-group").addClass("hidden");
$("input[name='srcPort']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('2')>-1){//展示目的IP,端口
$("input[name='destIpAddress']").parents(".form-group").removeClass("hidden");
$("input[name='destPort']").parents(".form-group").removeClass("hidden");
}else{
$("input[name='destIpAddress']").parents(".form-group").addClass("hidden");
$("input[name='destPort']").parents(".form-group").addClass("hidden");
}
} }
if(ipPortShow.indexOf('2')>-1){//展示目的IP,端口 if(ipType){
$("input[name='destIpAddress']").parents(".form-group").removeClass("hidden"); var arr=ipType.split(',');
$("input[name='destPort']").parents(".form-group").removeClass("hidden"); $("select[name='ipType'] option").each(function(){
}else{ var has=false;
$("input[name='destIpAddress']").parents(".form-group").addClass("hidden"); for(var type in arr){
$("input[name='destPort']").parents(".form-group").addClass("hidden"); if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).attr("disabled",true);
}
});
} }
var arr=ipType.split(','); if(ipPattern){
$("select[name='ipType'] option").each(function(){ arr=ipPattern.split(',');
var has=false; $("select[name='ipPattern'] option").each(function(){
for(var type in arr){ var has=false;
if($(this).val()==arr[type]){ for(var type in arr){
has=true; if($(this).val()==arr[type]){
if($(this).attr("disabled")){ has=true;
$(this).removeAttr("disabled") if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
} }
break;
} }
} if(!has){
if(!has){ $(this).attr("disabled",true);
$(this).attr("disabled",true); }
} });
}); }
arr=ipPattern.split(','); if(portPattern){
$("select[name='ipPattern'] option").each(function(){ arr=portPattern.split(',');
var has=false; $("select[name='portPattern'] option").each(function(){
for(var type in arr){ var has=false;
if($(this).val()==arr[type]){ for(var type in arr){
has=true; if($(this).val()==arr[type]){
if($(this).attr("disabled")){ has=true;
$(this).removeAttr("disabled") if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
} }
break;
} }
} if(!has){
if(!has){ $(this).attr("disabled",true);
$(this).attr("disabled",true); }
} });
}); }
arr=portPattern.split(','); if(direction){
$("select[name='portPattern'] option").each(function(){ arr=direction.split(',');
var has=false; $("select[name='direction'] option").each(function(){
for(var type in arr){ var has=false;
if($(this).val()==arr[type]){ for(var type in arr){
has=true; if($(this).val()==arr[type]){
if($(this).attr("disabled")){ has=true;
$(this).removeAttr("disabled") if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
} }
break;
} }
} if(!has){
if(!has){ $(this).attr("disabled",true);
$(this).attr("disabled",true); }
} });
}); }
arr=direction.split(','); if(protocol){
$("select[name='direction'] option").each(function(){ arr=protocol.split(',');
var has=false; $("select[name='protocol'] option").each(function(){
for(var type in arr){ var has=false;
if($(this).val()==arr[type]){ for(var type in arr){
has=true; if($(this).val()==arr[type]){
if($(this).attr("disabled")){ has=true;
$(this).removeAttr("disabled") if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
} }
break;
} }
} if(!has){
if(!has){ $(this).attr("disabled",true);
$(this).attr("disabled",true);
}
});
arr=protocol.split(',');
$("select[name='protocol'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
} }
} });
if(!has){ }
$(this).attr("disabled",true);
}
});
return regionCode; return regionCode;
} }