diff --git a/src/lib/components/BullBearSay.svelte b/src/lib/components/BullBearSay.svelte index f6e2f445..80eeebcd 100644 --- a/src/lib/components/BullBearSay.svelte +++ b/src/lib/components/BullBearSay.svelte @@ -1,133 +1,152 @@ - - -{#if Object?.keys(marketMoods)?.length !== 0} - -
{paragraph} {paragraphs?.length <= index+1 ? '' : '.'}
+ // 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*/); + + // 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 = [ + { + title: "Bull Case", + }, + { + title: "Bear Case", + }, + ]; + + let activeIdx = 0; + + $: { + if($stockTicker && typeof window !== 'undefined') { + rawData = marketMoods; + mode = 'bullish'; + showFullText = false; + paragraphs = splitIntoParagraphs(rawData?.bullSays); + } + } + + + + + {#if Object?.keys(marketMoods)?.length !== 0} + +{paragraph} {paragraphs?.length <= index+1 ? '' : '.'}
+ {/each} + {:else} + {paragraphs?.at(0)?.slice(0,250) + '...'} + {/if} + +