2018-09-29 21:46:17 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 处理IP域值
|
|
|
|
|
|
*/
|
|
|
|
|
|
;(function($){
|
|
|
|
|
|
$.extend({
|
|
|
|
|
|
ipcommon:function(){
|
|
|
|
|
|
return {};
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$.extend($.ipcommon, {
|
|
|
|
|
|
ipType:[],
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern:[],
|
|
|
|
|
|
destIpPattern:[],
|
|
|
|
|
|
srcPortPattern:[],
|
|
|
|
|
|
destPortPattern:[],
|
2018-09-29 21:46:17 +08:00
|
|
|
|
protocol:[],
|
|
|
|
|
|
direction:[]
|
|
|
|
|
|
});
|
|
|
|
|
|
})(jQuery);
|
|
|
|
|
|
$(function(){
|
|
|
|
|
|
initCommIpVal();
|
2019-04-18 10:15:23 +08:00
|
|
|
|
//IP域修改时默认展开,不显示show more
|
|
|
|
|
|
if($("input[name='compileId']")&&$("input[name='compileId']").val()!=0&&($(".btn-red-hollow").parents(".boxSolid").is(":visible")||$("input[name$='cfgRegionCode']").length==1)){
|
|
|
|
|
|
$(".port").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(".destPort").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(".protocol").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(".ipCol:hidden").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(".btn-red-hollow").addClass("hidden");
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
});
|
|
|
|
|
|
window.$.ipcommon=$.ipcommon;
|
2019-04-18 10:15:23 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 初始化格式处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
var processPattern=function(selector,pattern){
|
|
|
|
|
|
if("ipType"==selector){
|
|
|
|
|
|
$.ipcommon.ipType=$("select[name$='ipType'] option");
|
|
|
|
|
|
}else if("srcIpPattern"==selector){
|
|
|
|
|
|
$.ipcommon.srcIpPattern=$("select[name$='srcIpPattern'] option");
|
|
|
|
|
|
}else if("destIpPattern"==selector){
|
|
|
|
|
|
$.ipcommon.destIpPattern=$("select[name$='destIpPattern'] option");
|
|
|
|
|
|
}else if("srcPortPattern"==selector){
|
|
|
|
|
|
$.ipcommon.srcPortPattern=$("select[name$='srcPortPattern'] option");
|
|
|
|
|
|
}else if("destPortPattern"==selector){
|
|
|
|
|
|
$.ipcommon.destPortPattern=$("select[name$='destPortPattern'] option");
|
|
|
|
|
|
}else if("direction"==selector){
|
|
|
|
|
|
$.ipcommon.direction=$("select[name$='direction'] option");
|
|
|
|
|
|
}else if("protocol"==selector){
|
|
|
|
|
|
$.ipcommon.protocol=$("select[name$='protocol'] option");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(pattern){
|
|
|
|
|
|
var arr=pattern.split(',');
|
|
|
|
|
|
$("select[name$='"+selector+"'] 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).remove();
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* ip默认选项处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
var initCommIpVal=function(){
|
|
|
|
|
|
var action,regionCode,serviceType,ipPortShow,ipType,
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern,destIpPattern,srcPortPattern,destPortPattern,
|
|
|
|
|
|
direction,protocol,regionType;
|
2018-09-29 21:46:17 +08:00
|
|
|
|
if($("input[name$='action']:checked").length>0){
|
|
|
|
|
|
regionCode=$("input[name$='action']:checked").attr("regionCode");
|
|
|
|
|
|
action=$("input[name$='action']:checked").val();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
regionCode=$("input[name$='action']").attr("regionCode");
|
|
|
|
|
|
action=$("input[name$='action']").val();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionCode){
|
|
|
|
|
|
if(regionCode.indexOf(",")==-1){
|
|
|
|
|
|
$("#cfgRegionCode"+regionCode).attr("name","cfgRegionCode");
|
|
|
|
|
|
$("#cfgType"+regionCode).attr("name","cfgType");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
var _region='';
|
|
|
|
|
|
var regionArr=regionCode.split(',');
|
|
|
|
|
|
$("input[name$='cfgRegionCode'][regionType='1']").each(function(){
|
|
|
|
|
|
for(var re in regionArr){
|
|
|
|
|
|
if($(this).val()==regionArr[re]){
|
|
|
|
|
|
_region=regionArr[re];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if(_region!=''){
|
|
|
|
|
|
regionCode=_region;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionCode){//IP域大于1个,根据action获取ip属性
|
|
|
|
|
|
ipPortShow=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPortShow"),
|
|
|
|
|
|
ipType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipType"),
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcIpPattern"),
|
|
|
|
|
|
destIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destIpPattern"),
|
|
|
|
|
|
srcPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcPortPattern"),
|
|
|
|
|
|
destPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destPortPattern"),
|
2018-09-29 21:46:17 +08:00
|
|
|
|
direction=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("direction"),
|
|
|
|
|
|
protocol=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("protocol"),
|
|
|
|
|
|
regionType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("regionType");
|
|
|
|
|
|
}else{//IP域只有一个,获取regionType为1的
|
|
|
|
|
|
ipPortShow=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPortShow"),
|
|
|
|
|
|
ipType=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipType"),
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcIpPattern"),
|
|
|
|
|
|
destIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destIpPattern"),
|
|
|
|
|
|
srcPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcPortPattern"),
|
|
|
|
|
|
destPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destPortPattern"),
|
2018-09-29 21:46:17 +08:00
|
|
|
|
direction=$("input[name$='cfgRegionCode'][regionType='1']").attr("direction"),
|
|
|
|
|
|
protocol=$("input[name$='cfgRegionCode'][regionType='1']").attr("protocol"),
|
|
|
|
|
|
regionType=$("input[name$='cfgRegionCode'][regionType='1']").attr("regionType");
|
|
|
|
|
|
}
|
2018-10-04 19:45:39 +08:00
|
|
|
|
//ip,端口处理源ip展示、源端口展示、目的ip展示、目的端口展示1、2、3、4
|
2018-09-29 21:46:17 +08:00
|
|
|
|
if(ipPortShow){
|
2018-10-04 19:45:39 +08:00
|
|
|
|
if(ipPortShow.indexOf('1')>-1){//展示源IP
|
2018-09-29 21:46:17 +08:00
|
|
|
|
$("input[name$='srcIpAddress']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcIpPattern']").parents(".form-group").removeClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
$("input[name$='srcIpAddress']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcIpPattern']").parents(".form-group").addClass("hidden");
|
|
|
|
|
|
if(!$("input[name$='srcIpAddress']").parents(".ipCol").is(":hidden")){
|
|
|
|
|
|
$("input[name$='srcIpAddress']").parents(".ipCol").addClass("hidden");
|
|
|
|
|
|
}
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(ipPortShow.indexOf('2')>-1){//展示源端口
|
|
|
|
|
|
$("input[name$='srcPort']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcPortPattern']").parents(".form-group").removeClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}else{
|
2018-09-29 21:46:17 +08:00
|
|
|
|
$("input[name$='srcPort']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcPortPattern']").parents(".form-group").addClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
2018-10-04 19:45:39 +08:00
|
|
|
|
if(ipPortShow.indexOf('3')>-1){//展示目的IP
|
2018-09-29 21:46:17 +08:00
|
|
|
|
$("input[name$='destIpAddress']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destIpPattern']").parents(".form-group").removeClass("hidden");
|
|
|
|
|
|
//当源IP不展示的时候目的IP要默认展示
|
|
|
|
|
|
if($("input[name$='destIpAddress']").parents(".ipCol")&&ipPortShow.indexOf('1')==-1){
|
|
|
|
|
|
$("input[name$='destIpAddress']").parents(".ipCol").removeClass("hidden");
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
$("input[name$='destIpAddress']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destIpPattern']").parents(".form-group").addClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(ipPortShow.indexOf('4')>-1){//展示目的端口
|
|
|
|
|
|
$("input[name$='destPort']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destPortPattern']").parents(".form-group").removeClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}else{
|
2018-09-29 21:46:17 +08:00
|
|
|
|
$("input[name$='destPort']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destPortPattern']").parents(".form-group").addClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(ipType){
|
2019-04-18 10:15:23 +08:00
|
|
|
|
processPattern("ipType",ipType);
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
2019-04-18 10:15:23 +08:00
|
|
|
|
if(srcIpPattern){
|
|
|
|
|
|
processPattern("srcIpPattern",srcIpPattern);
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
2019-04-18 10:15:23 +08:00
|
|
|
|
if(destIpPattern){
|
|
|
|
|
|
processPattern("destIpPattern",destIpPattern);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(srcPortPattern){
|
|
|
|
|
|
processPattern("srcPortPattern",srcPortPattern);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(destPortPattern){
|
|
|
|
|
|
processPattern("destPortPattern",destPortPattern);
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(direction){
|
2019-04-18 10:15:23 +08:00
|
|
|
|
processPattern("direction",direction);
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(protocol){
|
2019-04-18 10:15:23 +08:00
|
|
|
|
processPattern("protocol",protocol);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
var changePattern=function(o,selector,pattern){
|
|
|
|
|
|
if(pattern){
|
|
|
|
|
|
arr=pattern.split(',');
|
|
|
|
|
|
var ipPatternVal=o.find("select[name$='"+selector+"'] option:selected").attr("value");
|
|
|
|
|
|
o.find("select[name$='"+selector+"']").empty();
|
|
|
|
|
|
var patterns=selector=="srcIpPattern"?$.ipcommon.srcIpPattern:
|
|
|
|
|
|
selector=="destIpPattern"?$.ipcommon.destIpPattern:
|
|
|
|
|
|
selector=="srcPortPattern"?$.ipcommon.srcPortPattern:
|
|
|
|
|
|
selector=="destPortPattern"?$.ipcommon.destPortPattern:[];
|
|
|
|
|
|
$(patterns).each(function(){
|
2018-09-29 21:46:17 +08:00
|
|
|
|
var has=false;
|
|
|
|
|
|
for(var type in arr){
|
|
|
|
|
|
if($(this).val()==arr[type]){
|
|
|
|
|
|
has=true;
|
2019-04-18 10:15:23 +08:00
|
|
|
|
o.find("select[name$='"+selector+"']").append($(this));
|
2018-09-29 21:46:17 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-04-18 10:15:23 +08:00
|
|
|
|
o.find("select[name$='"+selector+"']").selectpicker("refresh");
|
|
|
|
|
|
if(o.find("select[name$='"+selector+"'] option[value='"+ipPatternVal+"']").length>0){
|
|
|
|
|
|
o.find("select[name$='"+selector+"']").selectpicker("val",ipPatternVal);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(o.find("select[name$='"+selector+"'] option[value=1]").length>0){
|
|
|
|
|
|
o.find("select[name$='"+selector+"']").selectpicker("val",1);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
o.find("select[name$='"+selector+"']").get(0).selectedIndex=0;
|
|
|
|
|
|
o.find("select[name$='"+selector+"']").selectpicker("refresh");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* ip切换默认值处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
var changeIPVal=function(obj){
|
|
|
|
|
|
var action,regionCode,serviceType,ipPortShow,ipType,
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern,destIpPattern,srcPortPattern,destPortPattern,direction,protocol,regionType,o;
|
2018-09-29 21:46:17 +08:00
|
|
|
|
o=$(obj);
|
|
|
|
|
|
if($("input[name$='action']:checked").length>0){
|
|
|
|
|
|
regionCode=$("input[name$='action']:checked").attr("regionCode");
|
|
|
|
|
|
action=$("input[name$='action']:checked").val();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
regionCode=$("input[name$='action']").attr("regionCode");
|
|
|
|
|
|
action=$("input[name$='action']").val();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionCode){
|
|
|
|
|
|
if(regionCode.indexOf(",")==-1){
|
|
|
|
|
|
$("#cfgRegionCode"+regionCode).attr("name","cfgRegionCode");
|
|
|
|
|
|
$("#cfgType"+regionCode).attr("name","cfgType");
|
|
|
|
|
|
}else{
|
|
|
|
|
|
var _region='';
|
|
|
|
|
|
var regionArr=regionCode.split(',');
|
|
|
|
|
|
$("input[name$='cfgRegionCode'][regionType='1']").each(function(){
|
|
|
|
|
|
for(var re in regionArr){
|
|
|
|
|
|
if($(this).val()==regionArr[re]){
|
|
|
|
|
|
_region=regionArr[re];
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if(_region!=''){
|
|
|
|
|
|
regionCode=_region;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(regionCode){//IP域大于1个,根据action获取ip属性
|
|
|
|
|
|
ipPortShow=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPortShow"),
|
|
|
|
|
|
ipType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipType"),
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcIpPattern"),
|
|
|
|
|
|
destIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destIpPattern"),
|
|
|
|
|
|
srcPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcPortPattern"),
|
|
|
|
|
|
destPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destPortPattern"),
|
2018-09-29 21:46:17 +08:00
|
|
|
|
direction=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("direction"),
|
|
|
|
|
|
protocol=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("protocol"),
|
|
|
|
|
|
regionType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("regionType");
|
|
|
|
|
|
}else{//IP域只有一个,获取regionType为1的
|
|
|
|
|
|
ipPortShow=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPortShow"),
|
|
|
|
|
|
ipType=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipType"),
|
2019-04-18 10:15:23 +08:00
|
|
|
|
srcIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcIpPattern"),
|
|
|
|
|
|
destIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destIpPattern"),
|
|
|
|
|
|
srcPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcPortPattern"),
|
|
|
|
|
|
destPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destPortPattern"),
|
2018-09-29 21:46:17 +08:00
|
|
|
|
direction=$("input[name$='cfgRegionCode'][regionType='1']").attr("direction"),
|
|
|
|
|
|
protocol=$("input[name$='cfgRegionCode'][regionType='1']").attr("protocol"),
|
|
|
|
|
|
regionType=$("input[name$='cfgRegionCode'][regionType='1']").attr("regionType");
|
|
|
|
|
|
}
|
|
|
|
|
|
if(o){
|
2018-10-04 19:45:39 +08:00
|
|
|
|
//ip,端口处理源ip展示、源端口展示、目的ip展示、目的端口展示1、2、3、4
|
2018-09-29 21:46:17 +08:00
|
|
|
|
if(ipPortShow){
|
2018-10-04 19:45:39 +08:00
|
|
|
|
if(ipPortShow.indexOf('1')>-1){//展示源IP
|
|
|
|
|
|
$("input[name$='srcIpAddress']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcIpPattern']").parents(".form-group").removeClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
$("input[name$='srcIpAddress']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcIpPattern']").parents(".form-group").addClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(ipPortShow.indexOf('2')>-1){//展示源端口
|
|
|
|
|
|
$("input[name$='srcPort']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcPortPattern']").parents(".form-group").removeClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}else{
|
|
|
|
|
|
$("input[name$='srcPort']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='srcPortPattern']").parents(".form-group").addClass("hidden");
|
2018-10-04 19:45:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(ipPortShow.indexOf('3')>-1){//展示目的IP
|
|
|
|
|
|
$("input[name$='destIpAddress']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destIpPattern']").parents(".form-group").removeClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}else{
|
2018-10-04 19:45:39 +08:00
|
|
|
|
$("input[name$='destIpAddress']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destIpPattern']").parents(".form-group").addClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
2018-10-04 19:45:39 +08:00
|
|
|
|
if(ipPortShow.indexOf('4')>-1){//展示目的端口
|
|
|
|
|
|
$("input[name$='destPort']").parents(".form-group").removeClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destPortPattern']").parents(".form-group").removeClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}else{
|
2018-10-04 19:45:39 +08:00
|
|
|
|
$("input[name$='destPort']").parents(".form-group").addClass("hidden");
|
2019-04-18 10:15:23 +08:00
|
|
|
|
$("select[name$='destPortPattern']").parents(".form-group").addClass("hidden");
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//ip类型处理
|
|
|
|
|
|
if(ipType){
|
|
|
|
|
|
var arr=ipType.split(',');
|
|
|
|
|
|
var ipTypeVal=o.find("select[name$='ipType'] option:selected").attr("value");
|
|
|
|
|
|
o.find("select[name$='ipType']").empty();
|
|
|
|
|
|
$.ipcommon.ipType.each(function(){
|
|
|
|
|
|
var has=false;
|
|
|
|
|
|
for(var type in arr){
|
|
|
|
|
|
if($(this).val()==arr[type]){
|
|
|
|
|
|
has=true;
|
|
|
|
|
|
o.find("select[name$='ipType']").append($(this));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
o.find("select[name$='ipType']").selectpicker("refresh");
|
|
|
|
|
|
if(o.find("select[name$='ipType'] option[value='"+ipTypeVal+"']").length>0){
|
|
|
|
|
|
o.find("select[name$='ipType']").selectpicker("val",ipTypeVal);
|
|
|
|
|
|
}else{
|
2018-10-06 23:10:54 +08:00
|
|
|
|
if(o.find("select[name$='ipType'] option[value=4]").length>0){
|
|
|
|
|
|
o.find("select[name$='ipType']").selectpicker("val",4);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
o.find("select[name$='ipType']").get(0).selectedIndex=0;
|
|
|
|
|
|
o.find("select[name$='ipType']").selectpicker("refresh");
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2019-04-18 10:15:23 +08:00
|
|
|
|
//源ip格式处理
|
|
|
|
|
|
changePattern(o,"srcIpPattern",srcIpPattern);
|
|
|
|
|
|
//目的ip格式处理
|
|
|
|
|
|
changePattern(o,"destIpPattern",destIpPattern);
|
|
|
|
|
|
//源端口格式处理
|
|
|
|
|
|
changePattern(o,"srcPortPattern",srcPortPattern);
|
|
|
|
|
|
//目的源端口格式处理
|
|
|
|
|
|
changePattern(o,"destPortPattern",destPortPattern);
|
2018-09-29 21:46:17 +08:00
|
|
|
|
//方向处理
|
|
|
|
|
|
if(direction){
|
|
|
|
|
|
arr=direction.split(',');
|
|
|
|
|
|
var directionVal=o.find("select[name$='direction'] option:selected").attr("value");
|
|
|
|
|
|
o.find("select[name$='direction']").empty();
|
|
|
|
|
|
$.ipcommon.direction.each(function(){
|
|
|
|
|
|
var has=false;
|
|
|
|
|
|
for(var type in arr){
|
|
|
|
|
|
if($(this).val()==arr[type]){
|
|
|
|
|
|
has=true;
|
|
|
|
|
|
o.find("select[name$='direction']").append($(this));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
o.find("select[name$='direction']").selectpicker("refresh");
|
|
|
|
|
|
if(o.find("select[name$='direction'] option[value='"+directionVal+"']").length>0){
|
|
|
|
|
|
o.find("select[name$='direction']").selectpicker("val",directionVal);
|
|
|
|
|
|
}else{
|
2018-10-06 23:10:54 +08:00
|
|
|
|
if(o.find("select[name$='direction'] option[value=0]").length>0){
|
|
|
|
|
|
o.find("select[name$='direction']").selectpicker("val",0);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
o.find("select[name$='direction']").get(0).selectedIndex=0;
|
|
|
|
|
|
o.find("select[name$='direction']").selectpicker("refresh");
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//协议处理
|
|
|
|
|
|
if(protocol){
|
|
|
|
|
|
arr=protocol.split(',');
|
|
|
|
|
|
var protocolVal=o.find("select[name$='protocol'] option:selected").attr("value");
|
|
|
|
|
|
o.find("select[name$='protocol']").empty();
|
|
|
|
|
|
$.ipcommon.protocol.each(function(){
|
|
|
|
|
|
var has=false;
|
|
|
|
|
|
for(var type in arr){
|
|
|
|
|
|
if($(this).val()==arr[type]){
|
|
|
|
|
|
has=true;
|
|
|
|
|
|
o.find("select[name$='protocol']").append($(this));
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
o.find("select[name$='protocol']").selectpicker("refresh");
|
|
|
|
|
|
if(o.find("select[name$='protocol'] option[value='"+protocolVal+"']").length>0){
|
|
|
|
|
|
o.find("select[name$='protocol']").selectpicker("val",protocolVal);
|
|
|
|
|
|
}else{
|
2018-10-06 23:10:54 +08:00
|
|
|
|
if(o.find("select[name$='protocol'] option[value=0]").length>0){
|
|
|
|
|
|
o.find("select[name$='protocol']").selectpicker("val",0);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
o.find("select[name$='protocol']").get(0).selectedIndex=0;
|
|
|
|
|
|
o.find("select[name$='protocol']").selectpicker("refresh");
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-04-18 10:15:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
//show more 添加更多属性
|
|
|
|
|
|
var more=function(obj){
|
|
|
|
|
|
var moreCols=$(obj).parents(".row").siblings(".ipCol").not(":hidden").last().nextAll(":hidden");
|
|
|
|
|
|
if(moreCols.length==0){
|
|
|
|
|
|
var clickTimes=$(obj).data("click-times");
|
|
|
|
|
|
if(clickTimes==0){
|
|
|
|
|
|
$(".port").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(obj).data("click-times",clickTimes+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(clickTimes==1){
|
|
|
|
|
|
$(".destPort").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(obj).data("click-times",clickTimes+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
if(clickTimes==2){
|
|
|
|
|
|
$(".protocol").removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(obj).data("click-times",clickTimes+1);
|
|
|
|
|
|
}
|
|
|
|
|
|
var rows=$(obj).parent(".row").siblings(".row:hidden");
|
|
|
|
|
|
if(rows.size()==0){
|
|
|
|
|
|
$(obj).addClass("hidden");
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(moreCols.length>0){
|
|
|
|
|
|
//$(moreCols[0]).removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
$(moreCols).each(function(i){
|
|
|
|
|
|
$(this).removeClass("hidden").removeClass("disabled");
|
|
|
|
|
|
if($(this).find("form-group:hidden").length>0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if($(obj).parents(".row").siblings(".ipCol").not(":hidden").last().nextAll(":hidden").length==0){
|
|
|
|
|
|
$(obj).addClass("hidden");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-09-29 21:46:17 +08:00
|
|
|
|
}
|