diff --git a/src/lib/components/Infobox.svelte b/src/lib/components/Infobox.svelte index 61f68d14..dee61bf4 100644 --- a/src/lib/components/Infobox.svelte +++ b/src/lib/components/Infobox.svelte @@ -3,7 +3,7 @@
- - - + + - - - - + {#each rawData?.history as item} - +
+
Ex-Divid. Date + Cash Amount + Record Date + Pay Date
{new Date(item?.date)?.toLocaleString("en-US", { month: "short", @@ -378,12 +372,12 @@ })} {item?.adjDividend?.toFixed(3)} {item?.recordDate?.length !== 0 ? new Date(item?.recordDate)?.toLocaleString( @@ -398,7 +392,7 @@ : "n/a"} {item?.paymentDate?.length !== 0 ? new Date(item?.paymentDate)?.toLocaleString( diff --git a/src/routes/etf/[tickerID]/holdings/+page.svelte b/src/routes/etf/[tickerID]/holdings/+page.svelte index 97632d17..b0498783 100644 --- a/src/routes/etf/[tickerID]/holdings/+page.svelte +++ b/src/routes/etf/[tickerID]/holdings/+page.svelte @@ -101,25 +101,22 @@
-
-
+
+
+

+ {$etfTicker} Holdings List +

+
+ As of {formattedDate} +
+
+
{#if rawData?.length !== 0} -
-
-

- {$etfTicker} Holdings List -

-
- As of {formattedDate} -
-
-
- { + // Reset all other keys to 'none' except the current key + for (const k in sortOrders) { + if (k !== key) { + sortOrders[k].order = "none"; + } + } + + // Cycle through 'none', 'asc', 'desc' for the clicked key + const orderCycle = ["none", "asc", "desc"]; + + let originalData = rawData; + const currentOrderIndex = orderCycle.indexOf(sortOrders[key].order); + sortOrders[key].order = + orderCycle[(currentOrderIndex + 1) % orderCycle.length]; + const sortOrder = sortOrders[key].order; + + // Reset to original data when 'none' and stop further sorting + if (sortOrder === "none") { + senateTradingList = [...originalData]?.slice(0, 50); // Reset to original data (spread to avoid mutation) + return; + } + + // Define a generic comparison function + const compareValues = (a, b) => { + const { type } = sortOrders[key]; + let valueA, valueB; + + switch (type) { + case "date": + valueA = new Date(a[key]); + valueB = new Date(b[key]); + break; + case "string": + valueA = a[key].toUpperCase(); + valueB = b[key].toUpperCase(); + return sortOrder === "asc" + ? valueA.localeCompare(valueB) + : valueB.localeCompare(valueA); + case "number": + default: + valueA = parseFloat(a[key]); + valueB = parseFloat(b[key]); + break; + } + + if (sortOrder === "asc") { + return valueA < valueB ? -1 : valueA > valueB ? 1 : 0; + } else { + return valueA > valueB ? -1 : valueA < valueB ? 1 : 0; + } + }; + + // Sort using the generic comparison function + senateTradingList = [...originalData].sort(compareValues)?.slice(0, 50); + }; @@ -161,7 +239,7 @@ class="w-full mt-5 mb-10 m-auto flex justify-center items-center" >
- - - - - - + {#each senateTradingList as item} + +
- Person - - Transaction Date - - Amount - Type
- {item?.party}
+ {item?.party} + {new Date(item?.transactionDate)?.toLocaleString( "en-US", @@ -371,12 +434,12 @@ {item?.amount} {#if item?.type === "Bought"} Bought diff --git a/src/routes/list/bitcoin-etfs/+page.svelte b/src/routes/list/bitcoin-etfs/+page.svelte index 84271fce..5c66f911 100644 --- a/src/routes/list/bitcoin-etfs/+page.svelte +++ b/src/routes/list/bitcoin-etfs/+page.svelte @@ -1,10 +1,11 @@
-
- - - A list of all Bitcoin ETFs available for trading on the US stock market, - offering investors exposure to the cryptocurrency's price. -
+
diff --git a/src/routes/list/country/[slug]/+page.svelte b/src/routes/list/country/[slug]/+page.svelte index 5fc655c5..40738900 100644 --- a/src/routes/list/country/[slug]/+page.svelte +++ b/src/routes/list/country/[slug]/+page.svelte @@ -1,6 +1,7 @@
-
- A complete list of the {countryNavigation[data?.getParams?.toLowerCase()]} companies - that are listed on the US stock market. -
+
diff --git a/src/routes/list/exchange/[slug]/+page.svelte b/src/routes/list/exchange/[slug]/+page.svelte index 60c4ecd2..d722ba28 100644 --- a/src/routes/list/exchange/[slug]/+page.svelte +++ b/src/routes/list/exchange/[slug]/+page.svelte @@ -1,7 +1,7 @@
-
- A complete list of the {exchangeNavigation[data?.getParams?.toLowerCase()]} companies - that are listed on the US stock market. -
+
diff --git a/src/routes/list/faang/+page.svelte b/src/routes/list/faang/+page.svelte index b51e38c9..c7642829 100644 --- a/src/routes/list/faang/+page.svelte +++ b/src/routes/list/faang/+page.svelte @@ -1,7 +1,7 @@
-
- - - The "FAANG" stocks refer to five major U.S. tech companies: Meta (formerly + + popularized by Jim Cramer as FAANG." + />
diff --git a/src/routes/list/index/[slug]/+page.svelte b/src/routes/list/index/[slug]/+page.svelte index 904c86e1..438be014 100644 --- a/src/routes/list/index/[slug]/+page.svelte +++ b/src/routes/list/index/[slug]/+page.svelte @@ -1,6 +1,7 @@
-
- {indexNavigation[data?.getParams?.toLowerCase()]} -
+
diff --git a/src/routes/list/magnificent-seven/+page.svelte b/src/routes/list/magnificent-seven/+page.svelte index 785ec17f..2507e3e4 100644 --- a/src/routes/list/magnificent-seven/+page.svelte +++ b/src/routes/list/magnificent-seven/+page.svelte @@ -1,6 +1,7 @@
-
- - - The "magnificent seven" stocks are 7 technology stocks that drove a large +
diff --git a/src/routes/list/market-cap/[slug]/+page.svelte b/src/routes/list/market-cap/[slug]/+page.svelte index c6abcfee..75f90c54 100644 --- a/src/routes/list/market-cap/[slug]/+page.svelte +++ b/src/routes/list/market-cap/[slug]/+page.svelte @@ -2,6 +2,7 @@ import { abbreviateNumber } from "$lib/utils"; import Table from "$lib/components/Table/Table.svelte"; import { page } from "$app/stores"; + import Infobox from "$lib/components/Infobox.svelte"; export let data; @@ -109,34 +110,13 @@
-
- {currentCategoryData?.name} stocks have market capitalizations ranging {description} - USD. - -
+
diff --git a/src/routes/list/most-shorted-stocks/+page.svelte b/src/routes/list/most-shorted-stocks/+page.svelte index ec08fec9..71d25fbc 100644 --- a/src/routes/list/most-shorted-stocks/+page.svelte +++ b/src/routes/list/most-shorted-stocks/+page.svelte @@ -1,5 +1,6 @@
-
- - - A list of the stocks with the highest number of shares shorted relative to + diff --git a/src/routes/list/overbought-stocks/+page.svelte b/src/routes/list/overbought-stocks/+page.svelte index afc63ece..7731dd7d 100644 --- a/src/routes/list/overbought-stocks/+page.svelte +++ b/src/routes/list/overbought-stocks/+page.svelte @@ -1,5 +1,6 @@
-
- - - A list of stocks that are "overbought" according to the Relative Strength +
import Table from "$lib/components/Table/Table.svelte"; + import Infobox from "$lib/components/Infobox.svelte"; export let data; @@ -22,25 +23,13 @@
-
- - - A list of stocks that are "oversold" according to the Relative Strength +
import Table from "$lib/components/Table/Table.svelte"; - + import Infobox from "$lib/components/Infobox.svelte"; export let data; const defaultList = [ @@ -12,23 +12,11 @@
-
- - - A list of actively traded penny stocks, which are generally defined as +
diff --git a/src/routes/list/sector/[slug]/+page.svelte b/src/routes/list/sector/[slug]/+page.svelte index e9c858f2..48a016c0 100644 --- a/src/routes/list/sector/[slug]/+page.svelte +++ b/src/routes/list/sector/[slug]/+page.svelte @@ -1,7 +1,7 @@
-
- The {data?.getParams} sector has a total of {rawData?.length} stocks, with a - combined market cap of {abbreviateNumber(totalMarketCap)} and a total revenue - of {abbreviateNumber(totalRevenue)}. -
+