summaryrefslogtreecommitdiff
path: root/frontend/index.js
blob: d0f27f33b52c86cbefda88f953fb104087b59709 (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
/// <reference path="scripts/jquery-3.5.1.min.js"/>

(function() {
    function main() {
        
        $.get('/navbar.html', function(pData) {
            $('nav').html(pData);                 
            
            // Set selected tab as selected            
            $('nav').find('a').removeClass('nav-selected');
            $('nav').find('a[href="' + window.location.pathname + '"').addClass('nav-selected');

            // Set up tree callbacks
            $('.outer-tree > li').click(function() {
                $(this).toggleClass('expanded');
            })

            $('.inner-tree > li').click(function(pEv) {
                pEv.stopPropagation();
            })

            // Open up the selected document from the navigation tree
            var lSplitPath = window.location.pathname.split('/');
            if (lSplitPath.length < 3) {
                return;
            }

            if (lSplitPath[1] === '2d') {
                $('nav > ul > li:nth-child(2)').addClass('expanded');
                $('nav > ul > li:last-child').removeClass('expanded');
            }
        });
    }
    
    $(document).ready(main);
})()