aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2023-09-06 23:30:15 +0300
committerkaotisk <kaotisk@arching-kaos.org>2023-09-06 23:30:15 +0300
commitb66f638a81b8133b795a4757c3391afc87c54ba3 (patch)
treeedd7191cf7ee328ee8faea105c0dc2f91cfa3c07 /src
parenta4097105989dbde323c7b21426ca3437e8ac8be0 (diff)
downloadarching-kaos-web-ui-b66f638a81b8133b795a4757c3391afc87c54ba3.tar.gz
arching-kaos-web-ui-b66f638a81b8133b795a4757c3391afc87c54ba3.tar.bz2
arching-kaos-web-ui-b66f638a81b8133b795a4757c3391afc87c54ba3.zip
Introduced SPA router and make use of it
Diffstat (limited to 'src')
-rw-r--r--src/index.html1
-rw-r--r--src/js/arching-kaos-spa-router.js27
-rw-r--r--src/js/menu-magic.js3
3 files changed, 29 insertions, 2 deletions
diff --git a/src/index.html b/src/index.html
index e9f77bb..a8f6c15 100644
--- a/src/index.html
+++ b/src/index.html
@@ -208,6 +208,7 @@
<script src="./js/arching-kaos-fetch.js"></script>
<script src="./js/arching-kaos-log.js"></script>
<script src="./js/menu-magic.js"></script>
+ <script src="./js/arching-kaos-spa-router.js"></script>
<script src="./js/arching-kaos-tools.js"></script>
<script src="./js/arching-kaos-stellar-network.js"></script>
<script src="./js/arching-kaos-decentralized-radio.js"></script>
diff --git a/src/js/arching-kaos-spa-router.js b/src/js/arching-kaos-spa-router.js
index 650a828..03eac11 100644
--- a/src/js/arching-kaos-spa-router.js
+++ b/src/js/arching-kaos-spa-router.js
@@ -1,4 +1,3 @@
-
/*
* A new feature for a new future:
*
@@ -11,3 +10,29 @@
* the "route" we got from `location.search`.
*
*/
+
+function locationHashSetter(value){
+ window.location.hash = value;
+ locationHashOnChange();
+}
+
+function locationHashGetter(){
+ return window.location.hash;
+}
+
+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);
+ } else {
+ menuinit();
+ }
+}
diff --git a/src/js/menu-magic.js b/src/js/menu-magic.js
index b4ee247..7abd050 100644
--- a/src/js/menu-magic.js
+++ b/src/js/menu-magic.js
@@ -44,7 +44,8 @@ function menuinit(){
*/
function menusel(m){
menuinit();
- document.querySelector(m.id.replace('/','')).hidden=false;
+ // document.querySelector(m.id.replace('/','')).hidden=false;
+ locationHashSetter(m.id);
mainContainer.style.display = 'block';
if ( isMobile ) {