From 970e7567fcceb23d38b393b0de52e91955e33891 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 9 Feb 2024 18:38:17 -0500 Subject: [PATCH] More work on The Hub --- public/ae_bridge_init.js | 38 ++++++++++++++++++++++---------------- src/0_hub__main.svelte | 1 + 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/public/ae_bridge_init.js b/public/ae_bridge_init.js index 947c65fe..a73f555e 100644 --- a/public/ae_bridge_init.js +++ b/public/ae_bridge_init.js @@ -1,12 +1,15 @@ // These localStorage values were created when generating the HTML -// ae value is reset every page load -// ae_com value is ? + // let ae_local = window.localStorage.getItem('ae'); // Includes: cfg, client, page, other // let ae_session = window.sessionStorage.getItem('ae'); // Includes: cfg, client, page, other // let ae_com_local = window.localStorage.getItem('ae_com'); // let ae_com_session = window.sessionStorage.getItem('ae_com'); +if (window.localStorage.getItem('ae') === null) { + window.localStorage.setItem('ae', JSON.stringify({ 'cfg': {}, 'client': {}, 'page': {}, 'other': {}, 'test': {} })); +} + if (window.sessionStorage.getItem('ae') === null) { window.sessionStorage.setItem('ae', JSON.stringify({ 'cfg': {}, 'client': {}, 'page': {}, 'other': {}, 'test': {} })); } @@ -41,7 +44,7 @@ const ae_bridge = { // }, - // Monitor change in local storage AE + // Monitor change in **local** storage AE // Created and set when generating and then rendering the inital HTML and JS // ae_local_var: true, ae_local_var: JSON.parse(window.localStorage.getItem('ae')), @@ -60,7 +63,7 @@ const ae_bridge = { }, - // Monitor change in session storage AE + // Monitor change in **session* storage AE // Created and set when generating and then rendering the inital HTML and JS // ae_session_var: true, // ae_session_var: JSON.parse((window.sessionStorage.getItem('ae') ? window.sessionStorage.getItem('ae') : {'cfg': true, 'client': true, 'page': true, 'other': true})), @@ -149,19 +152,22 @@ const ae_bridge = { }; console.log('ae_bridge_init.js loaded'); -// console.log(ae_bridge.example); -// console.log(ae_bridge.ae_com); -// export let ae_bridge = ae_bridge; -// export { default as Element_sql_qry } +// Updated: 2024-02-09 +/* BEGIN: Add this to the stores.ts */ +// This adds a listener to the ae_bridge object. This can then be exported and used in the Svelte components. +// export let ae_example = writable(ae_bridge.ae_example); +// ae_bridge.register_ae_example_listener((new_value) => { +// console.log(`AE Bridge: AE Example: ${new_value}`); +// console.log(new_value); -/* Add this to the stores.ts */ -export let ae_example = writable(ae_bridge.ae_example); -ae_bridge.register_ae_example_listener((new_value) => { - console.log(`AE Bridge: AE Example: ${new_value}`); - console.log(new_value); +// ae_example.set(new_value); +// console.log(ae_example); +// }); +/* END: Add this to the stores.ts */ - ae_example.set(new_value); - console.log(ae_example); -}); \ No newline at end of file + +/* BEGIN: Add this to the Svelte components */ +// import { ae_example } from './stores'; +/* END: Add this to the Svelte components */ diff --git a/src/0_hub__main.svelte b/src/0_hub__main.svelte index 6fb040c1..18b5e4d3 100644 --- a/src/0_hub__main.svelte +++ b/src/0_hub__main.svelte @@ -66,6 +66,7 @@ async function handle_get_data_store_obj_w_code({code, data_type='text'}) { }); } +// In most cases we are just inserting HTML into the DOM. The Svelte module apps can update the ID's of the elements within if needed. $: if ($ae_app.hub.ds['hub_site_header']) { console.log('Hub Site Header:', $ae_app.hub.ds['hub_site_header']); const site_header_element = document.getElementById('Site-Header');