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

1 line
1.8 KiB
JavaScript

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