Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +14 -11
templates/index.html
CHANGED
|
@@ -125,10 +125,12 @@
|
|
| 125 |
|
| 126 |
const API_BASE_URL = '';
|
| 127 |
|
| 128 |
-
function getSDGBadge(
|
| 129 |
-
if (
|
| 130 |
-
|
| 131 |
-
return `<span class="sdg-badge sdg-
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
let stockChart = null; // Variable to hold the chart instance
|
|
@@ -369,6 +371,11 @@
|
|
| 369 |
}
|
| 370 |
|
| 371 |
function renderAnalysis(data, stockInfo) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
const getRecommendationClass = (r) => {
|
| 373 |
if (!r) return 'rec-hold';
|
| 374 |
const lowerR = r.toLowerCase();
|
|
@@ -397,8 +404,7 @@
|
|
| 397 |
${data.recommendation}
|
| 398 |
</div>
|
| 399 |
<div>
|
| 400 |
-
${getSDGBadge(
|
| 401 |
-
</div>
|
| 402 |
</div>
|
| 403 |
</div>
|
| 404 |
|
|
@@ -423,8 +429,7 @@
|
|
| 423 |
<div class="mt-4">
|
| 424 |
<h3 class="text-xl font-bold mb-2">SDG Explanation</h3>
|
| 425 |
<div class="bg-black bg-opacity-20 p-4 rounded-lg text-gray-300 space-y-2">
|
| 426 |
-
${convertMarkdownToHTML(
|
| 427 |
-
</div>
|
| 428 |
</div>
|
| 429 |
<div>
|
| 430 |
<h3 class="text-xl font-bold mb-2">Valuation Analysis</h3>
|
|
@@ -469,9 +474,7 @@
|
|
| 469 |
<div>
|
| 470 |
<h3 class="text-xl font-bold mb-2">SDG Impact Score</h3>
|
| 471 |
<div class="bg-black bg-opacity-20 p-4 rounded-lg text-center">
|
| 472 |
-
<p class="text-4xl font-bold">${
|
| 473 |
-
<p class="mt-2">${getSDGBadge(data.sdg_score)}</p>
|
| 474 |
-
</div>
|
| 475 |
</div>
|
| 476 |
|
| 477 |
<div>
|
|
|
|
| 125 |
|
| 126 |
const API_BASE_URL = '';
|
| 127 |
|
| 128 |
+
function getSDGBadge(label) {
|
| 129 |
+
if (!label) label = "neutral";
|
| 130 |
+
const lowerLabel = label.toLowerCase();
|
| 131 |
+
if (lowerLabel === "positive") return `<span class="sdg-badge sdg-positive">SDG+</span>`;
|
| 132 |
+
if (lowerLabel === "negative") return `<span class="sdg-badge sdg-negative">SDG-</span>`;
|
| 133 |
+
return `<span class="sdg-badge sdg-neutral">SDG Neutral</span>`;
|
| 134 |
}
|
| 135 |
|
| 136 |
let stockChart = null; // Variable to hold the chart instance
|
|
|
|
| 371 |
}
|
| 372 |
|
| 373 |
function renderAnalysis(data, stockInfo) {
|
| 374 |
+
// ✅ Define SDG variables at the top
|
| 375 |
+
const sdgLabel = data?.sdg?.label || "Neutral";
|
| 376 |
+
const sdgScore = data?.sdg?.score || 50;
|
| 377 |
+
const sdgExplanation = data?.sdg?.explanation || "No SDG-related impact detected.";
|
| 378 |
+
|
| 379 |
const getRecommendationClass = (r) => {
|
| 380 |
if (!r) return 'rec-hold';
|
| 381 |
const lowerR = r.toLowerCase();
|
|
|
|
| 404 |
${data.recommendation}
|
| 405 |
</div>
|
| 406 |
<div>
|
| 407 |
+
${getSDGBadge(sdgLabel)} </div>
|
|
|
|
| 408 |
</div>
|
| 409 |
</div>
|
| 410 |
|
|
|
|
| 429 |
<div class="mt-4">
|
| 430 |
<h3 class="text-xl font-bold mb-2">SDG Explanation</h3>
|
| 431 |
<div class="bg-black bg-opacity-20 p-4 rounded-lg text-gray-300 space-y-2">
|
| 432 |
+
${convertMarkdownToHTML(sdgExplanation)} </div>
|
|
|
|
| 433 |
</div>
|
| 434 |
<div>
|
| 435 |
<h3 class="text-xl font-bold mb-2">Valuation Analysis</h3>
|
|
|
|
| 474 |
<div>
|
| 475 |
<h3 class="text-xl font-bold mb-2">SDG Impact Score</h3>
|
| 476 |
<div class="bg-black bg-opacity-20 p-4 rounded-lg text-center">
|
| 477 |
+
<p class="text-4xl font-bold">${sdgScore}</p> <p class="mt-2">${getSDGBadge(sdgLabel)}</p> </div>
|
|
|
|
|
|
|
| 478 |
</div>
|
| 479 |
|
| 480 |
<div>
|