From 0f554c6d51aafe055312e7877c6584ed7543d896 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Wed, 21 May 2025 14:07:34 +0900 Subject: [PATCH] Consoliate all debug-related variables under the Rhymix object --- classes/display/DisplayHandler.class.php | 2 +- common/js/common.js | 5 +++-- common/js/debug.js | 10 +++++----- common/js/xml_handler.js | 12 ++++++------ 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/classes/display/DisplayHandler.class.php b/classes/display/DisplayHandler.class.php index 1d2fd8194..be853571b 100644 --- a/classes/display/DisplayHandler.class.php +++ b/classes/display/DisplayHandler.class.php @@ -257,7 +257,7 @@ class DisplayHandler extends Handler case 'HTML': $json_options = defined('JSON_PRETTY_PRINT') ? (JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : 0; $panel_script = sprintf('', RX_BASEURL, 'common/js/debug.js', filemtime(RX_BASEDIR . 'common/js/debug.js')); - $panel_script .= "\n"; + $panel_script .= "\n"; $body_end_position = strrpos($output, '') ?: strlen($output); $output = substr($output, 0, $body_end_position) . "\n$panel_script\n" . substr($output, $body_end_position); break; diff --git a/common/js/common.js b/common/js/common.js index f61be2fb7..01452cb89 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -13,6 +13,7 @@ const Rhymix = { addedDocument: [], loadedPopupMenus: [], openWindowList: {}, + currentDebugData: null, pendingDebugData: [], showAjaxErrors: ['ALL'], unloading: false, @@ -468,8 +469,8 @@ Rhymix.ajaxSuccessHandler = function(xhr, textStatus, action, data, params, succ // Add debug information. if (data._rx_debug) { data._rx_debug.page_title = "AJAX : " + action; - if (window.rhymix_debug_add_data) { - window.rhymix_debug_add_data(data._rx_debug); + if (this.addDebugData) { + this.addDebugData(data._rx_debug); } else { this.pendingDebugData.push(data._rx_debug); } diff --git a/common/js/debug.js b/common/js/debug.js index 07b602831..9214ec41f 100644 --- a/common/js/debug.js +++ b/common/js/debug.js @@ -40,7 +40,7 @@ $(function() { })); // Define a function for adding debug data to the panel. - window.rhymix_debug_add_data = function(data, open) { + Rhymix.addDebugData = function(data, open) { // Define loop variables. var i, j, entry, num, cnt, backtrace, description; @@ -238,15 +238,15 @@ $(function() { }; // Add debug data from the current request. - if (window.rhymix_debug_content) { - window.rhymix_debug_content.page_title = 'MAIN PAGE'; - rhymix_debug_add_data(window.rhymix_debug_content, true); + if (Rhymix.currentDebugData) { + Rhymix.currentDebugData.page_title = 'MAIN PAGE'; + Rhymix.addDebugData(Rhymix.currentDebugData, true); } // Add debug data from pending AJAX requests. if (Rhymix.pendingDebugData) { while (Rhymix.pendingDebugData.length) { - rhymix_debug_add_data(Rhymix.pendingDebugData.shift()); + Rhymix.addDebugData(Rhymix.pendingDebugData.shift()); } } }); diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index d9c12f07e..f94c5a45d 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -60,10 +60,10 @@ // Add debug information. if (data._rx_debug) { data._rx_debug.page_title = "AJAX : " + params.module + "." + params.act; - if (window.rhymix_debug_add_data) { - window.rhymix_debug_add_data(data._rx_debug); + if (Rhymix.addDebugData) { + Rhymix.addDebugData(data._rx_debug); } else { - window.rhymix_debug_pending_data.push(data._rx_debug); + Rhymix.pendingDebugData.push(data._rx_debug); } } @@ -226,10 +226,10 @@ // Add debug information. if (data._rx_debug) { data._rx_debug.page_title = "AJAX : " + request_info; - if (window.rhymix_debug_add_data) { - window.rhymix_debug_add_data(data._rx_debug); + if (Rhymix.addDebugData) { + Rhymix.addDebugData(data._rx_debug); } else { - window.rhymix_debug_pending_data.push(data._rx_debug); + Rhymix.pendingDebugData.push(data._rx_debug); } }