diff --git a/src/lib/ae_stores.ts b/src/lib/ae_stores.ts index 206ee62a..976a683a 100644 --- a/src/lib/ae_stores.ts +++ b/src/lib/ae_stores.ts @@ -189,6 +189,9 @@ ae_api_data_struct['headers'] = ae_api_headers; console.log(`AE Stores - API Data:`, ae_api_data_struct); export let ae_api = writable(ae_api_data_struct); +// *** BEGIN *** Trigger to update the slct variables and other things. +let ae_trig_template: key_val = {}; +export let ae_trig = writable(ae_trig_template); /* *** BEGIN *** Initialize slct_trigger and slct variables. The slct variable can be stored with local storage. */ // Updated 2024-02-27 diff --git a/src/lib/ae_utils.ts b/src/lib/ae_utils.ts index d6726b76..8057dc3f 100644 --- a/src/lib/ae_utils.ts +++ b/src/lib/ae_utils.ts @@ -405,10 +405,39 @@ export let process_permission_checks = function process_permission_checks(access } +// This function will update the URL and send a message to the parent window (iframe). +// The name should be something like "example_id". +// Svelte specific: +// WARNING: Avoid using `history.pushState(...)` and `history.replaceState(...)` as these will conflict with SvelteKit's router. Use the `pushState` and `replaceState` imports from `$app/navigation` instead. +// Updated 2024-03-02 +function handle_url_and_message(name: string, value: null|string) { + console.log(`*** handle_url_and_message() *** name=${name} value=${value}`); + + if (value) { + let location = window.location.href; + const url = new URL(location); + url.searchParams.set(name, value); + history.pushState({}, '', url); + + let message = {name: value}; + window.parent.postMessage(message, "*"); + } else { + let location = window.location.href; + const url = new URL(location); + url.searchParams.delete(name); + history.pushState({}, '', url); + + let message = {name: null}; + window.parent.postMessage(message, "*"); + } + // console.log('Message sent to parent (iframe):', message); +} + export let ae_util = { iso_datetime_formatter: iso_datetime_formatter, extract_prefixed_form_data: extract_prefixed_form_data, process_permission_checks: process_permission_checks, + handle_url_and_message: handle_url_and_message, }; // export default ae_util; \ No newline at end of file diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 8c4d9adc..fba46b41 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,4 +1,8 @@
+{#if $ae_loc.ds.hub__page__sponsorships__create_info_header} +{@html $ae_loc.ds.hub__page__sponsorships__create_info_header} +{:else} +
+

Information Goes Here

+
+{/if} + + + + +{#if $slct.sponsorship_id} + +{:else} + +{/if} + + {#if $ae_loc.ds.hub__page__sponsorships__create_info} {@html $ae_loc.ds.hub__page__sponsorships__create_info} {:else} - -
-

Information Goes Here

-
-
More information goes here.
- {/if} - - -