From 0b6909371840d482902c9217adf5fab440e196aa Mon Sep 17 00:00:00 2001 From: kaotisk Date: Sun, 17 Mar 2024 03:34:53 +0200 Subject: Reworked routing --- src/js/arching-kaos-spa-router.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/js/arching-kaos-spa-router.js') diff --git a/src/js/arching-kaos-spa-router.js b/src/js/arching-kaos-spa-router.js index e5d5d2a..162f1e2 100644 --- a/src/js/arching-kaos-spa-router.js +++ b/src/js/arching-kaos-spa-router.js @@ -22,12 +22,15 @@ function locationHashGetter(){ function locationHashOnChange(){ var route = new Object; - route.id = locationHashGetter(); + route.full = locationHashGetter(); + route.args = route.full.split('/'); + route.menuid = '#'+route.args[1]; + route.subcommand = route.args[2]; 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 if ( (locationHashGetter() !== 'undefined') && ( menuids.includes(route.menuid))){ + document.querySelector(route.menuid).hidden=false; } else { document.querySelector('#not-found-section').hidden=false; } -- cgit v1.2.3