| 1 |
jQuery(document).ready(function ($) { |
| 2 |
|
| 3 |
$('body').on('click','#waf_load_more', function (e) { |
| 4 |
e.preventDefault(); |
| 5 |
lazy_ajax('ajax_firewall',$(this)); |
| 6 |
}) |
| 7 |
.on('click','#av_load_more', function (e) { |
| 8 |
e.preventDefault(); |
| 9 |
lazy_ajax('ajax_antivirus',$(this)); |
| 10 |
}); |
| 11 |
|
| 12 |
|
| 13 |
$('#waf_period_filter').on('input', function (e) { |
| 14 |
var $period = $(this).val(); |
| 15 |
period_filter('ajax_firewall',$period) |
| 16 |
}); |
| 17 |
|
| 18 |
$('#av_period_filter').on('input', function (e) { |
| 19 |
var $period = $(this).val(); |
| 20 |
period_filter('ajax_antivirus',$period) |
| 21 |
}); |
| 22 |
|
| 23 |
|
| 24 |
$('#color_scheme_toggle input').on('click', function (e) { |
| 25 |
|
| 26 |
let $checked = $(this).prop("checked"); |
| 27 |
|
| 28 |
jQuery.post( |
| 29 |
ajaxurl, |
| 30 |
{ |
| 31 |
action: 'color_scheme_toggle', |
| 32 |
checked: Number($checked), |
| 33 |
}, |
| 34 |
function (response) { |
| 35 |
if(response == 'dark'){ |
| 36 |
$('body').addClass('wtotem_theme—dark'); |
| 37 |
} else{ |
| 38 |
$('body').removeClass('wtotem_theme—dark'); |
| 39 |
} |
| 40 |
}); |
| 41 |
|
| 42 |
}); |
| 43 |
|
| 44 |
$('.config_toggle').on('click', function (e) { |
| 45 |
let $id = $(this).val(); |
| 46 |
let $checkBox = $(this); |
| 47 |
e.preventDefault(); |
| 48 |
jQuery.post( |
| 49 |
ajaxurl, |
| 50 |
{ |
| 51 |
action: 'configs_toggle', |
| 52 |
service: $id, |
| 53 |
}, |
| 54 |
function (response) { |
| 55 |
let data = $.parseJSON(response); |
| 56 |
if(data){ |
| 57 |
|
| 58 |
if(data.isActive === true){ |
| 59 |
$checkBox.prop('checked', true); |
| 60 |
} |
| 61 |
else if(data.isActive === false) { |
| 62 |
$checkBox.prop('checked', false); |
| 63 |
} |
| 64 |
} |
| 65 |
}); |
| 66 |
}); |
| 67 |
|
| 68 |
$('#chart_btn div').click( function (e) { |
| 69 |
var $mainBox = $('#chart_wrap'); |
| 70 |
var $btn = $(this); |
| 71 |
var $days = $btn.data('days'); |
| 72 |
|
| 73 |
$mainBox.animate({opacity: 0.5}, 300); |
| 74 |
|
| 75 |
jQuery.post( |
| 76 |
ajaxurl, |
| 77 |
{ |
| 78 |
action: 'chart_filter', |
| 79 |
days: $days, |
| 80 |
}, |
| 81 |
function (response) { |
| 82 |
$('#chart_btn div').removeClass('wtotem_chart-first__btn_active'); |
| 83 |
$btn.addClass('wtotem_chart-first__btn_active'); |
| 84 |
|
| 85 |
$mainBox |
| 86 |
.html(response) |
| 87 |
.animate({opacity: 1}, 300); |
| 88 |
}); |
| 89 |
}); |
| 90 |
|
| 91 |
$('#map_btn div').click( function (e) { |
| 92 |
var $mainBox = $('#wtotem_map_box'); |
| 93 |
var $btn = $(this); |
| 94 |
var $days = $btn.data('days'); |
| 95 |
|
| 96 |
$mainBox.animate({opacity: 0.5}, 300); |
| 97 |
|
| 98 |
jQuery.post( |
| 99 |
ajaxurl, |
| 100 |
{ |
| 101 |
action: 'map_filter', |
| 102 |
days: $days, |
| 103 |
}, |
| 104 |
function (response) { |
| 105 |
$('#map_btn div').removeClass('wtotem_chart-first__btn_active'); |
| 106 |
$btn.addClass('wtotem_chart-first__btn_active'); |
| 107 |
|
| 108 |
$mainBox |
| 109 |
.html(response) |
| 110 |
.animate({opacity: 1}, 300); |
| 111 |
attacksMap(); |
| 112 |
}); |
| 113 |
}); |
| 114 |
|
| 115 |
$('#wtotem_av_state_filter').change( function (e) { |
| 116 |
var $period = $('#av_period_filter').val(); |
| 117 |
$period = $period.split(' to '); |
| 118 |
$period = ($period[0]) ? $period : null; |
| 119 |
|
| 120 |
var $mainBox = $('#wtotem_data_box'); |
| 121 |
$mainBox.animate({opacity: 0.5}, 300); |
| 122 |
|
| 123 |
jQuery.post( |
| 124 |
ajaxurl, |
| 125 |
{ |
| 126 |
action: 'ajax_antivirus', |
| 127 |
event: $(this).val(), |
| 128 |
period: $period, |
| 129 |
|
| 130 |
}, |
| 131 |
function (response) { |
| 132 |
$mainBox |
| 133 |
.html(response) |
| 134 |
.animate({opacity: 1}, 300); |
| 135 |
}); |
| 136 |
}); |
| 137 |
|
| 138 |
|
| 139 |
function lazy_ajax(actionName, btnMore ) { |
| 140 |
var $period = $('.flatpickr-input').val(); |
| 141 |
$period = $period.split(' to '); |
| 142 |
$period = ($period[0]) ? $period : null; |
| 143 |
|
| 144 |
var $mainBox = $('#wtotem_data_box'); |
| 145 |
$mainBox.animate({opacity: 0.5}, 300); |
| 146 |
|
| 147 |
jQuery.post( |
| 148 |
ajaxurl, |
| 149 |
{ |
| 150 |
action: actionName, |
| 151 |
period: $period, |
| 152 |
}, |
| 153 |
function (response) { |
| 154 |
$('#waf_load_more, #av_load_more').remove(); |
| 155 |
$mainBox |
| 156 |
.append(response) |
| 157 |
.animate({opacity: 1}, 300); |
| 158 |
}); |
| 159 |
} |
| 160 |
|
| 161 |
// period filter |
| 162 |
function period_filter(actionName, $period ) { |
| 163 |
$period = $period.split(' to '); |
| 164 |
$period = ($period[0]) ? $period : null; |
| 165 |
|
| 166 |
var $mainBox = $('#wtotem_data_box'); |
| 167 |
$mainBox.animate({opacity: 0.5}, 300); |
| 168 |
|
| 169 |
jQuery.post( |
| 170 |
ajaxurl, |
| 171 |
{ |
| 172 |
action: actionName, |
| 173 |
filter: 'period_filter', |
| 174 |
period: $period, |
| 175 |
|
| 176 |
}, |
| 177 |
function (response) { |
| 178 |
$mainBox |
| 179 |
.html(response) |
| 180 |
.animate({opacity: 1}, 300); |
| 181 |
}); |
| 182 |
} |
| 183 |
|
| 184 |
}); |