diff --git a/src/routes/stock-screener/[strategyId]/+page.svelte b/src/routes/stock-screener/[strategyId]/+page.svelte index 1e988121..07cb90c4 100644 --- a/src/routes/stock-screener/[strategyId]/+page.svelte +++ b/src/routes/stock-screener/[strategyId]/+page.svelte @@ -7,6 +7,7 @@ import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js"; import { Button } from "$lib/components/shadcn/button/index.js"; //const userConfirmation = confirm('Unsaved changes detected. Leaving now will discard your strategy. Continue?'); + import { compareTwoStrings } from 'string-similarity'; import { writable } from 'svelte/store'; @@ -16,6 +17,8 @@ export let form; let isLoaded = false; let syncWorker: Worker | undefined; + let searchQuery = ''; + $: testList = []; $strategyId = data?.getStrategyId; let ruleOfList = data?.getStrategy?.rules ?? []; @@ -595,6 +598,23 @@ async function popularStrategy(state: string) { } +function handleInput(event) { + const searchQuery = event.target.value?.toLowerCase() || ''; + + setTimeout(() => { + testList = []; + + if (searchQuery.length > 0) { + testList = listOfRelevantCountries?.filter(item => { + const country = item?.toLowerCase(); + // Check if country starts with searchQuery + return country.startsWith(searchQuery); + }) || []; + } + console.log(testList); + }, 50); +} + @@ -803,17 +823,40 @@ async function popularStrategy(state: string) { + {:else} +