woocommerce/assets/js/admin/system-status.min.js

1 line
1.8 KiB
JavaScript

jQuery(function(c){({init:function(){c(document.body).on("click","a.help_tip, a.woocommerce-help-tip",this.preventTipTipClick).on("click","a.debug-report",this.generateReport).on("click","#copy-for-support",this.copyReport).on("aftercopy","#copy-for-support",this.copySuccess).on("aftercopyfailure","#copy-for-support",this.copyFail)},preventTipTipClick:function(){return!1},generateReport:function(){var a="";c(".wc_status_table thead, .wc_status_table tbody").each(function(){if(c(this).is("thead")){var t=c(this).find("th:eq(0)").data("export-label")||c(this).text();a=a+"\n### "+c.trim(t)+" ###\n\n"}else c("tr",c(this)).each(function(){var t=c(this).find("td:eq(0)").data("export-label")||c(this).find("td:eq(0)").text(),e=c.trim(t).replace(/(<([^>]+)>)/gi,""),i=c(this).find("td:eq(2)").clone();i.find(".private").remove(),i.find(".dashicons-yes").replaceWith("&#10004;"),i.find(".dashicons-no-alt, .dashicons-warning").replaceWith("&#10060;");var o=c.trim(i.text()),n=o.split(", ");if(1<n.length){var r="";c.each(n,function(t,e){r=r+e+"\n"}),o=r}a=a+""+e+": "+o+"\n"})});try{return c("#debug-report").slideDown(),c("#debug-report").find("textarea").val("`"+a+"`").focus().select(),c(this).fadeOut(),!1}catch(t){console.log(t)}return!1},copyReport:function(t){wcClearClipboard(),wcSetClipboard(c("#debug-report").find("textarea").val(),c(this)),t.preventDefault()},copySuccess:function(){c("#copy-for-support").tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).focus()},copyFail:function(){c(".copy-error").removeClass("hidden"),c("#debug-report").find("textarea").focus().select()}}).init(),c("#log-viewer-select").on("click","h2 a.page-title-action",function(t){return t.stopImmediatePropagation(),window.confirm(woocommerce_admin_system_status.delete_log_confirmation)})});