diff --git a/src/routes/list/basic-materials-sector/+page.svelte b/src/routes/list/basic-materials-sector/+page.svelte index ab0f8310..188a0a14 100644 --- a/src/routes/list/basic-materials-sector/+page.svelte +++ b/src/routes/list/basic-materials-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getBasicMaterialsSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,17 +46,17 @@ } -
+
-
- +
+ A complete list of companies in the Basic Materials Sector that are publicly traded on the US stock exchange.
-
+
-
+
@@ -152,7 +156,7 @@ -
+
@@ -164,12 +168,12 @@ - - - - - - + + + + + + @@ -178,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} + {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} + +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -236,12 +232,11 @@
- - - - +
+ + diff --git a/src/routes/list/basic-materials-sector/+page.ts b/src/routes/list/basic-materials-sector/+page.ts index 93e1b527..7bc64d0e 100644 --- a/src/routes/list/basic-materials-sector/+page.ts +++ b/src/routes/list/basic-materials-sector/+page.ts @@ -1,24 +1,8 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { +export const load = async ({parent}) => { const getBasicMaterialsSector = async () => { let output; @@ -28,6 +12,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'basic-materials'}; const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/bitcoin-etfs/+page.svelte b/src/routes/list/bitcoin-etfs/+page.svelte index 64f30f27..0ac3c732 100644 --- a/src/routes/list/bitcoin-etfs/+page.svelte +++ b/src/routes/list/bitcoin-etfs/+page.svelte @@ -29,13 +29,13 @@ $: {
-
+
A list of all Bitcoin ETFs available for trading on the US stock market, offering investors exposure to the cryptocurrency's price.
-
+
Total ETFs
diff --git a/src/routes/list/bitcoin-etfs/+page.ts b/src/routes/list/bitcoin-etfs/+page.ts index 14cff5b5..507a43a1 100644 --- a/src/routes/list/bitcoin-etfs/+page.ts +++ b/src/routes/list/bitcoin-etfs/+page.ts @@ -1,24 +1,9 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { + +export const load = async ({parent}) => { const getETFBitcoinList = async () => { let output; @@ -27,6 +12,8 @@ export const load = async () => { if (cachedData) { output = cachedData; } else { + + const {apiKey, apiURL} = await parent(); const response = await fetch(apiURL + '/etf-bitcoin-list', { method: 'GET', diff --git a/src/routes/list/communication-services-sector/+page.svelte b/src/routes/list/communication-services-sector/+page.svelte index 9947e8bb..f3c4bca6 100644 --- a/src/routes/list/communication-services-sector/+page.svelte +++ b/src/routes/list/communication-services-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getCommunicationServicesSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Communication Services Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,9 +232,11 @@
- - - + +
-
-
\ No newline at end of file + + +
+ + diff --git a/src/routes/list/communication-services-sector/+page.ts b/src/routes/list/communication-services-sector/+page.ts index 8bf11662..069865df 100644 --- a/src/routes/list/communication-services-sector/+page.ts +++ b/src/routes/list/communication-services-sector/+page.ts @@ -1,24 +1,7 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - - -export const load = async () => { +export const load = async ({parent}) => { const getCommunicationServicesSector = async () => { let output; @@ -27,6 +10,7 @@ export const load = async () => { if (cachedData) { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); const postData = {'filterList': 'communication-services'}; diff --git a/src/routes/list/consumer-cyclical-sector/+page.svelte b/src/routes/list/consumer-cyclical-sector/+page.svelte index 8639edc7..62cc5f8a 100644 --- a/src/routes/list/consumer-cyclical-sector/+page.svelte +++ b/src/routes/list/consumer-cyclical-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getConsumerCyclicalSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Consumer Cyclical Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,45 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+ +
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -236,12 +232,11 @@
- - - - +
+ + diff --git a/src/routes/list/consumer-cyclical-sector/+page.ts b/src/routes/list/consumer-cyclical-sector/+page.ts index 8222fc2a..f4e56cfc 100644 --- a/src/routes/list/consumer-cyclical-sector/+page.ts +++ b/src/routes/list/consumer-cyclical-sector/+page.ts @@ -1,24 +1,8 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import {getCache, setCache } from '$lib/store'; -export const load = async () => { +export const load = async ({parent}) => { const getConsumerCyclicalSector = async () => { let output; @@ -27,7 +11,7 @@ export const load = async () => { if (cachedData) { output = cachedData; } else { - + const {apiKey, apiURL} = await parent(); const postData = {'filterList': 'consumer-cyclical'} const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/consumer-defensive-sector/+page.svelte b/src/routes/list/consumer-defensive-sector/+page.svelte index ec08f04d..6e6054be 100644 --- a/src/routes/list/consumer-defensive-sector/+page.svelte +++ b/src/routes/list/consumer-defensive-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getConsumerDefensiveSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Consumer Defensive Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,8 +232,11 @@
- - - -
-
\ No newline at end of file + +
+ + + +
+ + diff --git a/src/routes/list/consumer-defensive-sector/+page.ts b/src/routes/list/consumer-defensive-sector/+page.ts index f5419b06..f93d84d1 100644 --- a/src/routes/list/consumer-defensive-sector/+page.ts +++ b/src/routes/list/consumer-defensive-sector/+page.ts @@ -1,24 +1,9 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { + +export const load = async ({parent}) => { const getConsumerDefensiveSector = async () => { let output; @@ -28,6 +13,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'consumer-defensive'}; const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/delisted-stocks/+page.svelte b/src/routes/list/delisted-stocks/+page.svelte index 24df7ddc..b7ae577f 100644 --- a/src/routes/list/delisted-stocks/+page.svelte +++ b/src/routes/list/delisted-stocks/+page.svelte @@ -1,26 +1,28 @@ -
+
-
+
A list of companies delisted from the exchange and no longer publicly traded.
-
+
Total Stocks
@@ -66,7 +68,7 @@ $: { -
+
@@ -75,45 +77,39 @@ $: { - +
- - - - - + + + + + {#each marketCapList as item,index} - - - - - @@ -128,8 +124,6 @@ $: {
CompanyIPODelistedSymbolCompanyIPOExchangeDelisted
{item?.symbol} - -
-
- {item?.symbol} - {item?.companyName?.length > charNumber ? item?.companyName?.slice(0,charNumber) + "..." : item?.companyName} -
-
+
+ {item?.companyName?.length > charNumber ? item?.companyName?.slice(0,charNumber) + "..." : item?.companyName} + {new Date(item?.ipoDate).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })} {item?.exchange} + {new Date(item?.delistedDate).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}
- -
diff --git a/src/routes/list/delisted-stocks/+page.ts b/src/routes/list/delisted-stocks/+page.ts index 725521af..6e540f3a 100644 --- a/src/routes/list/delisted-stocks/+page.ts +++ b/src/routes/list/delisted-stocks/+page.ts @@ -1,23 +1,8 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - -export const load = async () => { +export const load = async ({parent}) => { const getDelistedStocks = async () => { let output; @@ -27,7 +12,8 @@ export const load = async () => { output = cachedData; } else { - + const {apiKey, apiURL} = await parent(); + const response = await fetch(apiURL + '/delisted-companies', { method: 'GET', headers: { diff --git a/src/routes/list/energy-sector/+page.svelte b/src/routes/list/energy-sector/+page.svelte index d3e804e7..7fc9bb68 100644 --- a/src/routes/list/energy-sector/+page.svelte +++ b/src/routes/list/energy-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getEnergySector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Energy Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -162,15 +165,15 @@ - +
- - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,8 +232,11 @@
- - - -
-
\ No newline at end of file + +
+ + + +
+ + diff --git a/src/routes/list/energy-sector/+page.ts b/src/routes/list/energy-sector/+page.ts index b6d959ec..3a58180f 100644 --- a/src/routes/list/energy-sector/+page.ts +++ b/src/routes/list/energy-sector/+page.ts @@ -1,24 +1,7 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - - -export const load = async () => { +export const load = async ({parent}) => { const getEnergySector = async () => { let output; @@ -28,6 +11,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'energy'} const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/financial-sector/+page.svelte b/src/routes/list/financial-sector/+page.svelte index 6b258af9..f239c582 100644 --- a/src/routes/list/financial-sector/+page.svelte +++ b/src/routes/list/financial-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; - + import { onMount } from 'svelte'; + export let data; let rawData = data?.getFinancialSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -45,12 +49,12 @@
-
+
A complete list of companies in the Financial Sector that are publicly traded on the US stock exchange.
-
+
@@ -164,12 +168,12 @@ - - - - - - + + + + + + @@ -178,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -236,9 +232,7 @@
- - - +
diff --git a/src/routes/list/financial-sector/+page.ts b/src/routes/list/financial-sector/+page.ts index 41abfcaa..17d8971e 100644 --- a/src/routes/list/financial-sector/+page.ts +++ b/src/routes/list/financial-sector/+page.ts @@ -1,24 +1,8 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { +export const load = async ({parent}) => { const getFinancialSector = async () => { let output; @@ -28,6 +12,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'financial'} const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/healthcare-sector/+page.svelte b/src/routes/list/healthcare-sector/+page.svelte index 27cf8f56..25f76ef9 100644 --- a/src/routes/list/healthcare-sector/+page.svelte +++ b/src/routes/list/healthcare-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getHealthcareSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,134 +46,134 @@ } -
+
-
+
- A complete list of companies in the Healthcare Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
+ - +
- - - - - - + + + + + + @@ -178,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + - -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -234,11 +230,9 @@ {/each}
+ - - - +
diff --git a/src/routes/list/healthcare-sector/+page.ts b/src/routes/list/healthcare-sector/+page.ts index 89cb1940..f16b3a9b 100644 --- a/src/routes/list/healthcare-sector/+page.ts +++ b/src/routes/list/healthcare-sector/+page.ts @@ -1,24 +1,7 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - - -export const load = async () => { +export const load = async ({parent}) => { const getHealthcareSector = async () => { let output; @@ -27,6 +10,7 @@ export const load = async () => { if (cachedData) { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); const postData = {'filterList': 'healthcare'} diff --git a/src/routes/list/industrials-sector/+page.svelte b/src/routes/list/industrials-sector/+page.svelte index 6f30f691..132c961a 100644 --- a/src/routes/list/industrials-sector/+page.svelte +++ b/src/routes/list/industrials-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getIndustrialsSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Industrials Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -162,15 +165,15 @@ - +
- - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,13 +232,11 @@
- - - - +
-
+
+ diff --git a/src/routes/list/industrials-sector/+page.ts b/src/routes/list/industrials-sector/+page.ts index a9494272..ba975a0a 100644 --- a/src/routes/list/industrials-sector/+page.ts +++ b/src/routes/list/industrials-sector/+page.ts @@ -1,24 +1,9 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { + +export const load = async ({parent}) => { const getIndustrialsSector = async () => { let output; @@ -28,6 +13,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'industrials'} const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/real-estate-sector/+page.svelte b/src/routes/list/real-estate-sector/+page.svelte index 0ff59dbb..f05803ae 100644 --- a/src/routes/list/real-estate-sector/+page.svelte +++ b/src/routes/list/real-estate-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getRealEstateSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Real Estate Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,12 +232,11 @@
- - - - +
-
\ No newline at end of file +
+ + diff --git a/src/routes/list/real-estate-sector/+page.ts b/src/routes/list/real-estate-sector/+page.ts index 63c0d2e0..56d7269d 100644 --- a/src/routes/list/real-estate-sector/+page.ts +++ b/src/routes/list/real-estate-sector/+page.ts @@ -1,24 +1,7 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - - -export const load = async () => { +export const load = async ({parent}) => { const getRealEstateSector = async () => { let output; @@ -28,6 +11,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'real-estate'} const response = await fetch(apiURL + '/filter-stock-list', { method: 'POST', diff --git a/src/routes/list/technology-sector/+page.svelte b/src/routes/list/technology-sector/+page.svelte index e71fde8b..310a63de 100644 --- a/src/routes/list/technology-sector/+page.svelte +++ b/src/routes/list/technology-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getTechnologySector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Technology Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,13 +232,11 @@
- - - +
-
+
+ - \ No newline at end of file diff --git a/src/routes/list/technology-sector/+page.ts b/src/routes/list/technology-sector/+page.ts index c1ff210a..3e56db9c 100644 --- a/src/routes/list/technology-sector/+page.ts +++ b/src/routes/list/technology-sector/+page.ts @@ -1,24 +1,8 @@ -import { userRegion, getCache, setCache } from '$lib/store'; - - -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); +import { getCache, setCache } from '$lib/store'; -export const load = async () => { +export const load = async ({parent}) => { const getTechnologySector = async () => { let output; @@ -28,6 +12,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'technology'} const response = await fetch(apiURL + '/filter-stock-list', { diff --git a/src/routes/list/utilities-sector/+page.svelte b/src/routes/list/utilities-sector/+page.svelte index cfe72b0e..755dfbd9 100644 --- a/src/routes/list/utilities-sector/+page.svelte +++ b/src/routes/list/utilities-sector/+page.svelte @@ -2,27 +2,31 @@ import { goto } from '$app/navigation'; import { screenWidth } from '$lib/store'; import { abbreviateNumber} from '$lib/utils'; - import InfiniteLoading from '$lib/components/InfiniteLoading.svelte'; import InfoModal from '$lib/components/InfoModal.svelte'; + import { onMount } from 'svelte'; export let data; let rawData = data?.getUtilitiesSector; let marketCapList = rawData?.slice(0,50); - async function infiniteHandler({ detail: { loaded, complete } }) - { - - if (marketCapList?.length === rawData?.length) { - complete(); - } - else { - const nextIndex = marketCapList?.length; - const newElements= rawData?.slice(nextIndex, nextIndex + 5); - marketCapList = [...marketCapList, ...newElements]; - loaded(); + async function handleScroll() { + const scrollThreshold = document.body.offsetHeight * 0.8; // 80% of the website height + const isBottom = window.innerHeight + window.scrollY >= scrollThreshold; + if (isBottom && displayList?.length !== rawData?.length) { + const nextIndex = displayList?.length; + const filteredNewResults = rawData?.slice(nextIndex, nextIndex + 50); + displayList = [...displayList, ...filteredNewResults]; } - } + } + + onMount(async () => { + window.addEventListener('scroll', handleScroll); + return () => { + window.removeEventListener('scroll', handleScroll); + }; + }) + let totalMarketCap = rawData?.reduce((total, stock) => total + stock?.marketCap, 0) ?? 0; let totalRevenue = rawData?.reduce((total, stock) => total + stock?.revenue, 0) ?? 0; @@ -42,118 +46,117 @@ } -
+
-
+
- A complete list of companies in the Utilities Sector that are publicly traded on the US stock exchange. -
+
-
+
-
- -
-
- - -
-
{rawData?.length}
-
- - - -
-
-
+ + +
-
+
@@ -165,12 +168,12 @@ - - - - - - + + + + + + @@ -179,46 +182,38 @@ goto("/stocks/"+item?.symbol)} class="sm:hover:bg-[#245073] sm:hover:bg-opacity-[0.2] odd:bg-[#27272A] border-b-[#09090B] shake-ticker cursor-pointer"> - - - - - + -
CompanyMarket CapPriceSymbolCompanyMarket CapRevenueProfitsPrice
{item?.symbol} - -
-
- {item?.symbol} - {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} -
-
+
+ {item?.name?.length > charNumber ? item?.name?.slice(0,charNumber) + "..." : item?.name} + {abbreviateNumber(item?.marketCap,true)} {item?.revenue !== null ? abbreviateNumber(item?.revenue,true) : '-'} {item?.netIncome !== null ? abbreviateNumber(item?.netIncome,true) : '-'} - +
- ${item.price?.toFixed(2)} + ${item.price?.toFixed(2)}
{#if item.changesPercentage >=0} - - +{item.changesPercentage?.toFixed(2)}% + +{item.changesPercentage?.toFixed(2)}% {:else} - - {item.changesPercentage?.toFixed(2)}% + {item.changesPercentage?.toFixed(2)}% {/if}
@@ -237,11 +232,11 @@
- - - - +
-
\ No newline at end of file + +
+ + diff --git a/src/routes/list/utilities-sector/+page.ts b/src/routes/list/utilities-sector/+page.ts index 1aa44a74..768570d9 100644 --- a/src/routes/list/utilities-sector/+page.ts +++ b/src/routes/list/utilities-sector/+page.ts @@ -1,24 +1,7 @@ -import { userRegion, getCache, setCache } from '$lib/store'; +import { getCache, setCache } from '$lib/store'; -const usRegion = ['cle1','iad1','pdx1','sfo1']; - -let apiURL; -let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY; - - -userRegion.subscribe(value => { - - if (usRegion.includes(value)) { - apiURL = import.meta.env.VITE_USEAST_API_URL; - } else { - apiURL = import.meta.env.VITE_EU_API_URL; - } -}); - - - -export const load = async () => { +export const load = async ({parent}) => { const getUtilitiesSector = async () => { let output; @@ -28,6 +11,8 @@ export const load = async () => { output = cachedData; } else { + const {apiKey, apiURL} = await parent(); + const postData = {'filterList': 'utilities'} const response = await fetch(apiURL + '/filter-stock-list', {