maliciousIpLook.js
2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$(function () {
refreshTableRemove();
});
function refreshTableRemove() {
$("#lookTable").table({
url: contextPath + "maliciousIp/lookIps",
dataType: 'json',
striped: true,
panelClass: "panel-success",
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [
{
title: "",
width:"50px",
field: "ip",
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
//复选框
var checkBox = $("<input name='checkType' type='checkbox' value='"+value+"'>").addClass("ckbox-default").appendTo(div);
return div;
}
},
{
title: "ip",
width: "230px",
field: "ip"
},
{
title: "剩余时间(小时)",
width: "100px",
field: "ttl"
}]
});
}
function checkAllRemove(){
$("#lookTable input[type='checkbox']").each(function(){
if($("#checkAllRemove").is(':checked'))
$(this).prop("checked", true);
else
$(this).prop("checked", false);
});
}
function remove(){
var listip = "";
$("#lookTable input[type='checkbox']:checked").each(function(){
listip += $(this).val() + "|";
});
if(listip.length == 0){
return;
}
if(confirm("是否确定要移除如下ip:\r\n" + listip)){
var params = {};
params.ips = listip;
$.ajax({
url: '/maliciousIp/removeIp',
type: 'POST',
data: params,
dataType: 'json',
success: function (data) {
if (!data || data.code != 200) {
alert('系统异常:'+data.message);
}else{
if(data.data.status == '0'){
alert('移除成功!');
$("#lookTable input[type='checkbox']:checked").each(function(){
$(this).parent().parent().parent().remove();
});
}else{
alert('移除失败:'+data.data.message);
}
}
},
error: function (data) {
alert('系统异常');
}
});
}
}