From 63530324338de5e25853eaf8d7a85dbd8ca724ee Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 11 Sep 2023 21:45:02 +0300 Subject: Changed way we init and handle location --- src/js/app.js | 3 +-- src/js/arching-kaos-spa-router.js | 20 ++++++++------------ 2 files changed, 9 insertions(+), 14 deletions(-) (limited to 'src/js') diff --git a/src/js/app.js b/src/js/app.js index c3e4c06..e246a19 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -19,8 +19,7 @@ window.addEventListener('resize', () => { // And call menuinit(); -// We bring up the default pane ( #welcome-section ) -document.querySelector('#welcome-section').hidden=false; +locationHashOnChange(); progressPlaceholder.value = '0'; diff --git a/src/js/arching-kaos-spa-router.js b/src/js/arching-kaos-spa-router.js index 03eac11..e5d5d2a 100644 --- a/src/js/arching-kaos-spa-router.js +++ b/src/js/arching-kaos-spa-router.js @@ -21,18 +21,14 @@ function locationHashGetter(){ } function locationHashOnChange(){ - if ( window.location.hash !== 'undefined' ){ - var route = new Object; - route.id = window.location.hash; - console.log(route); - menuinit(); - if ( menuids.includes(route.id.replace('/','')) ){ - document.querySelector(route.id.replace('/','')).hidden=false; - } else { - document.querySelector('#not-found-section').hidden=false; - } - //menusel(route); + var route = new Object; + route.id = locationHashGetter(); + menuinit(); + if ( (locationHashGetter() !== 'undefined') && (locationHashGetter() === '') ){ + document.querySelector('#welcome-section').hidden=false; + } else if ( (locationHashGetter() !== 'undefined') && ( menuids.includes(route.id.replace('/',''))) ){ + document.querySelector(route.id.replace('/','')).hidden=false; } else { - menuinit(); + document.querySelector('#not-found-section').hidden=false; } } -- cgit v1.2.3