vaithi663 commited on
Commit
76131f6
·
verified ·
1 Parent(s): 5194035

Update templates/result.html

Browse files
Files changed (1) hide show
  1. templates/result.html +77 -78
templates/result.html CHANGED
@@ -77,7 +77,6 @@
77
  }
78
  .btn-back:hover { background: #475569; }
79
 
80
- /* PUDHU CODE: பேசும் பட்டன் டிசைன் 👇 */
81
  .btn-voice {
82
  width: 100%;
83
  padding: 15px;
@@ -92,7 +91,6 @@
92
  transition: 0.3s;
93
  }
94
  .btn-voice:hover { background: #00f2fe; color: #0f172a; }
95
- /* PUDHU CODE END 👆 */
96
  </style>
97
  </head>
98
  <body>
@@ -144,6 +142,7 @@
144
  <button class="btn-voice" id="voiceBtn">
145
  <i class="fa-solid fa-volume-high"></i> Listen to AI Report
146
  </button>
 
147
  <button class="btn-print" id="downloadBtn" onclick="generatePDF()">Download Medical Report (PDF)</button>
148
  <button class="btn-back" onclick="window.location.href='/upload'">Scan Another Image (Go Back)</button>
149
  </div>
@@ -170,9 +169,14 @@
170
  });
171
  }
172
 
173
- // --- PUDHU CODE: AI VOICE ASSISTANT (Advanced Female Voice) 👇 ---
174
  function speakReport(triage, disease) {
175
- // ஏற்கனவே பேசிட்டு இருந்தா நிப்பாட்டிடு
 
 
 
 
 
176
  window.speechSynthesis.cancel();
177
 
178
  let speech = new SpeechSynthesisUtterance();
@@ -186,11 +190,10 @@
186
 
187
  speech.text = dialogue;
188
  speech.volume = 1;
189
- speech.rate = 0.95; // கொஞ்சம் நிதானமா பேசுற வேகம்
190
- speech.pitch = 1.1; // கொஞ்சம் பெண் குரல் மாதிரி Pitch
191
  speech.lang = 'en-US';
192
 
193
- // போன்ல இருக்குற வாய்ஸ் லிஸ்டை எடுத்து, "Female" வாய்ஸ் செலக்ட் பண்ற லாஜிக்
194
  let voices = window.speechSynthesis.getVoices();
195
  let femaleVoice = voices.find(voice => voice.name.includes('Female') || voice.name.includes('Google UK English Female') || voice.name.includes('en-US'));
196
 
@@ -198,86 +201,82 @@
198
  speech.voice = femaleVoice;
199
  }
200
 
201
- // பேசு!
202
  window.speechSynthesis.speak(speech);
203
  }
204
- // வாய்ஸ் லிஸ்டை ரெடியா முன்கூட்டியே லோட் பண்ணி வைக்கும் கோடு
205
- window.speechSynthesis.onvoiceschanged = function() {
206
- window.speechSynthesis.getVoices();
207
- };
208
- // --- PUDHU CODE END 👆 ---
209
 
 
 
 
 
 
 
 
210
 
211
- const aiDataJSON = localStorage.getItem('aiResult');
212
-
213
- if(!aiDataJSON) {
214
- window.location.href = '/upload';
215
- } else {
216
- const aiData = JSON.parse(aiDataJSON);
217
 
218
- if(aiData.orig_img) {
219
- document.getElementById('display-orig').src = "data:image/jpeg;base64," + aiData.orig_img;
220
- }
221
- if(aiData.heat_gen && aiData.heat_img) {
222
- document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.heat_img;
223
  } else {
224
- document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.orig_img;
225
- document.getElementById('heatmap-caption').innerText = "Healthy Retina (No Heatmap Needed)";
226
- document.getElementById('heatmap-caption').style.color = "#10b981";
227
- }
 
 
 
 
 
 
 
 
228
 
229
- const headerStatus = document.getElementById('header-status');
230
- const mainCard = document.getElementById('main-result-card');
231
- const scoreTitle = document.getElementById('pred-title');
232
- const scoreValue = document.getElementById('pred-score');
233
- const scoreStatus = document.getElementById('pred-status');
234
- const dummyCards = document.querySelectorAll('.dummy-card');
235
-
236
- const verdictBox = document.getElementById('verdict-box');
237
- const verdictTitle = document.getElementById('verdict-title');
238
- const verdictText = document.getElementById('verdict-text');
239
 
240
- headerStatus.innerText = "● System Diagnosis: " + aiData.triage;
241
- scoreTitle.innerText = "AI Prediction: " + aiData.disease;
242
- scoreValue.innerText = aiData.confidence;
243
- scoreStatus.innerText = "Status: " + aiData.status;
244
 
245
- verdictText.innerText = "Action Required: " + aiData.action + " | Doctor Advice: " + aiData.advice;
246
 
247
- if(aiData.triage === "SAFE") {
248
- const color = "#10b981";
249
- headerStatus.style.color = color;
250
- scoreValue.style.color = color;
251
- mainCard.style.borderLeftColor = color;
252
- verdictBox.style.background = "rgba(16, 185, 129, 0.1)";
253
- verdictBox.style.borderColor = color;
254
- verdictTitle.style.color = color;
255
- } else if(aiData.triage === "URGENT") {
256
- const color = "#ef4444";
257
- headerStatus.style.color = color;
258
- scoreValue.style.color = color;
259
- mainCard.style.borderLeftColor = color;
260
- verdictBox.style.background = "rgba(239, 68, 68, 0.1)";
261
- verdictBox.style.borderColor = color;
262
- verdictTitle.style.color = color;
263
- } else {
264
- const color = "#f59e0b";
265
- headerStatus.style.color = color;
266
- scoreValue.style.color = color;
267
- mainCard.style.borderLeftColor = color;
268
- verdictBox.style.background = "rgba(245, 158, 11, 0.1)";
269
- verdictBox.style.borderColor = color;
270
- verdictTitle.style.color = color;
271
- }
272
 
273
- dummyCards.forEach(card => card.style.display = "none");
274
 
275
- // --- PUDHU CODE: பட்டனை தொட்டா பேசுற மாதிரி இணைக்கப்பட்டுள்ளது 👇 ---
276
- document.getElementById('voiceBtn').addEventListener('click', function() {
277
- speakReport(aiData.triage, aiData.disease);
278
- });
279
- // --- PUDHU CODE END 👆 ---
280
- }
281
- </script>
282
- </body>
283
- </html>
 
77
  }
78
  .btn-back:hover { background: #475569; }
79
 
 
80
  .btn-voice {
81
  width: 100%;
82
  padding: 15px;
 
91
  transition: 0.3s;
92
  }
93
  .btn-voice:hover { background: #00f2fe; color: #0f172a; }
 
94
  </style>
95
  </head>
96
  <body>
 
142
  <button class="btn-voice" id="voiceBtn">
143
  <i class="fa-solid fa-volume-high"></i> Listen to AI Report
144
  </button>
145
+
146
  <button class="btn-print" id="downloadBtn" onclick="generatePDF()">Download Medical Report (PDF)</button>
147
  <button class="btn-back" onclick="window.location.href='/upload'">Scan Another Image (Go Back)</button>
148
  </div>
 
169
  });
170
  }
171
 
172
+ // --- PUDHU CODE: AI VOICE ASSISTANT (Crash-Proof Safeguard Added) 👇 ---
173
  function speakReport(triage, disease) {
174
+ // மொபைல் ஆப்பில் வாய்ஸ் சப்போர்ட் இல்லை என்றால் எரர் வராமல் தடுக்க
175
+ if (!('speechSynthesis' in window)) {
176
+ alert("⚠️ App Notice: Voice Assistant is not supported in this mobile view. Please check the text report.");
177
+ return;
178
+ }
179
+
180
  window.speechSynthesis.cancel();
181
 
182
  let speech = new SpeechSynthesisUtterance();
 
190
 
191
  speech.text = dialogue;
192
  speech.volume = 1;
193
+ speech.rate = 0.95;
194
+ speech.pitch = 1.1;
195
  speech.lang = 'en-US';
196
 
 
197
  let voices = window.speechSynthesis.getVoices();
198
  let femaleVoice = voices.find(voice => voice.name.includes('Female') || voice.name.includes('Google UK English Female') || voice.name.includes('en-US'));
199
 
 
201
  speech.voice = femaleVoice;
202
  }
203
 
 
204
  window.speechSynthesis.speak(speech);
205
  }
 
 
 
 
 
206
 
207
+ // போனில் வாய்ஸ் சிஸ்டம் இருந்தால் மட்டும் இதை ரன் பண்ணு (இதுதான் ஆப்பை க்ராஷ் ஆக்கிய வில்லன்!)
208
+ if ('speechSynthesis' in window) {
209
+ window.speechSynthesis.onvoiceschanged = function() {
210
+ window.speechSynthesis.getVoices();
211
+ };
212
+ }
213
+ // --- PUDHU CODE END 👆 ---
214
 
215
+ // --- PUDHU CODE: Try-Catch பாதுகாப்பு அரண் 👇 ---
216
+ try {
217
+ const aiDataJSON = localStorage.getItem('aiResult');
 
 
 
218
 
219
+ if(!aiDataJSON || aiDataJSON === "undefined" || aiDataJSON === "null") {
220
+ window.location.href = '/upload';
 
 
 
221
  } else {
222
+ const aiData = JSON.parse(aiDataJSON);
223
+
224
+ if(aiData.orig_img) {
225
+ document.getElementById('display-orig').src = "data:image/jpeg;base64," + aiData.orig_img;
226
+ }
227
+ if(aiData.heat_gen && aiData.heat_img) {
228
+ document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.heat_img;
229
+ } else {
230
+ document.getElementById('display-heat').src = "data:image/jpeg;base64," + aiData.orig_img;
231
+ document.getElementById('heatmap-caption').innerText = "Healthy Retina (No Heatmap Needed)";
232
+ document.getElementById('heatmap-caption').style.color = "#10b981";
233
+ }
234
 
235
+ const headerStatus = document.getElementById('header-status');
236
+ const mainCard = document.getElementById('main-result-card');
237
+ const scoreTitle = document.getElementById('pred-title');
238
+ const scoreValue = document.getElementById('pred-score');
239
+ const scoreStatus = document.getElementById('pred-status');
240
+ const dummyCards = document.querySelectorAll('.dummy-card');
241
+
242
+ const verdictBox = document.getElementById('verdict-box');
243
+ const verdictTitle = document.getElementById('verdict-title');
244
+ const verdictText = document.getElementById('verdict-text');
245
 
246
+ headerStatus.innerText = "● System Diagnosis: " + aiData.triage;
247
+ scoreTitle.innerText = "AI Prediction: " + aiData.disease;
248
+ scoreValue.innerText = aiData.confidence;
249
+ scoreStatus.innerText = "Status: " + aiData.status;
250
 
251
+ verdictText.innerText = "Action Required: " + aiData.action + " | Doctor Advice: " + aiData.advice;
252
 
253
+ if(aiData.triage === "SAFE") {
254
+ const color = "#10b981";
255
+ headerStatus.style.color = color;
256
+ scoreValue.style.color = color;
257
+ mainCard.style.borderLeftColor = color;
258
+ verdictBox.style.background = "rgba(16, 185, 129, 0.1)";
259
+ verdictBox.style.borderColor = color;
260
+ verdictTitle.style.color = color;
261
+ } else if(aiData.triage === "URGENT") {
262
+ const color = "#ef4444";
263
+ headerStatus.style.color = color;
264
+ scoreValue.style.color = color;
265
+ mainCard.style.borderLeftColor = color;
266
+ verdictBox.style.background = "rgba(239, 68, 68, 0.1)";
267
+ verdictBox.style.borderColor = color;
268
+ verdictTitle.style.color = color;
269
+ } else {
270
+ const color = "#f59e0b";
271
+ headerStatus.style.color = color;
272
+ scoreValue.style.color = color;
273
+ mainCard.style.borderLeftColor = color;
274
+ verdictBox.style.background = "rgba(245, 158, 11, 0.1)";
275
+ verdictBox.style.borderColor = color;
276
+ verdictTitle.style.color = color;
277
+ }
278
 
279
+ dummyCards.forEach(card => card.style.display = "none");
280
 
281
+ // பட்டனை தொட்டா பேசுற லாஜிக்
282
+ document.getElementById('voiceBtn').addEventListener