Skip to content

Commit

Permalink
Tracy Exceptions bug fixes - script load and clearing while retaining…
Browse files Browse the repository at this point in the history
… footer element as needed by Tracy core.
  • Loading branch information
adrianbj committed Jul 5, 2023
1 parent da82fd1 commit 13a4462
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
'version' => '4.25.0',
'version' => '4.25.2',
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down
15 changes: 13 additions & 2 deletions panels/TracyExceptionsPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,33 @@ public function getTab() {

public function getPanel() {

$tracyModuleUrl = $this->wire('config')->urls->TracyDebugger;

$filePath = $this->wire('config')->paths->root . $this->tracyExceptionFile;

$maximizeSvg = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="282.8 231 16 15.2" enable-background="new 282.8 231 16 15.2" xml:space="preserve"><polygon fill="#AEAEAE" points="287.6,233.6 298.8,231 295.4,242 "/><polygon fill="#AEAEAE" points="293.9,243.6 282.8,246.2 286.1,235.3 "/></svg>';

$out = <<< HTML
<script>
var tracyExceptionsViewer = {};
var tracyExceptionsViewer = {
tracyModuleUrl: "$tracyModuleUrl",
};
function clearTracyExceptionsViewer() {
document.getElementById("panelTitleFilePath").innerHTML = '';
if(document.getElementById('tracy-bs')) {
document.getElementById('tracy-bs').remove();
var bs = document.getElementById('tracy-bs');
while (bs.firstChild) {
bs.removeChild(bs.firstChild);
}
const footer = document.createElement("footer");
bs.appendChild(footer);
}
}
tracyJSLoader.load(tracyExceptionsViewer.tracyModuleUrl + "scripts/exception-loader.js");
</script>
HTML;
Expand Down
8 changes: 4 additions & 4 deletions scripts/exception-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ if(!tracyExceptionLoader) {

document.getElementById("tracyExceptionFilePath").value = filePath;
document.cookie = "tracyExceptionFile=" + filePath + "; path=/";
if(document.getElementById('tracy-bs')) {
document.getElementById('tracy-bs').remove();
}
document.getElementById("panelTitleFilePath").innerHTML = filePath.replace('site/assets/logs/tracy/', '');

var xmlhttp;
Expand All @@ -37,8 +34,11 @@ if(!tracyExceptionLoader) {
if(xmlhttp.readyState == XMLHttpRequest.DONE) {
if(xmlhttp.status == 200 && xmlhttp.responseText !== "" && xmlhttp.responseText !== "[]") {
var fileData = JSON.parse(xmlhttp.responseText);
if(document.getElementById('tracy-bs')) {
document.getElementById('tracy-bs').remove();
}
document.getElementById("tracyExceptionsViewerCode").innerHTML = fileData.contents;
document.getElementById("tracy-bs").style.zIndex = "100"
document.getElementById("tracy-bs").style.zIndex = "100";
}
xmlhttp.getAllResponseHeaders();
}
Expand Down

0 comments on commit 13a4462

Please sign in to comment.