1 line
2.0 KiB
JavaScript
1 line
2.0 KiB
JavaScript
jQuery(function(n){({init:function(){n(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 r="";n(".wc_status_table thead, .wc_status_table tbody").each(function(){var t;n(this).is("thead")?(t=n(this).find("th:eq(0)").data("exportLabel")||n(this).text(),r=r+"\n### "+t.trim()+" ###\n\n"):n("tr",n(this)).each(function(){var t=(n(this).find("td:eq(0)").data("exportLabel")||n(this).find("td:eq(0)").text()).trim().replace(/(<([^>]+)>)/gi,""),e=n(this).find("td:eq(2)").clone();e.find(".private").remove(),e.find(".dashicons-yes").replaceWith("✔"),e.find(".dashicons-no-alt, .dashicons-warning").replaceWith("❌");var o,i=e.text().trim(),e=i.split(", ");1<e.length&&(o="",n.each(e,function(t,e){o=o+e+"\n"}),i=o),r=r+""+t+": "+i+"\n"})});try{return n("#debug-report").slideDown(),n("#debug-report").find("textarea").val("`"+r+"`").trigger("focus").trigger("select"),n(this).fadeOut(),!1}catch(t){console.log(t)}return!1},copyReport:function(t){wcClearClipboard(),wcSetClipboard(n("#debug-report").find("textarea").val(),n(this)),t.preventDefault()},copySuccess:function(){n("#copy-for-support").tipTip({attribute:"data-tip",activation:"focus",fadeIn:50,fadeOut:50,delay:0}).trigger("focus")},copyFail:function(){n(".copy-error").removeClass("hidden"),n("#debug-report").find("textarea").trigger("focus").trigger("select")}}).init(),n(".wc_status_table").on("click",".run-tool .button",function(t){return t.stopImmediatePropagation(),window.confirm(woocommerce_admin_system_status.run_tool_confirmation)}),n("#log-viewer-select").on("click","h2 a.page-title-action",function(t){return t.stopImmediatePropagation(),window.confirm(woocommerce_admin_system_status.delete_log_confirmation)})}); |