Repository navigation
Expand file tree
/
Copy pathreport.html
More file actions
850 lines (724 loc) · 35.6 KB
/
Copy pathreport.html
File metadata and controls
850 lines (724 loc) · 35.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
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
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Medical Report Viewer - Medical Diagnostics Platform</title>
<!-- Meta Information -->
<meta name="description"
content="View detailed medical diagnostic reports with AI-powered analysis and recommendations.">
<meta name="keywords" content="medical report, diagnostic analysis, breast density, mammography results">
<meta name="author" content="Medical Diagnostics Platform">
<!-- Favicon -->
<link rel="icon" type="image/svg+xml"
href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='40' fill='%230066cc'/><path d='M35 45h30v10H35z' fill='white'/><path d='M45 35h10v30H45z' fill='white'/></svg>">
<!-- CSS Files -->
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/components.css">
<link rel="stylesheet" href="css/medical-theme.css">
<!-- Font Loading -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<!-- Header with Navigation -->
<header class="header">
<div class="container">
<div class="header-content">
<!-- Logo and Branding -->
<a href="index.html" class="logo">
<div class="logo-icon">🏥</div>
<span>Medical Diagnostics</span>
</a>
<!-- Navigation Actions -->
<div class="nav-actions">
<a href="index.html" class="btn btn-secondary">
← Back to Dashboard
</a>
<button class="btn btn-secondary" id="print-report-btn">
🖨️ Print
</button>
<button class="btn btn-secondary" id="export-report-btn">
📄 Export
</button>
<button class="btn btn-secondary" id="download-pdf-btn">
📥 Download as PDF
</button>
</div>
</div>
</div>
</header>
<!-- Report Navigation -->
<nav class="report-navigation">
<div class="container">
<div class="breadcrumb">
<a href="index.html" class="breadcrumb-item">Dashboard</a>
<span class="breadcrumb-separator">/</span>
<span class="breadcrumb-item active" id="report-breadcrumb">Report</span>
</div>
<div class="report-meta-info">
<span class="report-meta-item">
<span class="medical-icon time"></span>
<span id="report-timestamp">Loading...</span>
</span>
<span class="report-meta-item">
<span class="medical-icon report"></span>
<span id="report-status">Processing</span>
</span>
</div>
</div>
</nav>
<!-- Main Report Content -->
<main class="main-content">
<div class="container-fluid">
<!-- Loading State -->
<div class="loading-state glass-card" id="report-loading" style="display: none;">
<div style="text-align: center; padding: var(--spacing-xxl);">
<div class="loading-spinner" style="margin: 0 auto var(--spacing-lg);"></div>
<h3>Loading Medical Report</h3>
<p>Please wait while we retrieve your diagnostic analysis...</p>
</div>
</div>
<!-- Error State -->
<div class="error-state glass-card" id="report-error" style="display: none;">
<div style="text-align: center; padding: var(--spacing-xxl);">
<div class="error-icon" style="font-size: 4rem; margin-bottom: var(--spacing-lg);">⚠️</div>
<h3>Report Not Found</h3>
<p id="error-message">The requested medical report could not be found or is no longer available.</p>
<a href="index.html" class="btn btn-primary" style="margin-top: var(--spacing-lg);">
Return to Dashboard
</a>
</div>
</div>
<!-- Report Container -->
<div class="report-container" id="report-container" style="display: none;">
<!-- Image Panel -->
<div class="image-panel">
<div class="image-viewer">
<div class="image-viewer-header">
<h4 class="image-title" id="image-title">Medical Image</h4>
<div class="image-controls">
<button class="image-control-btn tooltip" id="zoom-out" title="Zoom Out">
<span>−</span>
<span class="tooltip-content">Zoom Out</span>
</button>
<button class="image-control-btn tooltip" id="zoom-reset" title="Reset Zoom">
<span>⌂</span>
<span class="tooltip-content">Reset Zoom</span>
</button>
<button class="image-control-btn tooltip" id="zoom-in" title="Zoom In">
<span>+</span>
<span class="tooltip-content">Zoom In</span>
</button>
<button class="image-control-btn tooltip" id="fullscreen-btn" title="Fullscreen">
<span>⛶</span>
<span class="tooltip-content">Fullscreen</span>
</button>
<button class="image-control-btn tooltip" id="download-image" title="Download Image">
<span>⬇</span>
<span class="tooltip-content">Download</span>
</button>
</div>
</div>
<div class="image-display" id="image-display">
<img class="medical-image" id="medical-image" alt="Medical Image" src="">
<div class="zoom-indicator" id="zoom-indicator">100%</div>
<!-- Image Loading State -->
<div class="image-loading" id="image-loading">
<div class="loading-spinner"></div>
<p>Loading medical image...</p>
</div>
<!-- Image Error State -->
<div class="image-error" id="image-error" style="display: none;">
<div class="error-icon">📷</div>
<p>Failed to load medical image</p>
</div>
</div>
</div>
</div>
<!-- Report Panel -->
<div class="report-panel">
<div class="report-header">
<h3 class="report-title">Diagnostic Analysis Report</h3>
<div class="report-meta">
<div class="report-meta-item">
<span class="medical-icon report"></span>
<span>Report ID: <span id="header-report-id">N/A</span></span>
</div>
<div class="report-meta-item">
<span class="medical-icon calendar"></span>
<span>Analysis Date: <span id="header-analysis-date">N/A</span></span>
</div>
<div class="report-meta-item">
<span class="medical-icon patient"></span>
<span>File: <span id="header-filename">N/A</span></span>
</div>
</div>
</div>
<div class="report-content" id="report-content">
<!-- Table of Contents -->
<div class="table-of-contents" id="table-of-contents" style="display: none;">
<h4>Table of Contents</h4>
<ul id="toc-list">
<!-- TOC items will be generated automatically -->
</ul>
</div>
<!-- Report Content Area -->
<div class="medical-report" id="medical-report-content">
<!-- Processing State -->
<div class="processing-state" id="processing-state">
<div class="findings-section">
<div class="findings-title">
<span class="severity-indicator severity-medium"></span>
Analysis in Progress
</div>
<p>Your diagnostic analysis is currently being processed by our AI system. This
typically takes 2-10 minutes depending on image complexity and current system
load.</p>
<div class="processing-details">
<h4>Processing Steps:</h4>
<ul class="processing-steps">
<li class="step completed">✓ Image uploaded and validated</li>
<li class="step active">🔄 AI analysis in progress</li>
<li class="step pending">⏳ Generating diagnostic report</li>
<li class="step pending">⏳ Quality review and validation</li>
</ul>
</div>
<div class="progress-bar" style="margin-top: var(--spacing-lg);">
<div class="progress-fill" id="processing-progress" style="width: 45%;"></div>
</div>
<p
style="margin-top: var(--spacing-md); text-align: center; color: var(--dark-gray);">
Estimated completion: <span id="estimated-completion">3-5 minutes</span>
</p>
</div>
</div>
<!-- Completed Report Content -->
<div class="completed-report" id="completed-report" style="display: none;">
<!-- Report content will be dynamically inserted here -->
</div>
</div>
</div>
<!-- Report Actions -->
<div class="report-actions"
style="padding: var(--spacing-lg); border-top: 1px solid var(--medium-gray); background: var(--light-gray);">
<div class="action-buttons"
style="display: flex; gap: var(--spacing-md); justify-content: center; flex-wrap: wrap;">
<button class="btn btn-primary" id="share-report-btn">
📤 Share Report
</button>
<button class="btn btn-secondary" id="download-pdf-action-btn">
📄 Download PDF
</button>
<button class="btn btn-secondary" id="download-markdown-btn">
📝 Download Markdown
</button>
<button class="btn btn-secondary" id="view-raw-data-btn">
🔍 View Raw Data
</button>
</div>
<div class="report-info"
style="text-align: center; margin-top: var(--spacing-md); font-size: 0.875rem; color: var(--dark-gray);">
<p>This report was generated using AI-powered analysis and should be reviewed by a qualified
medical professional.</p>
<p>Generated on <span id="generation-timestamp">Loading...</span></p>
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Share Modal -->
<div class="modal-overlay" id="share-modal" style="display: none;">
<div class="modal">
<div class="modal-header">
<h3 class="modal-title">Share Medical Report</h3>
<button class="modal-close">×</button>
</div>
<div class="modal-body">
<div class="share-options">
<h4>Share Options</h4>
<div class="share-buttons"
style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--spacing-md);">
<button class="btn btn-secondary share-option" data-method="email">
📧 Email Report
</button>
<button class="btn btn-secondary share-option" data-method="link">
🔗 Copy Link
</button>
<button class="btn btn-secondary share-option" data-method="qr">
📱 QR Code
</button>
</div>
<div class="share-link-section" style="margin-top: var(--spacing-lg);">
<label class="form-label">Shareable Link</label>
<div style="display: flex; gap: var(--spacing-sm);">
<input type="text" class="form-control" id="share-link-input" readonly>
<button class="btn btn-primary" id="copy-link-btn">Copy</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Toast Container -->
<div class="toast-container" id="toast-container"></div>
<!-- JavaScript Files -->
<script src="js/mock-api.js"></script>
<script src="js/ui-components.js"></script>
<script src="js/markdown-renderer.js"></script>
<script src="js/storage.js"></script>
<!-- Report Viewer Script -->
<script>
class ReportViewer {
constructor() {
this.currentRequest = null;
this.imageZoom = 1;
this.imagePosition = { x: 0, y: 0 };
this.isDragging = false;
this.markdownRenderer = new MedicalReportFormatter();
this.reportExporter = new ReportExporter();
this.init();
}
init() {
this.setupEventListeners();
this.loadReportFromURL();
}
setupEventListeners() {
// Image controls
document.getElementById('zoom-in').addEventListener('click', () => this.zoomIn());
document.getElementById('zoom-out').addEventListener('click', () => this.zoomOut());
document.getElementById('zoom-reset').addEventListener('click', () => this.resetZoom());
document.getElementById('fullscreen-btn').addEventListener('click', () => this.toggleFullscreen());
// Export buttons - both header and action buttons
document.getElementById('print-report-btn').addEventListener('click', () => this.printReport());
document.getElementById('export-report-btn').addEventListener('click', () => this.showExportOptions());
document.getElementById('download-pdf-btn').addEventListener('click', () => this.downloadPDF());
document.getElementById('download-pdf-action-btn').addEventListener('click', () => this.downloadPDF());
document.getElementById('download-markdown-btn').addEventListener('click', () => this.downloadMarkdown());
// Share functionality
document.getElementById('share-report-btn').addEventListener('click', () => this.showShareModal());
document.getElementById('copy-link-btn').addEventListener('click', () => this.copyShareLink());
// Image interaction
this.setupImageInteraction();
// Modal close
document.querySelectorAll('.modal-close').forEach(btn => {
btn.addEventListener('click', () => this.closeModals());
});
}
setupImageInteraction() {
const imageDisplay = document.getElementById('image-display');
const medicalImage = document.getElementById('medical-image');
// Mouse wheel zoom
imageDisplay.addEventListener('wheel', (e) => {
e.preventDefault();
if (e.deltaY < 0) {
this.zoomIn();
} else {
this.zoomOut();
}
});
// Drag functionality
imageDisplay.addEventListener('mousedown', (e) => this.startDrag(e));
imageDisplay.addEventListener('mousemove', (e) => this.drag(e));
imageDisplay.addEventListener('mouseup', () => this.endDrag());
imageDisplay.addEventListener('mouseleave', () => this.endDrag());
// Touch support for mobile
imageDisplay.addEventListener('touchstart', (e) => this.handleTouch(e, 'start'));
imageDisplay.addEventListener('touchmove', (e) => this.handleTouch(e, 'move'));
imageDisplay.addEventListener('touchend', (e) => this.handleTouch(e, 'end'));
}
loadReportFromURL() {
const urlParams = new URLSearchParams(window.location.search);
const reportId = urlParams.get('id') || window.location.hash.replace('#', '');
if (!reportId) {
this.showError('No report ID provided');
return;
}
this.loadReport(reportId);
}
async loadReport(reportId) {
this.showLoading();
try {
// Load from storage
const request = window.storage.getRequest(reportId);
if (!request) {
throw new Error('Report not found');
}
this.currentRequest = request;
this.displayReport();
// If still processing, simulate updates
if (request.status === 'pending' || request.status === 'processing') {
this.simulateProcessing();
}
} catch (error) {
this.showError(error.message);
}
}
showLoading() {
document.getElementById('report-loading').style.display = 'block';
document.getElementById('report-container').style.display = 'none';
document.getElementById('report-error').style.display = 'none';
}
showError(message) {
document.getElementById('error-message').textContent = message;
document.getElementById('report-error').style.display = 'block';
document.getElementById('report-loading').style.display = 'none';
document.getElementById('report-container').style.display = 'none';
}
displayReport() {
document.getElementById('report-loading').style.display = 'none';
document.getElementById('report-container').style.display = 'grid';
document.getElementById('report-error').style.display = 'none';
// Update header information
this.updateHeader();
// Load image
this.loadImage();
// Display report content
this.displayReportContent();
}
updateHeader() {
const request = this.currentRequest;
document.getElementById('report-breadcrumb').textContent = `Report ${request.id}`;
document.getElementById('header-report-id').textContent = request.id;
document.getElementById('header-analysis-date').textContent = new Date(request.timestamp).toLocaleDateString();
document.getElementById('header-filename').textContent = request.filename;
document.getElementById('report-timestamp').textContent = this.getTimeAgo(request.timestamp);
document.getElementById('report-status').textContent = request.status;
document.getElementById('generation-timestamp').textContent = new Date().toLocaleString();
}
loadImage() {
const request = this.currentRequest;
const imageElement = document.getElementById('medical-image');
const imageTitle = document.getElementById('image-title');
const imageLoading = document.getElementById('image-loading');
const imageError = document.getElementById('image-error');
imageTitle.textContent = request.filename;
if (request.imageData) {
imageLoading.style.display = 'flex';
imageError.style.display = 'none';
imageElement.onload = () => {
imageLoading.style.display = 'none';
imageElement.style.display = 'block';
};
imageElement.onerror = () => {
imageLoading.style.display = 'none';
imageError.style.display = 'flex';
};
imageElement.src = request.imageData;
} else {
imageLoading.style.display = 'none';
imageError.style.display = 'flex';
}
}
displayReportContent() {
const request = this.currentRequest;
const processingState = document.getElementById('processing-state');
const completedReport = document.getElementById('completed-report');
if (request.status === 'completed' && request.report) {
processingState.style.display = 'none';
completedReport.style.display = 'block';
// Render markdown report
const formatted = this.markdownRenderer.formatReport({
markdown: request.report,
metadata: {
reportId: request.id,
studyDate: request.timestamp,
physician: 'AI Diagnostic System'
}
});
completedReport.innerHTML = formatted.html;
// Generate table of contents if needed
if (formatted.toc) {
const tocElement = document.getElementById('table-of-contents');
tocElement.style.display = 'block';
document.getElementById('toc-list').innerHTML = formatted.toc;
}
} else {
processingState.style.display = 'block';
completedReport.style.display = 'none';
// Update processing progress
this.updateProcessingState();
}
}
simulateProcessing() {
let progress = this.currentRequest.progress || 0;
const interval = setInterval(() => {
progress += Math.random() * 10 + 5;
progress = Math.min(progress, 100);
this.currentRequest.progress = progress;
this.updateProcessingProgress(progress);
if (progress >= 100) {
clearInterval(interval);
this.completeProcessing();
}
}, 2000 + Math.random() * 3000);
}
updateProcessingProgress(progress) {
const progressFill = document.getElementById('processing-progress');
if (progressFill) {
progressFill.style.width = `${progress}%`;
}
// Update processing steps
const steps = document.querySelectorAll('.processing-steps .step');
steps.forEach((step, index) => {
if (progress > (index + 1) * 25) {
step.className = 'step completed';
step.innerHTML = step.innerHTML.replace(/🔄|⏳/, '✓');
} else if (progress > index * 25) {
step.className = 'step active';
if (!step.innerHTML.includes('🔄')) {
step.innerHTML = step.innerHTML.replace(/⏳/, '🔄');
}
}
});
}
completeProcessing() {
this.currentRequest.status = 'completed';
this.currentRequest.report = MockAPI.generateMedicalReport(this.currentRequest);
// Update storage
window.storage.saveRequest(this.currentRequest);
// Update display
this.displayReportContent();
this.updateHeader();
// Show completion notification
this.showToast('success', 'Analysis Complete', 'Your diagnostic report is now ready for review.');
}
// Image viewer controls
zoomIn() {
this.imageZoom = Math.min(this.imageZoom * 1.2, 5);
this.updateImageTransform();
}
zoomOut() {
this.imageZoom = Math.max(this.imageZoom / 1.2, 0.1);
this.updateImageTransform();
}
resetZoom() {
this.imageZoom = 1;
this.imagePosition = { x: 0, y: 0 };
this.updateImageTransform();
}
updateImageTransform() {
const image = document.getElementById('medical-image');
const zoomIndicator = document.getElementById('zoom-indicator');
if (image) {
image.style.transform = `translate(${this.imagePosition.x}px, ${this.imagePosition.y}px) scale(${this.imageZoom})`;
image.classList.toggle('zoomed', this.imageZoom > 1);
}
if (zoomIndicator) {
zoomIndicator.textContent = Math.round(this.imageZoom * 100) + '%';
}
}
startDrag(e) {
if (this.imageZoom > 1) {
this.isDragging = true;
this.lastMousePos = { x: e.clientX, y: e.clientY };
e.preventDefault();
}
}
drag(e) {
if (this.isDragging && this.imageZoom > 1) {
const deltaX = e.clientX - this.lastMousePos.x;
const deltaY = e.clientY - this.lastMousePos.y;
this.imagePosition.x += deltaX;
this.imagePosition.y += deltaY;
this.lastMousePos = { x: e.clientX, y: e.clientY };
this.updateImageTransform();
}
}
endDrag() {
this.isDragging = false;
}
toggleFullscreen() {
const imagePanel = document.querySelector('.image-panel');
if (imagePanel) {
imagePanel.classList.toggle('fullscreen');
}
}
// Export functions
printReport() {
if (this.currentRequest && this.currentRequest.report) {
this.reportExporter.exportToPDF({
markdown: this.currentRequest.report,
metadata: {
reportId: this.currentRequest.id,
studyDate: this.currentRequest.timestamp
}
});
}
}
downloadPDF() {
try {
// Create a link to download the static PDF file
const link = document.createElement('a');
link.href = 'assets/report.pdf';
link.download = `medical_report_${this.currentRequest ? this.currentRequest.id : 'sample'}.pdf`;
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
this.showToast('success', 'Download Started', 'PDF report download has been initiated.');
} catch (error) {
console.error('❌ Error downloading PDF:', error);
this.showToast('error', 'Download Failed', 'Failed to download PDF report. Please try again.');
}
}
downloadMarkdown() {
if (this.currentRequest && this.currentRequest.report) {
this.reportExporter.exportToMarkdown({
markdown: this.currentRequest.report
}, `medical_report_${this.currentRequest.id}.md`);
}
}
showExportOptions() {
// For now, just show the PDF download
this.downloadPDF();
}
showShareModal() {
const modal = document.getElementById('share-modal');
const shareLink = `${window.location.origin}/report.html?id=${this.currentRequest.id}`;
document.getElementById('share-link-input').value = shareLink;
modal.style.display = 'flex';
}
copyShareLink() {
const input = document.getElementById('share-link-input');
input.select();
document.execCommand('copy');
this.showToast('success', 'Link Copied', 'Report link has been copied to clipboard.');
}
closeModals() {
document.querySelectorAll('.modal-overlay').forEach(modal => {
modal.style.display = 'none';
});
}
getTimeAgo(timestamp) {
const now = new Date();
const time = new Date(timestamp);
const diffInSeconds = Math.floor((now - time) / 1000);
if (diffInSeconds < 60) return 'Just now';
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
if (diffInSeconds < 2592000) return `${Math.floor(diffInSeconds / 86400)}d ago`;
return time.toLocaleDateString();
}
showToast(type, title, message) {
const container = document.getElementById('toast-container');
const toast = document.createElement('div');
toast.className = `toast ${type}`;
toast.innerHTML = `
<div class="toast-content">
<div class="toast-title">${title}</div>
<div class="toast-message">${message}</div>
</div>
<button class="toast-close">×</button>
`;
toast.querySelector('.toast-close').addEventListener('click', () => {
toast.remove();
});
container.appendChild(toast);
setTimeout(() => {
if (toast.parentNode) {
toast.remove();
}
}, 5000);
}
}
// Initialize report viewer when DOM is ready
document.addEventListener('DOMContentLoaded', function () {
window.reportViewer = new ReportViewer();
});
</script>
<style>
.processing-steps {
list-style: none;
padding: 0;
margin: var(--spacing-lg) 0;
}
.processing-steps .step {
padding: var(--spacing-sm) 0;
color: var(--dark-gray);
transition: color 0.3s ease;
}
.processing-steps .step.completed {
color: var(--success-green);
}
.processing-steps .step.active {
color: var(--primary-blue);
font-weight: 500;
}
.image-loading,
.image-error {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(0, 0, 0, 0.8);
color: white;
font-size: 0.875rem;
}
.image-error .error-icon {
font-size: 3rem;
margin-bottom: var(--spacing-md);
}
.share-option {
padding: var(--spacing-lg);
text-align: left;
border: 2px solid var(--medium-gray);
transition: all 0.15s ease;
}
.share-option:hover {
border-color: var(--primary-blue);
background: var(--secondary-blue);
}
.image-panel.fullscreen {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
background: black;
}
@media (max-width: 1024px) {
.report-container {
grid-template-columns: 1fr;
gap: 0;
}
.image-panel {
order: 2;
max-height: 400px;
}
.report-panel {
order: 1;
}
}
@media (max-width: 768px) {
.nav-actions {
flex-wrap: wrap;
gap: var(--spacing-sm);
}
.nav-actions .btn {
font-size: 0.75rem;
padding: var(--spacing-sm);
}
.report-meta {
flex-direction: column;
gap: var(--spacing-sm);
}
.action-buttons {
flex-direction: column;
align-items: stretch;
}
.action-buttons .btn {
width: 100%;
}
}
</style>
</body>
</html>