Update web/past_data.html

#2
Files changed (1) hide show
  1. web/past_data.html +32 -3
web/past_data.html CHANGED
@@ -92,15 +92,31 @@
92
  }
93
  }
94
 
95
- function renderAnalysis(item) {
96
  const d = item.createdAt && item.createdAt.toDate ? item.createdAt.toDate().toLocaleString() : "";
 
 
97
  return `
98
  <div class="bg-white border border-gray-200 rounded-lg p-4 shadow">
99
  <div class="flex justify-between mb-2">
100
- <div class="font-semibold text-green-700">Report: ${item.reportDate || "N/A"}</div>
101
  <div class="text-xs text-gray-500">${d}</div>
102
  </div>
103
- <pre class="whitespace-pre-wrap text-sm text-gray-700 mb-2">${item.ocr_text || ""}</pre>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  ${(Array.isArray(item.Detected_Anomolies) ? item.Detected_Anomolies : []).map((r,i) => `
105
  <div class="border-t border-gray-200 pt-2 mt-2">
106
  <div class="font-medium">Finding ${i+1}: ${r.findings || ""}</div>
@@ -112,6 +128,19 @@
112
  `;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  onAuthStateChanged(auth, async (user) => {
116
  if (user) {
117
  statusEl.textContent = `Signed in as ${user.email || user.uid}`;
 
92
  }
93
  }
94
 
95
+ function renderAnalysisWithCustomToggle(item) {
96
  const d = item.createdAt && item.createdAt.toDate ? item.createdAt.toDate().toLocaleString() : "";
97
+ const uniqueId = `ocr-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`; // Generate unique ID
98
+
99
  return `
100
  <div class="bg-white border border-gray-200 rounded-lg p-4 shadow">
101
  <div class="flex justify-between mb-2">
 
102
  <div class="text-xs text-gray-500">${d}</div>
103
  </div>
104
+
105
+ <!-- Collapsible OCR Text Section with Custom Toggle -->
106
+ <div class="mb-4">
107
+ <div class="font-semibold text-green-700 cursor-pointer hover:text-green-800 py-2 flex justify-between items-center"
108
+ onclick="toggleOCR('${uniqueId}')">
109
+ <span>Report ${item.reportDate || "N/A"}</span>
110
+ <span class="arrow transition-transform duration-300" id="arrow-${uniqueId}">▶</span>
111
+ </div>
112
+ <div class="ocr-content overflow-hidden transition-all duration-300 max-h-0" id="content-${uniqueId}">
113
+ <div class="mt-2 p-3 bg-gray-50 rounded border">
114
+ <pre class="whitespace-pre-wrap text-sm text-gray-700">${item.ocr_text || ""}</pre>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <!-- Findings Section -->
120
  ${(Array.isArray(item.Detected_Anomolies) ? item.Detected_Anomolies : []).map((r,i) => `
121
  <div class="border-t border-gray-200 pt-2 mt-2">
122
  <div class="font-medium">Finding ${i+1}: ${r.findings || ""}</div>
 
128
  `;
129
  }
130
 
131
+ function toggleOCR(id) {
132
+ const content = document.getElementById(`content-${id}`);
133
+ const arrow = document.getElementById(`arrow-${id}`);
134
+
135
+ if (content.style.maxHeight && content.style.maxHeight !== '0px') {
136
+ content.style.maxHeight = '0px';
137
+ arrow.style.transform = 'rotate(0deg)';
138
+ } else {
139
+ content.style.maxHeight = content.scrollHeight + 'px';
140
+ arrow.style.transform = 'rotate(90deg)';
141
+ }
142
+ }
143
+
144
  onAuthStateChanged(auth, async (user) => {
145
  if (user) {
146
  statusEl.textContent = `Signed in as ${user.email || user.uid}`;