bugfixing: make it safari 15.6 compatible

This commit is contained in:
MuslemRahimi 2024-08-13 22:33:03 +02:00
parent d5c6d10a1a
commit 341d6c0120
2 changed files with 147 additions and 127 deletions

View File

@ -1,24 +1,43 @@
<script lang='ts'> <script lang='ts'>
import { stockTicker, displayCompanyName } from "$lib/store"; import { stockTicker, displayCompanyName } from "$lib/store";
import InfoModal from '$lib/components/InfoModal.svelte'; import InfoModal from '$lib/components/InfoModal.svelte';
export let data; export let data;
export let marketMoods = {}; export let marketMoods = {};
let rawData = marketMoods; let rawData = marketMoods;
let mode = 'bullish'; let mode = 'bullish';
let showFullText = false; let showFullText = false;
// Function to split text into paragraphs // Function to split text into paragraphs
function splitIntoParagraphs(text) { function splitIntoParagraphs(text) {
// Split the text into paragraphs based on periods followed by spaces, excluding numbers with decimals if (!text) return [];
return text?.replace('U.S.', 'US')?.split(/(?<!\d\.\d)(?<!vs)\.\s/);
// 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) { let paragraphs = splitIntoParagraphs(rawData?.bullSays);
function handleMode(i) {
activeIdx = i; activeIdx = i;
if(activeIdx === 0) { if(activeIdx === 0) {
paragraphs = splitIntoParagraphs(rawData?.bullSays); paragraphs = splitIntoParagraphs(rawData?.bullSays);
@ -26,9 +45,9 @@ function handleMode(i) {
else if (activeIdx === 1) { else if (activeIdx === 1) {
paragraphs = splitIntoParagraphs(rawData?.bearSays); paragraphs = splitIntoParagraphs(rawData?.bearSays);
} }
} }
const tabs = [ const tabs = [
{ {
title: "Bull Case", title: "Bull Case",
}, },
@ -39,21 +58,21 @@ const tabs = [
let activeIdx = 0; let activeIdx = 0;
$: { $: {
if($stockTicker && typeof window !== 'undefined') { if($stockTicker && typeof window !== 'undefined') {
rawData = marketMoods; rawData = marketMoods;
mode = 'bullish'; mode = 'bullish';
showFullText = false; showFullText = false;
paragraphs = splitIntoParagraphs(rawData?.bullSays); paragraphs = splitIntoParagraphs(rawData?.bullSays);
} }
} }
</script> </script>
{#if Object?.keys(marketMoods)?.length !== 0} {#if Object?.keys(marketMoods)?.length !== 0}
<div class="space-y-3 overflow-hidden"> <div class="space-y-3 overflow-hidden">
<!--Start Content--> <!--Start Content-->
<div class="w-auto lg:w-full p-1 flex flex-col m-auto"> <div class="w-auto lg:w-full p-1 flex flex-col m-auto">
@ -130,4 +149,4 @@ $: {
</div> </div>
{/if} {/if}

View File

@ -180,6 +180,7 @@ let Cookie;
$showCookieConsent = typeof data?.cookieConsent !== 'undefined' ? false : true; $showCookieConsent = typeof data?.cookieConsent !== 'undefined' ? false : true;
onMount(async () => { onMount(async () => {
//await fallbackWorker();
await loadWorker(); await loadWorker();
//await pushNotification() //await pushNotification()