ip属性共用值提取为一个全局的函数,当initCommIpVal执行的时候初始化ipcommon的属性,并且初始化完成之后将页面无用的select
option直接remove
This commit is contained in:
@@ -67,10 +67,14 @@
|
||||
}
|
||||
//处理ICMP
|
||||
if($(this).val()==32){
|
||||
tabInfo.find("select[name$='protocol'] option[value='1']").removeAttr("disabled");
|
||||
$.ipcommon.protocol.each(function(){
|
||||
if($(this).attr("value")==1){
|
||||
tabInfo.find("select[name$='protocol']").append($(this));
|
||||
}
|
||||
})
|
||||
tabInfo.find("select[name$='protocol']").selectpicker("refresh");
|
||||
}else{
|
||||
tabInfo.find("select[name$='protocol'] option[value='1']").attr("disabled",true);
|
||||
tabInfo.find("select[name$='protocol'] option[value='1']").remove();
|
||||
tabInfo.find("select[name$='protocol']").selectpicker("refresh");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
$(function(){
|
||||
//扩展jquery,增加全局函数
|
||||
$.ipcommon=function(){
|
||||
return {};
|
||||
}
|
||||
$.extend($.ipcommon, {
|
||||
ipType:[],
|
||||
ipPattern:[],
|
||||
portPattern:[],
|
||||
protocol:[],
|
||||
direction:[]
|
||||
|
||||
});
|
||||
$("select[name$='isHexbin']").each(function(){
|
||||
setIsHexBin(this);
|
||||
});
|
||||
@@ -1453,6 +1465,7 @@ var initCommIpVal=function(){
|
||||
//ip类型处理
|
||||
if(ipType){
|
||||
var arr=ipType.split(',');
|
||||
$.ipcommon.ipType=$("select[name$='ipPattern'] option");
|
||||
$("select[name$='ipType'] option").each(function(){
|
||||
var has=false;
|
||||
for(var type in arr){
|
||||
@@ -1465,13 +1478,14 @@ var initCommIpVal=function(){
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
$(this).attr("disabled",true);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
//ip格式处理
|
||||
if(ipPattern){
|
||||
arr=ipPattern.split(',');
|
||||
$.ipcommon.ipPattern=$("select[name$='ipPattern'] option");
|
||||
$("select[name$='ipPattern'] option").each(function(){
|
||||
var has=false;
|
||||
for(var type in arr){
|
||||
@@ -1484,13 +1498,16 @@ var initCommIpVal=function(){
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
$(this).attr("disabled",true);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ipcommon.ipPattern=[];
|
||||
}
|
||||
//端口格式处理
|
||||
if(portPattern){
|
||||
arr=portPattern.split(',');
|
||||
$.ipcommon.portPattern=$("select[name$='portPattern'] option");
|
||||
$("select[name$='portPattern'] option").each(function(){
|
||||
var has=false;
|
||||
for(var type in arr){
|
||||
@@ -1503,13 +1520,16 @@ var initCommIpVal=function(){
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
$(this).attr("disabled",true);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ipcommon.portPattern=[];
|
||||
}
|
||||
//方向处理
|
||||
if(direction){
|
||||
arr=direction.split(',');
|
||||
$.ipcommon.direction=$("select[name$='direction'] option");
|
||||
$("select[name$='direction'] option").each(function(){
|
||||
var has=false;
|
||||
for(var type in arr){
|
||||
@@ -1522,13 +1542,16 @@ var initCommIpVal=function(){
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
$(this).attr("disabled",true);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ipcommon.direction=[];
|
||||
}
|
||||
//协议处理
|
||||
if(protocol){
|
||||
arr=protocol.split(',');
|
||||
$.ipcommon.protocol=$("select[name$='protocol'] option");
|
||||
$("select[name$='protocol'] option").each(function(){
|
||||
var has=false;
|
||||
for(var type in arr){
|
||||
@@ -1541,8 +1564,10 @@ var initCommIpVal=function(){
|
||||
}
|
||||
}
|
||||
if(!has){
|
||||
$(this).attr("disabled",true);
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$.ipcommon.protocol=[];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user