aboutsummaryrefslogtreecommitdiff
path: root/src/js/arching-kaos-spa-router.js
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-11-29 16:23:39 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-11-29 16:23:39 +0200
commitafcedd44615d20423d58f4d9c9d8cfa3838a54d4 (patch)
treee16cd7f2eb4040f7b237baa45aa3f8f80516dcc4 /src/js/arching-kaos-spa-router.js
parent084e3ce6efc49c2d43ce9b44d96e430f8057848e (diff)
downloadarching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.tar.gz
arching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.tar.bz2
arching-kaos-web-ui-afcedd44615d20423d58f4d9c9d8cfa3838a54d4.zip
Major refactoring
Diffstat (limited to 'src/js/arching-kaos-spa-router.js')
-rw-r--r--src/js/arching-kaos-spa-router.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/js/arching-kaos-spa-router.js b/src/js/arching-kaos-spa-router.js
index 1775d24..162a316 100644
--- a/src/js/arching-kaos-spa-router.js
+++ b/src/js/arching-kaos-spa-router.js
@@ -17,17 +17,31 @@
* the "route" we got from `location.search`.
*
*/
+import { menuinit, menuids } from "./ui/menu.js";
-function locationHashSetter(value){
+export function locationHashSetter(value)
+{
window.location.hash = value;
locationHashOnChange();
}
-function locationHashGetter(){
+export function locationHashGetter()
+{
return window.location.hash;
}
-function locationHashOnChange(){
+export function getWelcomeSection()
+{
+ return document.querySelector('#welcome-section');
+}
+
+export function getSoftError()
+{
+ return document.querySelector('#not-found-section');
+}
+
+export function locationHashOnChange()
+{
var route = new Object;
route.full = locationHashGetter();
route.args = route.full.split('/');
@@ -35,19 +49,19 @@ function locationHashOnChange(){
route.subcommand = route.args[2];
menuinit();
if ( (locationHashGetter() !== 'undefined') && (locationHashGetter() === '') ){
- document.querySelector('#welcome-section').hidden=false;
+ getWelcomeSection.hidden=false;
}
else if ( route.args[1] == "route" ) {
- document.querySelector('#welcome-section').hidden=false;
+ getWelcomeSection.hidden=false;
if ( route.args.length === 4 ) {
if ( route.args[2] === "zblock" ) {
seekZblock(route.args[3], ['search', false]);
}
}
- } else if ( (locationHashGetter() !== 'undefined') && ( menuids.includes(route.menuid))){
+ } else if ( (locationHashGetter() !== 'undefined') && ( menuids().includes(route.menuid))){
document.querySelector(route.menuid).hidden=false;
} else {
- document.querySelector('#not-found-section').hidden=false;
+ getSoftError().hidden=false;
}
}