| 1 |
<script type="text/javascript"> |
| 2 |
jQuery(document).ready(function ($) { |
| 3 |
|
| 4 |
let quarantine_ajax = (action, path) => { |
| 5 |
jQuery('.antivirus-quarantine__items-container').addClass('wtotem_loader_spinner'); |
| 6 |
jQuery.post( |
| 7 |
ajaxurl, |
| 8 |
{ |
| 9 |
action: 'wtotem_ajax', |
| 10 |
ajax_action: 'quarantine', |
| 11 |
wtotem_page_nonce: '{{ page_nonce }}', |
| 12 |
quarantine_action: action, |
| 13 |
path: path, |
| 14 |
}, |
| 15 |
function (data) { |
| 16 |
if(data.success){ |
| 17 |
jQuery('#infected_files').html(data.infected_files); |
| 18 |
jQuery('#quarantine_files').html(data.quarantine_files); |
| 19 |
jQuery('.infected_files__pagination').html(data.pagination_infected_files); |
| 20 |
jQuery('.quarantine_files__pagination').html(data.pagination_quarantine); |
| 21 |
jQuery('#infected_files_total').text(data.infected_files_total); |
| 22 |
jQuery('#quarantine_files_total').text(data.quarantine_files_total); |
| 23 |
} |
| 24 |
jQuery('.antivirus-quarantine__items-container').removeClass('wtotem_loader_spinner') |
| 25 |
jQuery('#wtotem_notifications').html(data.notifications); |
| 26 |
} |
| 27 |
); |
| 28 |
}; |
| 29 |
|
| 30 |
jQuery('.infected_files__pagination').on('click', 'a.wtotem_pagination__number', function (e) { |
| 31 |
e.preventDefault(); |
| 32 |
jQuery('#infected_files').addClass('wtotem_loader_spinner'); |
| 33 |
jQuery.post(ajaxurl, { |
| 34 |
action: 'wtotem_ajax', |
| 35 |
ajax_action: 'pagination', |
| 36 |
wtotem_page_nonce: '{{ page_nonce }}', |
| 37 |
service: 'infected_files', |
| 38 |
current_page: jQuery(this).attr('data-page'), |
| 39 |
}, function (data) { |
| 40 |
jQuery('#infected_files').removeClass('wtotem_loader_spinner').html(data.content); |
| 41 |
jQuery('.infected_files__pagination').html(data.pagination); |
| 42 |
jQuery('#wtotem_notifications').html(data.notifications); |
| 43 |
}); |
| 44 |
}); |
| 45 |
|
| 46 |
jQuery('.quarantine_files__pagination').on('click', 'a.wtotem_pagination__number', function (e) { |
| 47 |
e.preventDefault(); |
| 48 |
jQuery('#quarantine_files').addClass('wtotem_loader_spinner'); |
| 49 |
jQuery.post(ajaxurl, { |
| 50 |
action: 'wtotem_ajax', |
| 51 |
ajax_action: 'pagination', |
| 52 |
wtotem_page_nonce: '{{ page_nonce }}', |
| 53 |
service: 'quarantine', |
| 54 |
current_page: jQuery(this).attr('data-page'), |
| 55 |
}, function (data) { |
| 56 |
jQuery('#quarantine_files').removeClass('wtotem_loader_spinner').html(data.content); |
| 57 |
jQuery('.quarantine_files__pagination').html(data.pagination); |
| 58 |
jQuery('#wtotem_notifications').html(data.notifications); |
| 59 |
}); |
| 60 |
}); |
| 61 |
|
| 62 |
jQuery('.wtotem_body').on('click', '.wt_infected__item', function (e) { |
| 63 |
let wrap = jQuery(this); |
| 64 |
wrap.toggleClass('antivirus-quarantine__item--open') |
| 65 |
.find('.antivirus-quarantine__item-chevron').toggleClass('antivirus-quarantine__item-chevron--open'); |
| 66 |
wrap.find('.antivirus-quarantine__item-full').toggleClass('visually-hidden'); |
| 67 |
}).on('click', '.antivirus-quarantine__tab', function (e) { |
| 68 |
jQuery('.antivirus-quarantine__tab').toggleClass('antivirus-quarantine__tab--active'); |
| 69 |
jQuery('.antivirus-quarantine').find('.antivirus-quarantine__items-container').toggleClass('antivirus-quarantine__items-container--active'); |
| 70 |
}).on('click', '.remove_from_quarantine', function (e) { |
| 71 |
quarantine_ajax('remove', jQuery(this).attr('data-path')); |
| 72 |
}).on('click', '.add_to_quarantine', function (e) { |
| 73 |
quarantine_ajax('add', jQuery(this).attr('data-path')); |
| 74 |
}); |
| 75 |
|
| 76 |
}); |
| 77 |
</script> |
| 78 |
|
| 79 |
<div class="wt_card antivirus-quarantine"> |
| 80 |
<div class="wt-flex-between"> |
| 81 |
<div class="wt-card-title wt-flex-1 wt-flex-middle wt-gap-row-4"> |
| 82 |
<button class="antivirus-quarantine__tab antivirus-quarantine__tab--active"> |
| 83 |
{{ 'Infected'|trans }} <span class="num" id="infected_files_total">{{ infected_files_total }}</span> |
| 84 |
</button> |
| 85 |
<button class="antivirus-quarantine__tab" style="margin-left: 15px;"> |
| 86 |
{{ 'Quarantine'|trans }} <span class="num" id="quarantine_files_total">{{ quarantine_files_total }}</span> |
| 87 |
</button> |
| 88 |
</div> |
| 89 |
</div> |
| 90 |
<div class="antivirus-quarantine__items-container antivirus-quarantine__items-container--active"> |
| 91 |
<div id="infected_files"> |
| 92 |
{% include 'quarantine_logs.html.twig' with {'logs': infected_files, 'type': 'infected'} %} |
| 93 |
</div> |
| 94 |
|
| 95 |
<div class="infected_files__pagination">{{ infected_files_pagination | raw }}</div> |
| 96 |
</div> |
| 97 |
<div class="antivirus-quarantine__items-container"> |
| 98 |
<div id="quarantine_files"> |
| 99 |
{% include 'quarantine_logs.html.twig' with {'logs': quarantine_files, 'type': 'quarantine'} %} |
| 100 |
</div> |
| 101 |
<div class="quarantine_files__pagination">{{ quarantine_files_pagination | raw }}</div> |
| 102 |
</div> |
| 103 |
</div> |