| 1 |
const CharitableSystemInfo=window.CharitableSystemInfo||function(e,a,t){const i={init(){t(i.ready)},ready(){i.events()},events(){t(e).on("click","#charitable-system-information-copy",function(e){e.preventDefault(),i.copySystemInformation()}),t(e).on("click","#charitable-ssl-verify",function(e){e.preventDefault(),i.verifySSLConnection()}),t(e).on("click","#charitable-email-diagnostics",function(e){e.preventDefault(),i.runEmailDiagnostics()}),t(e).on("click","#charitable-send-test-email",function(e){e.preventDefault(),i.sendTestEmail()}),t(e).on("click","#charitable-email-diagnostics-copy",function(e){e.preventDefault(),i.copyEmailDiagnostics()}),t(e).on("click","#charitable-toggle-error-logs",function(e){e.preventDefault(),i.toggleErrorLogs()}),t(e).on("click","#charitable-clear-error-logs",function(e){e.preventDefault(),i.clearErrorLogs()}),t(e).on("click","#charitable-export-error-logs",function(e){e.preventDefault(),i.exportErrorLogs()}),t(e).on("click","#charitable-debug-log-scan",function(e){e.preventDefault(),i.runDebugLogScan()}),t(e).on("click",".charitable-format-tab",function(e){e.preventDefault(),i.switchDebugFormat(t(this))}),t(e).on("click","#charitable-debug-copy",function(e){e.preventDefault(),i.copyDebugResults()})},copySystemInformation(){t("#charitable-system-information").select(),e.execCommand("copy")},verifySSLConnection(){const e=t("#charitable-ssl-verify"),a=e.text(),i=e.outerWidth(),o=e.parent();if("undefined"!=typeof charitable_admin_tools&&void 0!==charitable_admin_tools.ajax_url&&void 0!==charitable_admin_tools.nonce&&void 0!==charitable_admin_tools.testing){e.css("width",i).prop("disabled",!0).text(charitable_admin_tools.testing);const s={action:"charitable_verify_ssl",nonce:charitable_admin_tools.nonce};t.post(charitable_admin_tools.ajax_url,s,function(t){"undefined"!=typeof wpchar&&wpchar.debug(t),o.find(".charitable-notice").remove(),t.success&&e.before('<div class="notice charitable-notice notice-success">'+t.data.msg+"</div>"),!t.success&&t.data.msg&&e.before('<div class="notice charitable-notice notice-error">'+t.data.msg+"</div>"),!t.success&&t.data.debug&&e.before('<div class="charitable-ssl-error pre-error">'+t.data.debug+"</div>"),e.css("width",i).prop("disabled",!1).text(a)})}},runEmailDiagnostics(){const e=t("#charitable-email-diagnostics"),a=t("#charitable-email-diagnostics-results"),i=a.find("textarea"),o=t("#charitable-email-diagnostics-copy"),s=e.text(),r=e.outerWidth();if("undefined"!=typeof charitable_email_diagnostics){e.css("width",r).prop("disabled",!0).text(charitable_email_diagnostics.running_text),a.show(),i.val("Running diagnostics, please wait..."),o.hide(),e.parent().find(".charitable-notice").remove();const c={action:"charitable_email_diagnostics",nonce:charitable_email_diagnostics.nonce};t.post(charitable_email_diagnostics.ajax_url,c,function(a){if("undefined"!=typeof wpchar&&wpchar.debug(a),a.success&&a.data.diagnostics)i.val(a.data.diagnostics),o.show(),e.before('<div class="notice charitable-notice notice-success"><p>Email diagnostics completed successfully.</p></div>');else{let t=charitable_email_diagnostics.error_text;a.data&&a.data.message&&(t=a.data.message),i.val("### DIAGNOSTIC ERROR ###\n\n"+t),e.before('<div class="notice charitable-notice notice-error"><p>'+t+"</p></div>")}e.css("width",r).prop("disabled",!1).text(s)}).fail(function(a,t,o){const c="AJAX request failed: "+t+" - "+o;i.val("### DIAGNOSTIC ERROR ###\n\n"+c),e.before('<div class="notice charitable-notice notice-error"><p>Diagnostics request failed. Please try again.</p></div>'),e.css("width",r).prop("disabled",!1).text(s),"undefined"!=typeof wpchar&&wpchar.debug({xhr:a,status:t,error:o})})}else e.before('<div class="notice charitable-notice notice-error"><p>Email diagnostics not properly loaded. Please refresh the page and try again.</p></div>')},sendTestEmail(){const e=t("#charitable-send-test-email"),a=t("#charitable-test-email-message"),i=t("#charitable-test-email-message-text"),o=e.text();if("undefined"!=typeof charitable_email_diagnostics){e.prop("disabled",!0).text(charitable_email_diagnostics.sending_text||"Sending..."),a.hide(),e.parent().find(".charitable-notice").not("#charitable-test-email-message .charitable-notice").remove();const s={action:"charitable_send_test_email",nonce:charitable_email_diagnostics.test_email_nonce};t.post(charitable_email_diagnostics.ajax_url,s,function(t){if("undefined"!=typeof wpchar&&wpchar.debug(t),t.success&&t.data.success)i.text(t.data.message),a.find(".charitable-notice").removeClass("notice-error").addClass("notice-success"),a.show();else{let e="Test email failed to send.";t.data&&t.data.message&&(e=t.data.message),i.text(e),a.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),a.show()}e.prop("disabled",!1).text(o)}).fail(function(t,s,r){i.text("Test email request failed. Please try again. If problems persist, contact support."),a.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),a.show(),e.prop("disabled",!1).text(o),"undefined"!=typeof wpchar&&wpchar.debug({xhr:t,status:s,error:r})})}else i.text("Test email functionality not properly loaded. Please refresh the page and try again."),a.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),a.show()},copyEmailDiagnostics(){const a=t("#charitable-email-diagnostics-results textarea");if(a.length){a.select(),e.execCommand("copy");const i=t("#charitable-email-diagnostics-copy"),o=i.text();i.text("Copied!"),setTimeout(function(){i.text(o)},2e3)}},toggleErrorLogs(){const e=t("#charitable-toggle-error-logs"),a=t("#charitable-error-logs-container");a.is(":visible")?(a.hide(),e.text("Show Error Logs")):(a.show(),e.text("Hide Error Logs"))},clearErrorLogs(){const e=t("#charitable-clear-error-logs"),a=t("#charitable-error-log-message"),i=t("#charitable-error-log-message-text"),o=e.text();if(confirm("Are you sure you want to clear all error logs? This action cannot be undone."))if("undefined"!=typeof charitable_admin_tools&&void 0!==charitable_admin_tools.ajax_url&&void 0!==charitable_admin_tools.nonce){e.prop("disabled",!0).text("Clearing..."),a.hide();const s={action:"charitable_clear_error_logs",nonce:charitable_admin_tools.nonce};t.post(charitable_admin_tools.ajax_url,s,function(t){if("undefined"!=typeof wpchar&&wpchar.debug(t),t.success)i.text(t.data.message),a.find(".charitable-notice").removeClass("notice-error").addClass("notice-success"),a.show(),setTimeout(function(){location.reload()},2e3);else{let e="Failed to clear error logs.";t.data&&t.data.message&&(e=t.data.message),i.text(e),a.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),a.show()}e.prop("disabled",!1).text(o)}).fail(function(t,s,r){i.text("Clear request failed. Please try again."),a.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),a.show(),e.prop("disabled",!1).text(o),"undefined"!=typeof wpchar&&wpchar.debug({xhr:t,status:s,error:r})})}else alert("Error log clearing not properly loaded. Please refresh the page and try again.")},exportErrorLogs(){const a=t("#charitable-export-error-logs"),i=t("#charitable-error-log-message"),o=t("#charitable-error-log-message-text"),s=a.text();if("undefined"!=typeof charitable_admin_tools&&void 0!==charitable_admin_tools.ajax_url&&void 0!==charitable_admin_tools.nonce){a.prop("disabled",!0).text("Exporting..."),i.hide();const r={action:"charitable_export_error_logs",nonce:charitable_admin_tools.nonce};t.post(charitable_admin_tools.ajax_url,r,function(t){if("undefined"!=typeof wpchar&&wpchar.debug(t),t.success&&t.data.content){const a=atob(t.data.content),s=new Blob([a],{type:"text/csv;charset=utf-8;"}),r=e.createElement("a");if(void 0!==r.download){const a=URL.createObjectURL(s);r.setAttribute("href",a),r.setAttribute("download",t.data.filename||"error-logs.csv"),r.style.visibility="hidden",e.body.appendChild(r),r.click(),e.body.removeChild(r)}o.text(t.data.message),i.find(".charitable-notice").removeClass("notice-error").addClass("notice-success"),i.show()}else{let e="Failed to export error logs.";t.data&&t.data.message&&(e=t.data.message),o.text(e),i.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),i.show()}a.prop("disabled",!1).text(s)}).fail(function(e,t,r){o.text("Export request failed. Please try again."),i.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),i.show(),a.prop("disabled",!1).text(s),"undefined"!=typeof wpchar&&wpchar.debug({xhr:e,status:t,error:r})})}else alert("Error log export not properly loaded. Please refresh the page and try again.")},runDebugLogScan(){const e=t("#charitable-debug-log-scan"),a=t("#charitable-debug-log-results"),o=t("#charitable-debug-log-message"),s=t("#charitable-debug-log-message-text"),r=e.text(),c=e.outerWidth();if("undefined"!=typeof charitable_admin_tools&&void 0!==charitable_admin_tools.ajax_url&&void 0!==charitable_admin_tools.nonce){e.css("width",c).prop("disabled",!0).text("Scanning logs..."),a.show(),t(".charitable-format-content").val("Scanning debug logs, please wait..."),o.hide(),e.parent().find(".charitable-notice").remove();const n={action:"charitable_debug_log_scan",nonce:charitable_admin_tools.nonce};t.post(charitable_admin_tools.ajax_url,n,function(a){if("undefined"!=typeof wpchar&&wpchar.debug(a),a.success&&a.data.scan_results){const e=a.data.scan_results;t("#charitable-debug-summary").val(e.summary||"No summary available."),t("#charitable-debug-technical").val(e.technical||"No technical details available."),t("#charitable-debug-forum").val(e.forum_ready||"No forum format available."),s.text("Debug log scan completed successfully."),o.find(".charitable-notice").removeClass("notice-error").addClass("notice-success"),o.show(),i.switchDebugFormat(t('.charitable-format-tab[data-format="summary"]'))}else{let e="Debug log scan failed.",i="";a.data&&a.data.message&&(e=a.data.message),a.data&&a.data.detailed_message&&(i=a.data.detailed_message);const r=i||"### DEBUG LOG SCAN ERROR ###\n\n"+e;t(".charitable-format-content").val(r),s.text(e),o.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),o.show()}e.css("width",c).prop("disabled",!1).text(r)}).fail(function(a,i,n){const l="Debug log scan request failed: "+i+" - "+n;t(".charitable-format-content").val("### DEBUG LOG SCAN ERROR ###\n\n"+l),s.text("Scan request failed. Please try again."),o.find(".charitable-notice").removeClass("notice-success").addClass("notice-error"),o.show(),e.css("width",c).prop("disabled",!1).text(r),"undefined"!=typeof wpchar&&wpchar.debug({xhr:a,status:i,error:n})})}else alert("Debug log scanner not properly loaded. Please refresh the page and try again.")},switchDebugFormat(e){const a=e.data("format");t(".charitable-format-tab").removeClass("active"),e.addClass("active"),t(".charitable-format-content").hide(),t("#charitable-debug-"+a).show()},copyDebugResults(){const a=t(".charitable-format-content:visible"),i=t("#charitable-debug-copy-message");a.length>0&&(a.select(),e.execCommand("copy"),i.fadeIn(200).delay(1500).fadeOut(200))}};return i}(document,window,jQuery);CharitableSystemInfo.init(); |