diff --git a/src/lib/components/BullBearSay.svelte b/src/lib/components/BullBearSay.svelte index aed43180..78e771da 100644 --- a/src/lib/components/BullBearSay.svelte +++ b/src/lib/components/BullBearSay.svelte @@ -3,50 +3,12 @@ import InfoModal from '$lib/components/InfoModal.svelte'; export let data; - export let marketMoods = {}; - let rawData = marketMoods; - let mode = 'bullish'; - let showFullText = false; - // Function to split text into paragraphs - - //DO NOT TOUCH THIS CODE - SAFARI 15.3 are not compatible with the previous code. The website will break. - // CONSIDER MOVING THIS LOGIC TO THE BACKEND TO REMOVE THE RISK COMPLETELY - function splitIntoParagraphs(text) { - if (!text) return []; - - // Replace "U.S." and "vs." with placeholders - const placeholderUS = '__US__'; - const placeholderVs = '__VS__'; - - let tempText = text.replace(/U\.S\./g, placeholderUS) - .replace(/vs\./g, placeholderVs); - - // Split the text based on periods followed by spaces - let paragraphs = tempText.split(/\. \s*/); + let rawData = {}; - // Restore the placeholders back to "U.S." and "vs." - paragraphs = paragraphs.map(paragraph => - paragraph.replace(new RegExp(placeholderUS, 'g'), 'U.S.') - .replace(new RegExp(placeholderVs, 'g'), 'vs.') - ); - - return paragraphs; -} - - - - let paragraphs = splitIntoParagraphs(rawData?.bullSays); - function handleMode(i) { activeIdx = i; - if(activeIdx === 0) { - paragraphs = splitIntoParagraphs(rawData?.bullSays); - } - else if (activeIdx === 1) { - paragraphs = splitIntoParagraphs(rawData?.bearSays); - } } const tabs = [ @@ -62,17 +24,15 @@ $: { if($stockTicker && typeof window !== 'undefined') { - rawData = marketMoods; - mode = 'bullish'; - showFullText = false; - paragraphs = splitIntoParagraphs(rawData?.bullSays); + rawData = data?.getBullBearSay; + activeIdx = 0; } } - {#if Object?.keys(marketMoods)?.length !== 0} + {#if Object?.keys(rawData)?.length !== 0}
{paragraph} {paragraphs?.length <= index+1 ? '' : '.'}
- {/each} + {#if activeIdx === 0} +{rawData?.bullSays}
{:else} - {paragraphs?.at(0)?.slice(0,250) + '...'} +{rawData?.bearSays}
{/if}