Skip to content

Commit

Permalink
add debug dump button
Browse files Browse the repository at this point in the history
  • Loading branch information
sjpadgett committed Jun 21, 2024
1 parent 90c325c commit f99cf61
Showing 1 changed file with 42 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
exit;
}

$urlOut = $newRxUrl . urlencode($provider_info['email']) . "&data=" . urlencode($urlParam);

?>
<!doctype html>
<html lang="en">
Expand Down Expand Up @@ -110,15 +112,15 @@
<script>
$(function () {
$('#form_reset_key').addClass('d-none');
/* Toggle reset button. */
<?php if ((int)$isValidKey > 997) { ?>
/* Toggle reset button. */
<?php if ((int)$isValidKey > 997) { ?>
$(function () {
const warnMsg = "<?php echo xlt('Internet connection problem. Returning to Patient chart when alert closes!'); ?>";
syncAlertMsg(warnMsg, 8000, 'danger', 'lg').then(() => {
window.location.href = "<?php echo $GLOBALS['web_root'] ?>/interface/patient_file/summary/demographics.php?set_pid=<?php echo urlencode(attr($_SESSION['pid'] ?? $pid ?? '')) ?>";
});
});
<?php } else if (!$isValidKey) { ?>
<?php } else if (!$isValidKey) { ?>
$(function () {
$('#form_reset_key').removeClass('d-none');
const warnMsg = "<?php
Expand All @@ -127,18 +129,44 @@
xlt('Afterwards you may continue and no other action is required by you.'); ?>";
syncAlertMsg(warnMsg, 8000, 'danger', 'lg');
});
<?php } else { ?>
$(function () {
$('#form_reset_key').addClass('d-none');
});
<?php } ?>
<?php } else { ?>
$(function () {
$('#form_reset_key').addClass('d-none');
});
<?php } ?>
});
$(function () {
// Function to generate debug info and create a downloadable file
function generateDebugInfo() {
let debugInfo = 'Debug Information:';
debugInfo += '\n- User Agent:' + navigator.userAgent;
debugInfo += '\n- Platform:' + navigator.platform;
debugInfo += '\n- Language:' + navigator.language;
debugInfo += '\n\n- URL:\n <?php echo js_escape($urlOut); ?>';
debugInfo += '\n\n- Data Raw:\n <?php echo js_escape($urlParam); ?>';
debugInfo += '\n\n- Encoded Data:\n <?php echo js_escape(urlencode($urlParam)); ?>';

const blob = new Blob([debugInfo], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
$('#downloadLink').attr('href', url);
}

// Event handler for double-click on the trigger button
$('#trigger-debug').dblclick(function () {
generateDebugInfo();
$('#debugModal').modal('show');
});
$('#triggerButton').click(function () {
generateDebugInfo();
$('#debugModal').modal('show');
});
$('#downloadLink').click(function () {
$('#debugModal').modal('hide');
});
});
</script>
</head>
<body>
<?php
$urlOut = $newRxUrl . urlencode($provider_info['email']) . "&data=" . urlencode($urlParam);
?>
<div id="trigger-debug" class="container-xl">
<div class="container-xl sticky-container bg-light text-dark">
<form>
Expand Down Expand Up @@ -191,23 +219,18 @@
</div>
</div>
<div class="container-xl mt-3">
<iframe id="wenoIfram"
title="Weno IFRAME"
width="100%"
height="900"
src="<?php echo $urlOut; ?>">
</iframe>
<iframe id="wenoIfram" title="Weno IFRAME" width="100%" height="900" src="<?php echo $urlOut; ?>"></iframe>
</div>
<footer>
<a href="<?php echo $GLOBALS['web_root'] ?>/interface/patient_file/summary/demographics.php?set_pid=<?php echo urlencode(attr($_SESSION['pid'] ?? $pid)) ?>" class="btn btn-primary float-right mt-2 mb-4 mr-3"><?php echo xlt("Return to Demographics"); ?></a>
<button id="triggerButton" class="btn btn-primary btn-sm m-2 ml-3"><?php echo xlt("Debug"); ?></button>
<button id="triggerButton" class="btn btn-primary btn-sm m-2 ml-3" title="<?php echo xla("Download debug information to send to Weno support."); ?>"><i class="fa-solid fa-bug"></i></button>
</footer>
<!-- Modal Structure -->
<div class="modal fade" id="debugModal" tabindex="-1" role="dialog" aria-labelledby="debugModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="debugModalLabel"><?php echo xlt("Debug Information"); ?></h5>
<h5 class="modal-title" id="debugModalLabel"><?php echo xlt("Weno Debug Information"); ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
Expand All @@ -222,33 +245,6 @@
</div>
</div>
</div>
<script>
$(document).ready(function() {
// Function to generate debug info and create a downloadable file
function generateDebugInfo() {
let debugInfo = 'Debug Information:';
debugInfo += '\n\n- User Agent:' + navigator.userAgent;
debugInfo += '\n\n- Platform:' + navigator.platform;
debugInfo += '\n\n- Language:' + navigator.language;
debugInfo += '\n\n- URL: <?php echo js_escape($urlOut); ?>';
debugInfo += '\n\n- Data Raw: <?php echo js_escape($urlParam); ?>';
debugInfo += '\n\n- Encoded Data: <?php echo js_escape(urlencode($urlParam)); ?>';

const blob = new Blob([debugInfo], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
$('#downloadLink').attr('href', url);
}
// Event handler for double-click on the trigger button
$('#trigger-debug').dblclick(function() {
generateDebugInfo();
$('#debugModal').modal('show');
});
$('#triggerButton').click(function() {
generateDebugInfo();
$('#debugModal').modal('show');
});
});
</script>
</div>
</body>
</html>

0 comments on commit f99cf61

Please sign in to comment.