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("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 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,""),n=t(this).find("td:eq(2)").clone();n.find(".private").remove(),n.find(".dashicons-yes").replaceWith("&#10004;"),n.find(".dashicons-no-alt, .dashicons-warning").replaceWith("&#10060;");var r=t.trim(n.text()),a=r.split(", ");if(a.length>1){var c="";t.each(a,function(t,e){c=c+e+"\n"}),r=c}e=e+""+o+": "+r+"\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){wcClearClipboard(),wcSetClipboard(t("#debug-report").find("textarea").val(),t(this)),e.preventDefault()},copySuccess:function(){t("#copy-for-support").tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).focus()},copyFail:function(){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)})});