jQuery(document).ready((function($){function e(e){jQuery("#wf-sn-core-scanner-response").show(),jQuery("#wf-sn-core-scanner-response #sn-cs-results").slideUp(),jQuery("#wf-sn-core-scanner-response .spinner").addClass("is-active");var n={action:"sn_core_run_scan",_ajax_nonce:wf_sn_cs.nonce};e&&(n.doupdate=!0),$.post(ajaxurl,n,(function(e){jQuery("#wf-sn-core-scan-details .spinner").removeClass("is-active"),e.data.out&&(jQuery("#wf-sn-core-scanner-response").replaceWith(e.data.out).slideDown(),jQuery("#wf-sn-core-scan-details #files_checked").html(e.data.files_checked).slideDown(),jQuery("#wf-sn-core-scan-details #wp_version").html(e.data.wp_version).slideDown()),e.data.last_scan&&jQuery("#wf-sn-core-scan-details #last_scan").html(e.data.last_scan).slideDown()}),"json")}e(),$("button.sn-show-source").on("click",(function(){return $($(this).attr("href")).dialog("option",{title:wf_sn_cs.strings.file_source+": "+$(this).attr("data-file"),file_path:$(this).attr("data-file"),file_hash:$(this).attr("data-hash")}).dialog("open"),!1})),$(document).on("click","a.sn-restore-source",(function(n){if(n.preventDefault(),!confirm(wf_sn_cs.strings.confirm_restore))return!1;jQuery(this).attr("disabled","disabled");var s=jQuery(this).attr("data-file"),a=jQuery(this).attr("data-hash"),t=jQuery(this).attr("data-nonce");jQuery.post(ajaxurl,{action:"sn_core_restore_file_do",_ajax_nonce:wf_sn_cs.nonce,filename:s,hash:a,nonce:t},(function(n){1===n?jQuery('[data-hash="'+a+'"]').closest("li").fadeOut("slow",(function(){jQuery(this).remove(),e(!0)})):(jQuery("#wf-sn-core-scanner-response").append('<p class="error">Error deleting file</p>'),jQuery(this).removeAttr("disabled"))}),"json")})),$(document).on("click","button.sn-delete-source, a.sn-delete-source",(function(e){if(e.preventDefault(),!confirm(wf_sn_cs.strings.confirm_delete))return!1;jQuery(this).attr("disabled","disabled");var n=jQuery(this).attr("data-file"),s=jQuery(this).attr("data-hash"),a=jQuery(this).attr("data-nonce");jQuery.post(ajaxurl,{action:"sn_core_delete_file_do",_ajax_nonce:wf_sn_cs.nonce,filename:n,hash:s,nonce:a},(function(e){e.success?jQuery('[data-hash="'+s+'"]').closest("li").fadeOut("slow",(function(){jQuery(this).remove()})):(alert(wf_sn_cs.strings.error_occurred+": "+e),jQuery(this).attr("disabled",""))}),"json")})),$(document).on("click","button.sn-delete-all-files",(function(e){if(e.preventDefault(),!confirm(wf_sn_cs.strings.confirm_delete_all))return!1;jQuery(this).attr("disabled","disabled"),jQuery.ajax({url:ajaxurl,type:"POST",data:{action:"sn_core_delete_all_unknowns",_ajax_nonce:wf_sn_cs.delete_all_nonce},success:function(){window.location.reload()},error:function(){alert(wf_sn_cs.strings.ajax_error)}})})),$(document).on("click","#sn-run-core-scan",(function(e){e.preventDefault(),jQuery("#wf-sn-core-scanner-response .spinner").addClass("is-active"),jQuery.post(ajaxurl,{action:"sn_core_run_scan",_ajax_nonce:wf_sn_cs.nonce,datatype:"json",doupdate:!0},(function(e){jQuery("#wf-sn-core-scanner-response .spinner").removeClass("is-active"),e.data.out&&jQuery("#wf-sn-core-scanner-response").append(e.data.out).slideDown(),e.data.last_scan&&jQuery("#wf-sn-core-scanner-response #last_scan").html(e.data.last_scan).slideDown(),e.data.files_checked&&jQuery("#wf-sn-core-scanner-response #files_checked").html(e.data.files_checked).slideDown(),e.data.wp_version&&jQuery("#wf-sn-core-scanner-response #wp_version").html(e.data.wp_version).slideDown(),e.data.next_scan&&jQuery("#wf-sn-core-scanner-response #next_scan").html(e.data.next_scan).slideDown(),location.reload()}))}))}));