| 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 |
$('#chart_btn div').click( function (e) { |
| 25 |
var $mainBox = $('#chart_wrap'); |
| 26 |
var $btn = $(this); |
| 27 |
var $days = $btn.data('days'); |
| 28 |
|
| 29 |
$mainBox.animate({opacity: 0.5}, 300); |
| 30 |
|
| 31 |
jQuery.post( |
| 32 |
ajaxurl, |
| 33 |
{ |
| 34 |
action: 'chart_filter', |
| 35 |
days: $days, |
| 36 |
}, |
| 37 |
function (response) { |
| 38 |
$('#chart_btn div').removeClass('wtotem_chart-first__btn_active'); |
| 39 |
$btn.addClass('wtotem_chart-first__btn_active'); |
| 40 |
|
| 41 |
$mainBox |
| 42 |
.html(response) |
| 43 |
.animate({opacity: 1}, 300); |
| 44 |
}); |
| 45 |
}); |
| 46 |
|
| 47 |
$('#wtotem_av_state_filter').change( function (e) { |
| 48 |
var $period = $('#av_period_filter').val(); |
| 49 |
$period = $period.split(' to '); |
| 50 |
$period = ($period[0]) ? $period : null; |
| 51 |
|
| 52 |
var $mainBox = $('#wtotem_data_box'); |
| 53 |
$mainBox.animate({opacity: 0.5}, 300); |
| 54 |
|
| 55 |
jQuery.post( |
| 56 |
ajaxurl, |
| 57 |
{ |
| 58 |
action: 'ajax_antivirus', |
| 59 |
event: $(this).val(), |
| 60 |
period: $period, |
| 61 |
|
| 62 |
}, |
| 63 |
function (response) { |
| 64 |
$mainBox |
| 65 |
.html(response) |
| 66 |
.animate({opacity: 1}, 300); |
| 67 |
}); |
| 68 |
}); |
| 69 |
|
| 70 |
|
| 71 |
function lazy_ajax(actionName, btnMore ) { |
| 72 |
var $period = $('.flatpickr-input').val(); |
| 73 |
$period = $period.split(' to '); |
| 74 |
$period = ($period[0]) ? $period : null; |
| 75 |
|
| 76 |
var $mainBox = $('#wtotem_data_box'); |
| 77 |
$mainBox.animate({opacity: 0.5}, 300); |
| 78 |
|
| 79 |
jQuery.post( |
| 80 |
ajaxurl, |
| 81 |
{ |
| 82 |
action: actionName, |
| 83 |
period: $period, |
| 84 |
}, |
| 85 |
function (response) { |
| 86 |
$('#waf_load_more, #av_load_more').remove(); |
| 87 |
$mainBox |
| 88 |
.append(response) |
| 89 |
.animate({opacity: 1}, 300); |
| 90 |
}); |
| 91 |
} |
| 92 |
|
| 93 |
// period filter |
| 94 |
function period_filter(actionName, $period ) { |
| 95 |
$period = $period.split(' to '); |
| 96 |
$period = ($period[0]) ? $period : null; |
| 97 |
|
| 98 |
var $mainBox = $('#wtotem_data_box'); |
| 99 |
$mainBox.animate({opacity: 0.5}, 300); |
| 100 |
|
| 101 |
jQuery.post( |
| 102 |
ajaxurl, |
| 103 |
{ |
| 104 |
action: actionName, |
| 105 |
filter: 'period_filter', |
| 106 |
period: $period, |
| 107 |
|
| 108 |
}, |
| 109 |
function (response) { |
| 110 |
$mainBox |
| 111 |
.html(response) |
| 112 |
.animate({opacity: 1}, 300); |
| 113 |
}); |
| 114 |
} |
| 115 |
|
| 116 |
}); |