aboutsummaryrefslogtreecommitdiff
path: root/src/js/arching-kaos-spa-router.js
blob: 03eac119db1b543b67d6ab6809c13f5e7afbfd2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * A new feature for a new future:
 *
 * We will get `location.search` values to figure out where the visitor wants
 * to go.
 *
 * We should then replace the menu links with these ones.
 *
 * We should also modify the existing menu mechanism to show/hide depending on
 * 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();
    }
}