Update templates/index.html
Browse files- templates/index.html +73 -47
templates/index.html
CHANGED
@@ -783,53 +783,78 @@
|
|
783 |
return html;
|
784 |
}
|
785 |
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
833 |
// New analysis button functionality
|
834 |
newAnalysisButton.addEventListener('click', function() {
|
835 |
// Reset form and hide results
|
@@ -851,5 +876,6 @@
|
|
851 |
}, 2000);
|
852 |
});
|
853 |
</script>
|
|
|
854 |
</body>
|
855 |
</html>
|
|
|
783 |
return html;
|
784 |
}
|
785 |
|
786 |
+
// Fallback print via hidden iframe
|
787 |
+
function printViaIframe(html) {
|
788 |
+
const iframe = document.getElementById('printFrame');
|
789 |
+
const doc = iframe.contentWindow.document;
|
790 |
+
doc.open();
|
791 |
+
doc.write(html);
|
792 |
+
doc.close();
|
793 |
+
iframe.contentWindow.focus();
|
794 |
+
iframe.contentWindow.print();
|
795 |
+
}
|
796 |
+
|
797 |
+
// Updated click handler for "Print Report"
|
798 |
+
printButton.addEventListener('click', function() {
|
799 |
+
// Make sure there's something to print
|
800 |
+
const content = markdownContent.innerHTML;
|
801 |
+
if (!content.trim()) {
|
802 |
+
showError('Nothing to print yet.');
|
803 |
+
return;
|
804 |
+
}
|
805 |
+
|
806 |
+
// Build the full HTML for printing
|
807 |
+
const printHTML = `
|
808 |
+
<!DOCTYPE html>
|
809 |
+
<html>
|
810 |
+
<head>
|
811 |
+
<title>Medical Report & Prescription</title>
|
812 |
+
<style>
|
813 |
+
body { font-family: Arial, sans-serif; line-height: 1.6; padding: 20px; }
|
814 |
+
h1 { color: #1a365d; font-size: 24px; margin-bottom: 20px; }
|
815 |
+
h2 { color: #2c5282; font-size: 20px; margin-top: 25px; margin-bottom: 10px; }
|
816 |
+
h3 { color: #2d3748; font-size: 18px; margin-top: 20px; margin-bottom: 10px; }
|
817 |
+
p { margin-bottom: 15px; text-align: justify; }
|
818 |
+
ul, ol { padding-left: 25px; margin: 10px 0; }
|
819 |
+
li { margin-bottom: 8px; }
|
820 |
+
.header { text-align: center; margin-bottom: 30px; padding-bottom: 10px; border-bottom: 1px solid #ccc; }
|
821 |
+
.footer { text-align: center; margin-top: 30px; padding-top: 10px; border-top: 1px solid #ccc; font-size: 12px; color: #718096; }
|
822 |
+
.justified { text-align: justify; text-justify: inter-word; }
|
823 |
+
@media print {
|
824 |
+
body { margin: 0; padding: 15px; }
|
825 |
+
.no-print { display: none; }
|
826 |
+
}
|
827 |
+
</style>
|
828 |
+
</head>
|
829 |
+
<body>
|
830 |
+
<div class="header">
|
831 |
+
<h1>Medical Report & Prescription</h1>
|
832 |
+
<p>Generated on: ${new Date().toLocaleDateString()} at ${new Date().toLocaleTimeString()}</p>
|
833 |
+
</div>
|
834 |
+
${content}
|
835 |
+
<div class="footer">
|
836 |
+
<p>This report was generated by Medical Report & Prescription Generator.</p>
|
837 |
+
<p>Please consult with your healthcare provider before making any changes to your treatment.</p>
|
838 |
+
</div>
|
839 |
+
</body>
|
840 |
+
</html>
|
841 |
+
`;
|
842 |
+
|
843 |
+
// Try opening a new window
|
844 |
+
const printWindow = window.open('', '_blank');
|
845 |
+
if (printWindow) {
|
846 |
+
// We got a window → proceed as before
|
847 |
+
printWindow.document.write(printHTML);
|
848 |
+
printWindow.document.close();
|
849 |
+
setTimeout(() => printWindow.print(), 500);
|
850 |
+
} else {
|
851 |
+
// Popup was blocked → fallback to iframe
|
852 |
+
alert('Pop-up blocked! Using in-page print instead.');
|
853 |
+
printViaIframe(printHTML);
|
854 |
+
}
|
855 |
+
});
|
856 |
+
|
857 |
+
|
858 |
// New analysis button functionality
|
859 |
newAnalysisButton.addEventListener('click', function() {
|
860 |
// Reset form and hide results
|
|
|
876 |
}, 2000);
|
877 |
});
|
878 |
</script>
|
879 |
+
<iframe id="printFrame" style="display:none;"></iframe>
|
880 |
</body>
|
881 |
</html>
|