From 341d6c012098b08fb8451008e6d2d0b94eb02da8 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Tue, 13 Aug 2024 22:33:03 +0200 Subject: [PATCH] bugfixing: make it safari 15.6 compatible --- src/lib/components/BullBearSay.svelte | 273 ++++++++++++++------------ src/routes/+layout.svelte | 1 + 2 files changed, 147 insertions(+), 127 deletions(-) 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} - -
- -
- -
-
- -
- - -
- -
-
- - {#if data?.user?.tier === 'Pro'} - -
- {#each tabs as item, i} - - {/each} -
+ import { stockTicker, displayCompanyName } from "$lib/store"; + import InfoModal from '$lib/components/InfoModal.svelte'; - - - - Updated {rawData?.date} - -
+ export let data; + export let marketMoods = {}; + + let rawData = marketMoods; + let mode = 'bullish'; + let showFullText = false; + // Function to split text into paragraphs + + function splitIntoParagraphs(text) { + if (!text) return []; -
- - {#if showFullText} - {#each (showFullText ? paragraphs : paragraphs?.slice(0,1)) as paragraph, index} -

{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} + +
+ +
+ +
+
+ +
+ + +
+ +
+
+ + {#if data?.user?.tier === 'Pro'} + +
+ {#each tabs as item, i} + {/each} - {:else} - {paragraphs?.at(0)?.slice(0,250) + '...'} - {/if} +
+ + + + + Updated {rawData?.date} +
+ +
+ + {#if showFullText} + {#each (showFullText ? paragraphs : paragraphs?.slice(0,1)) as paragraph, index} +

{paragraph} {paragraphs?.length <= index+1 ? '' : '.'}

+ {/each} + {:else} + {paragraphs?.at(0)?.slice(0,250) + '...'} + {/if} +
+
+ {:else} +
+ + Unlock content with Pro Subscription +
+ {/if} + +
+ + + +
- {:else} -
- - Unlock content with Pro Subscription -
- {/if} - -
- - - - -
-{/if} \ No newline at end of file + {/if} \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index b532a508..f1aa4835 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -180,6 +180,7 @@ let Cookie; $showCookieConsent = typeof data?.cookieConsent !== 'undefined' ? false : true; onMount(async () => { + //await fallbackWorker(); await loadWorker(); //await pushNotification()