This commit is contained in:
MuslemRahimi 2025-04-03 13:45:15 +02:00
parent e3cb01ac04
commit 24e248b676
7 changed files with 82 additions and 10 deletions

View File

@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { abbreviateNumber } from "$lib/utils"; import { abbreviateNumber } from "$lib/utils";
import { screenWidth, stockTicker } from "$lib/store"; import { screenWidth, stockTicker, getCache, setCache } from "$lib/store";
import { mode } from "mode-watcher"; import { mode } from "mode-watcher";
import highcharts from "$lib/highcharts.ts"; import highcharts from "$lib/highcharts.ts";
@ -15,6 +16,7 @@
let lowestValueDate; let lowestValueDate;
let lowestValue; let lowestValue;
let fiveYearsGrowth; let fiveYearsGrowth;
let infoText = {};
const marginKeys = new Set([ const marginKeys = new Set([
/* /*
@ -173,6 +175,26 @@
modalLabel = label; modalLabel = label;
config = plotData(label, key); config = plotData(label, key);
} }
async function getInfoText(parameter, title) {
modalLabel = title;
const cachedData = getCache(parameter, "getInfoText");
if (cachedData) {
infoText = cachedData;
} else {
const postData = { parameter };
const response = await fetch("/api/info-text", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(postData),
});
infoText = await response.json();
setCache(parameter, infoText, "getInfoText");
}
}
</script> </script>
{#each computedFields as { label, key, isMargin } (key)} {#each computedFields as { label, key, isMargin } (key)}
@ -182,7 +204,23 @@
<td <td
class="text-start min-w-[220px] sm:min-w-[320px] border-r border-gray-300 dark:border-gray-700 text-sm sm:text-[1rem] w-full flex flex-row items-center justify-between" class="text-start min-w-[220px] sm:min-w-[320px] border-r border-gray-300 dark:border-gray-700 text-sm sm:text-[1rem] w-full flex flex-row items-center justify-between"
> >
<span class="truncate w-fit max-w-40 sm:max-w-64">{label}</span> <label
for="tooltipModal"
class="truncate w-fit max-w-40 sm:max-w-64 cursor-pointer"
on:click={() => getInfoText(key, label)}
>{label}
<svg
class="-ml-0.5 -mt-4 h-[10.5px] w-[10.5px] inline-block text-gray-600 dark:text-gray-400"
viewBox="0 0 4 16"
fill="currentColor"
style="max-width:20px"
>
<path
d="M0 6h4v10h-4v-10zm2-6c1.1 0 2 .9 2 2s-.9 2-2 2-2-.9-2-2 .9-2 2-2z"
></path>
</svg>
</label>
<label <label
for="financialPlotModal" for="financialPlotModal"
on:click={() => handleChart(label, key)} on:click={() => handleChart(label, key)}
@ -249,3 +287,33 @@
</div> </div>
</div> </div>
</dialog> </dialog>
<input type="checkbox" id="tooltipModal" class="modal-toggle" />
<dialog id="tooltipModal" class="modal p-3">
<label for="tooltipModal" class="cursor-pointer modal-backdrop"></label>
<!-- Desktop modal content -->
<div
class="modal-box rounded-md border border-gray-300 dark:border-gray-600 w-full bg-white dark:bg-secondary flex flex-col items-center"
>
<div class=" mb-5 text-center">
<h3 class="font-bold text-2xl mb-5">{modalLabel}</h3>
<span class=" text-[1rem] font-normal">{infoText?.text ?? "n/a"}</span>
{#if infoText?.equation !== undefined}
<div class="w-5/6 m-auto mt-5"></div>
<div class="text-[1rem] w-full pt-3 pb-3 m-auto">
{infoText?.equation}
</div>
{/if}
</div>
<div class="border-t border-gray-300 dark:border-gray-600 mt-2 w-full">
<label
for="tooltipModal"
class="cursor-pointer mt-4 font-semibold text-xl m-auto flex justify-center"
>
Close
</label>
</div>
</div>
</dialog>

View File

@ -24,6 +24,8 @@
{#if image} {#if image}
<meta property="og:image" content={image} /> <meta property="og:image" content={image} />
<meta property="og:image:alt" content={title} /> <meta property="og:image:alt" content={title} />
{:else}
<meta property="og:image" content="/img/astronaut.png" />
{/if} {/if}
<!-- Twitter meta tags --> <!-- Twitter meta tags -->
@ -32,5 +34,7 @@
<meta name="twitter:description" content={description} /> <meta name="twitter:description" content={description} />
{#if image} {#if image}
<meta name="twitter:image" content={image} /> <meta name="twitter:image" content={image} />
{:else}
<meta property="twitter:image" content="/img/astronaut.png" />
{/if} {/if}
</svelte:head> </svelte:head>

View File

@ -93,7 +93,7 @@
}, },
{ {
propertyName: "incomeTaxExpense", propertyName: "incomeTaxExpense",
label: "Income Tax", label: "Income Tax Expense",
}, },
{ {
propertyName: "weightedAverageShsOut", propertyName: "weightedAverageShsOut",
@ -281,7 +281,7 @@
<SEO <SEO
title={`${$displayCompanyName} (${$stockTicker}) Financials - Income Statement`} title={`${$displayCompanyName} (${$stockTicker}) Financials - Income Statement`}
description={`Detailed annual and quarter income statement for ${$displayCompanyName} (${$stockTicker}). See many years of revenue, expenses and profits or losses.`} description={`Detailed annual and quarterly income statement for ${$displayCompanyName} (${$stockTicker}). See many years of revenue, expenses and profits or losses.`}
/> />
<section class=" w-full overflow-hidden h-full"> <section class=" w-full overflow-hidden h-full">

View File

@ -536,10 +536,10 @@
</div> </div>
{:else} {:else}
<div <div
class="flex flex-col sm:flex-row items-start sm:items-center sm:justify-between" class="flex flex-col sm:flex-row items-start sm:items-end sm:justify-between"
> >
<span <span
class="text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full" class="text-xs sm:text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full"
> >
Financials in {data?.getProfileData?.currency}. Fiscal year Financials in {data?.getProfileData?.currency}. Fiscal year
is is

View File

@ -498,10 +498,10 @@
</div> </div>
{:else} {:else}
<div <div
class="flex flex-col sm:flex-row items-start sm:items-center sm:justify-between" class="flex flex-col sm:flex-row items-start sm:items-end sm:justify-between"
> >
<span <span
class="text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full" class="text-xs sm:text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full"
> >
Financials in {data?.getProfileData?.currency}. Fiscal year Financials in {data?.getProfileData?.currency}. Fiscal year
is is

View File

@ -487,10 +487,10 @@
</div> </div>
{:else} {:else}
<div <div
class="flex flex-col sm:flex-row items-start sm:items-center sm:justify-between" class="flex flex-col sm:flex-row items-start sm:items-end sm:justify-between"
> >
<span <span
class="text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full" class="text-xs sm:text-sm order-1 sm:order-0 mt-5 sm:mt-0 text-gray-600 dark:text-gray-400 w-full"
> >
Financials in {data?.getProfileData?.currency}. Fiscal year Financials in {data?.getProfileData?.currency}. Fiscal year
is is

Binary file not shown.

Before

Width:  |  Height:  |  Size: 639 KiB

After

Width:  |  Height:  |  Size: 111 KiB