Changed the function displayDebug, now using a div with a 'debug-target-container' to place the debug bar'

This commit is contained in:
2026-08-04 16:39:17 +01:00
parent 5f0cf85abe
commit 34de1baaa5
3 changed files with 28 additions and 8 deletions
+25 -7
View File
@@ -82,25 +82,26 @@ function debugStatusMes( string $Message, string $intensity) {
}
}
// DISPLAY DEBUG ERROR FOOTER BAR
function displayDebugFooter() {
// DISPLAY DEBUG ERROR BAR
function displayDebug() {
global $debug, $debug_messages;
if ($debug !== "on") {
return;
}
echo '<div id="debug-footer-container" style="background: #222; color: #fff; padding: 15px; font-family: monospace; border-top: 3px solid #ff4444; margin-top: 30px;">';
echo '<h3>⚙️ Debug Status Messages</h3>';
// Contenitore temporaneo nascosto per non creare sfarfallii nella pagina
echo '<div id="debug-source-content" style="display: none;">';
echo '<div style="background: #222; color: #fff; padding: 15px; font-family: monospace; border-bottom: 3px solid #ff4444; border-top: 3px solid #ff4444; margin-bottom: 20px;">';
echo '<h3 style="margin-bottom:5px;">⚙️ Debug Status Messages</h3>';
foreach ($debug_messages as $level => $messages) {
if (!empty($messages)) {
// Assegna un colore diverso in base alla gravità
$color = '#d3fcc8'; // Default Low
$color = '#6cef93';
if ($level === 'High') $color = '#ff4444';
if ($level === 'Medium') $color = '#ffbb33';
echo "<div class='debug-group' style='margin-bottom: 10px;'>";
echo "<div style='margin-bottom: 10px;'>";
echo "<strong style='color: $color;'>[" . $level . "]</strong>";
echo "<ul style='margin: 5px 0; padding-left: 20px;'>";
foreach ($messages as $msg) {
@@ -111,4 +112,21 @@ function displayDebugFooter() {
}
}
echo '</div>';
echo '</div>';
// Questo script JS prende il contenuto appena generato e lo sposta nel segnaposto in cima
?>
<script>
document.addEventListener("DOMContentLoaded", function() {
const source = document.getElementById('debug-source-content');
const target = document.getElementById('debug-target-container');
if (source && target) {
// Sposta l'HTML dentro il contenitore all'inizio del body
target.innerHTML = source.innerHTML;
// Rimuove il vecchio elemento nascosto per pulizia
source.remove();
}
});
</script>
<?php
}