修改是否十六进制切换,增加十六进制校验

This commit is contained in:
duandongmei
2018-09-13 18:08:26 +08:00
parent ae5cb30aa1
commit b74d51f9fb

View File

@@ -11,6 +11,7 @@ $(function(){
direction:[]
});
$("select[name$='isHexbin']").each(function(){
console.log("isHexbin:"+$(this).val());
setIsHexBin(this);
});
$("input[name$='isHex']").on("change",function(){
@@ -360,13 +361,6 @@ $(function(){
$("#serviceId").val($(this).attr("serviceId"));
$("#protocolId").val($(this).attr("protocolId"));
});
//选择hex cfgkeywords需校验十六进制
$("select[name$='isHexbin']").each(function(){
$(this).on("change",function(){
addHexCheck(this,$(this).val());
});
addHexCheck(this,$(this).val());
});
// 校验搜索条件里的时间选框,不允许起始时间晚于终止时间
$("#searchForm").validate({
rules:{
@@ -699,6 +693,14 @@ var setIsHexBin=function(obj){
$("input[name='"+profix+"isCaseSenstive'][value=1]").prop("checked",true);
$("input[name='"+profix+"isCaseSenstive'][value=0]").prop("checked",false);
}
if(isHexbin == 1){ //十六进制
console.log($("input[name='"+profix+"cfgKeywords']").val());
$("input[name='"+profix+"cfgKeywords']").addClass("hexCheck");
$("input[name='"+profix+"domain']").addClass("hexCheck");
}else{
$("input[name='"+profix+"cfgKeywords']").removeClass("hexCheck");
$("input[name='"+profix+"domain']").removeClass("hexCheck");
}
return;
}
var isHex=$("input[name='"+profix+"isHex']:checked").val();
@@ -727,16 +729,15 @@ var setIsHexBin=function(obj){
if($("select[name='"+profix+"isHexbin']").val() == ""){
$("select[name='"+profix+"isHexbin']").find("option[value=0]").prop("selected","selected");
}
}
//选择hex cfgkeywords需校验十六进制
var addHexCheck=function(obj,isHexbin){
if(isHexbin == 1){ //十六进制
$(obj).parent().parent().parent().parent().parent().parent().find("input[name$='cfgKeywords']").addClass("hexCheck");
$(obj).parent().parent().parent().parent().parent().parent().find("input[name$='domain']").addClass("hexCheck");
if(isHex == 1){ //十六进制
console.log($("input[name='"+profix+"cfgKeywords']").val());
$("input[name='"+profix+"cfgKeywords']").addClass("hexCheck");
$("input[name='"+profix+"domain']").addClass("hexCheck");
}else{
$(obj).parent().parent().parent().parent().parent().parent().find("input[name$='cfgKeywords']").removeClass("hexCheck");
$(obj).parent().parent().parent().parent().parent().parent().find("input[name$='domain']").removeClass("hexCheck");
$("input[name='"+profix+"cfgKeywords']").removeClass("hexCheck");
$("input[name='"+profix+"domain']").removeClass("hexCheck");
}
}
//与表达式时,只允许为子串匹配
var setDefaultMatchMethod=function (obj){
@@ -828,14 +829,16 @@ var switchAction=function(action){
/*************************action切换时隐藏白名单和drop的是否记录日志*****************************/
//drop whitelist
if(action == 32 || action==128){
if(action == 32 || action==128 || action==96){
$(".doLog").addClass("hidden");
$("input[name=doLog][value=0]").prop("checked",true);
$(".interceptDoLog").find("input[name=doLog][value=0]").prop("checked",true);
}else{
//如果表单非修改时,选中默认值
if(!$("input[name='compileId']").val()){
$(".doLog").removeClass("hidden");
$("input[name=doLog][value=2]").prop("checked",true);
$(".interceptDoLog").find("input[name=doLog][value=1]").prop("checked",true);
}
}
@@ -1390,11 +1393,7 @@ var GetLogTotal=function(_data){
for(var i=0;i<data.length;i++){
if($(this).attr("compileId")==data[i].compileId){
$(this).attr("id",i+"logTotal");
if(data[i].sum != 0){
$(this).html("<a href='javascript:;' onclick='toLogSearch("+i+")'>"+data[i].sum+"<a>");
}else{
$(this).html(data[i].sum);
}
$(this).html("<a href='javascript:;' onclick='toLogSearch("+i+")'>"+data[i].sum+"<a>");
hasLog=true;
}
}
@@ -1436,7 +1435,8 @@ var toLogSearch = function(index){
var date=$(this).attr("date");
var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.indexOf("/nis")+4);
window.location.href = pathName+"/toLogSearch?action="+action+"&functionId="+functionId+"&compileId="+compileId+"&date="+date;
window.location.href = pathName+"/toLogSearch?action="+action+"&functionId="+functionId+"&cfgId="+compileId+"&date="+date+"&isLogTotalSearch=yes";
}
});
@@ -1571,6 +1571,39 @@ var importCfg=function(){
$("#import_modal").modal('hide');//导入文件隐藏
$("#importForm1").submit();
}
var validateTagInputKeyword=function(){
var flag=true;
$(".boxSolid:visible").find("input[name$='cfgKeywords']").each(function(){
if($(this).val()==''){
$(this).parents(".form-group").find(
"div[for='"
+ $(this).attr("name")
+ "']").html("<label id=\"cfgKeywordsError\" class=\"error\">"+$("#keywordError").text()+"bb</label>");
return false;
}
});
if(flag){
//keywords非空校验完成校验二进制字符串
$(".boxSolid:visible").find("select[name$='isHexbin']").each(function(){
var isHexbin=$(this).val();
var configMultiKeywords=$("input[name$='"+$(this).attr("name").replace("isHexbin","configMultiKeywords")+"']").val();
if(isHexbin == 1 && configMultiKeywords==1){ //十六进制
var keywords=$("input[name$='"+$(this).attr("name").replace("isHexbin","cfgKeywords")+"']").val();
keywords=keywords.replace("***and***","")
if(keywords != ''){
if(!(/^([0-9|a-f|A-F]*)$/.test(keywords))){
$(this).parents(".boxSolid").find(
"div[for='"
+ $(this).attr("name").replace("isHexbin","cfgKeywords")
+ "']").html("<label id=\"cfgKeywordsError\" class=\"error\">"+$.validator.messages.hexCheck+"</label>");
flag = false;
}
}
}
});
}
return flag;
}
var validateInvisibleCharTag=function(){
var hasInvisibleCharTags=[];
var reg = new RegExp(/\t|\r|\n/);