assets/js/index-page.js
//Takes in the path as a parameter
Takes in the path as a parameter
Takes in the path as a parameter
function evaluatePath(path) {
    if (path == '/dashboard/') {
        var openSection = $("[aria-expanded='true']");
        openSection.collapse('hide');
        $('.dashboard-sections-wrapper').hide();
        $('#no-topics').show();
        $('#sections-list').css('margin-top', "0");
        $('.nav-buttons-wrapper').removeClass("right-wall-topic-menu");
        $("li.nav-buttons-wrapper.active").removeClass("active");
        return;
    }
    var newPath = path.split("/");
    if (newPath[0] == "https:") {
        return;
    }
    var pathToParse = newPath;
    if (newPath.length == 5) {
        var dashboard = pathToParse.pop();
        var section = pathToParse.pop();
        var topic = pathToParse.pop();
    } else if (newPath.length == 4) {
        var section = pathToParse.pop();
        var topic = pathToParse.pop();
    } else if (newPath.length == 3) {
        var topic = pathToParse.pop();
        var openSection = $("[aria-expanded='true']");
        openSection.collapse('hide');
    } else if (newPath.length < 2 || newPath.length > 5) {
        show404();
        return;
    }
    if (topic !== "" && topic !== ".." && topic !== 'login') {
        var topicId = document.getElementById(topic);
        if (topicId == null) {
            show404();
            return;
        } else {
            $('#no-topics').hide();
            var currentActiveSection = document.querySelector('[active-section-list="true"]');
            $(".nav-buttons-wrapper.active").removeClass("active");
            if (currentActiveSection != null) {
                currentActiveSection.setAttribute('active-section-list', false);
                $(currentActiveSection).hide();
            }
            var newSectionToShow = topicId;
            topicId.setAttribute('active-section-list', true);
            $(topicId).show();
            var topicBtn = document.getElementsByClassName("nav-buttons btn topic-buttons " + topic);
            var topicWrapper = topicBtn[0].closest(".nav-buttons-wrapper");
            $(topicWrapper).addClass("active");
        }
    }
    if (section !== undefined && section !== 'verifylogin') {
        var sect = $("#" + section, $(topicId));
        var sectionId = sect.attr("id");
        if (sectionId === undefined) {
            show404();
            return;
        } else {
            $("#" + sectionId).collapse("show");
        }
    }
    if (dashboard !== undefined) {
        var dash = $("#" + dashboard, $("#" + sectionId));
        var val = dash.attr('val');
        if (val == null) {
            show404();
        } else {
            showDashboard(val);
        }
    }
}
function evaluatePath ( path ) { if ( path == '/dashboard/' ) { var openSection = $ ( "[aria-expanded='true']" ) ; openSection . collapse ( 'hide' ) ; $ ( '.dashboard-sections-wrapper' ) . hide ( ) ; $ ( '#no-topics' ) . show ( ) ; $ ( '#sections-list' ) . css ( 'margin-top' , "0" ) ; $ ( '.nav-buttons-wrapper' ) . removeClass ( "right-wall-topic-menu" ) ; $ ( "li.nav-buttons-wrapper.active" ) . removeClass ( "active" ) ; return ; } var newPath = path . split ( "/" ) ; if ( newPath [ 0 ] == "https:" ) { return ; } var pathToParse = newPath ; if ( newPath . length == 5 ) { var dashboard = pathToParse . pop ( ) ; var section = pathToParse . pop ( ) ; var topic = pathToParse . pop ( ) ; } else if ( newPath . length == 4 ) { var section = pathToParse . pop ( ) ; var topic = pathToParse . pop ( ) ; } else if ( newPath . length == 3 ) { var topic = pathToParse . pop ( ) ; var openSection = $ ( "[aria-expanded='true']" ) ; openSection . collapse ( 'hide' ) ; } else if ( newPath . length < 2 || newPath . length > 5 ) { show404 ( ) ; return ; } if ( topic !== "" && topic !== ".." && topic !== 'login' ) { var topicId = document . getElementById ( topic ) ; if ( topicId == null ) { show404 ( ) ; return ; } else { $ ( '#no-topics' ) . hide ( ) ; var currentActiveSection = document . querySelector ( '[active-section-list="true"]' ) ; $ ( ".nav-buttons-wrapper.active" ) . removeClass ( "active" ) ; if ( currentActiveSection != null ) { currentActiveSection . setAttribute ( 'active-section-list' , false ) ; $ ( currentActiveSection ) . hide ( ) ; } var newSectionToShow = topicId ; topicId . setAttribute ( 'active-section-list' , true ) ; $ ( topicId ) . show ( ) ; var topicBtn = document . getElementsByClassName ( "nav-buttons btn topic-buttons " + topic ) ; var topicWrapper = topicBtn [ 0 ] . closest ( ".nav-buttons-wrapper" ) ; $ ( topicWrapper ) . addClass ( "active" ) ; } } if ( section !== undefined && section !== 'verifylogin' ) { var sect = $ ( "#" + section , $ ( topicId ) ) ; var sectionId = sect . attr ( "id" ) ; if ( sectionId === undefined ) { show404 ( ) ; return ; } else { $ ( "#" + sectionId ) . collapse ( "show" ) ; } } if ( dashboard !== undefined ) { var dash = $ ( "#" + dashboard , $ ( "#" + sectionId ) ) ; var val = dash . attr ( 'val' ) ; if ( val == null ) { show404 ( ) ; } else { showDashboard ( val ) ; } } }
Takes in the path as a parameter
Takes in the path as a parameter
//$("[aria-expanded='true']").attr("aria-expanded", "false"); //Splits the path with '/' as a delimiter //If length is 5, it is assumed that the format of the url is host/[dashboard]/topic/section/dashboard //If the length is 4: host/[dashboard]/topic/section //If the length is 3: host/[dashboard]/topic //2: index page //If the length is less than 2 or greater than 5, show 404 //Then we try to look for the correct topic //If the topic ID is not found, we show a 404 //Otherwise, we hide the div that shows when there are no topics visible, //We show the topic -- and we want to make active the correct topic button, //So we look for that and add the active class to it //$(currentTopicName).removeClass("active"); //$(document).find('[active-section-list]').hide(); //$("#" + convertNameToId($(document).find(".active .topic-buttons").text())).hide(); // find the id of the list of sections to show //$(document).find(".active .topic-buttons").text(); //If the topic is correct/found/kosher, we assume that they would have hit a 404 otherwise by now //So we look for the correct section next //If the section was correct, we look for the appropriate dashboard. //Here, we have a much higher possibility of duplicates, so we have to look for the dashboard //in the context of the section. We get the correct dashboard, get the correct value (another URL) //then we call the showDashboard function with the appropriate url/val.