function loadMainContent()

in wiki-interface/ui/js/sidebar_br.js [22:115]


function loadMainContent(page) {
    const mainContentDiv = document.getElementById("main-content");
    const loadingDiv = document.getElementById("loading");
    const ratingDiv = document.getElementById("rating-content")
    let url = "";

    switch (page) {
        case "about":
            url = "/ui/about";
            break;
        case "userstory":
            url = "/ui/userstory";
            break;
        case "testcase":
            url = "/ui/testcase";
            break;
        case "testscript":
            url = "/ui/testscript";
            break;
        case "testdata":
            url = "/ui/testdata";
            break;
        case "codechatbot":
            url = "/ui/codechatbot";
            break;
        case "docchatbot":
            url = "/ui/docchatbot";
            break;
        case "codesearch":
            url = "/ui/codesearch";
            break;
        case "solutionoverview":
            url = "/ui/solutionoverview";
            break;
        case "solutiondatabase":
            url = "/ui/solutiondatabase";
            break;
        case "solutionapi":
            url = "/ui/solutionapi";
            break;
        case "solutiondep":
            url = "/ui/solutiondep";
            break;
        case "solutionintegration":
            url = "/ui/solutionintegration";
            break;
        case "solutionsecurity":
            url = "/ui/solutionsecurity";
            break;
        case "selectproject":
            url = "/ui/selectproject";
            break;
        default:
            url = "/ui/about";
            break;
    }

    mainContentDiv.style.display = "none";
    ratingDiv.style.display = "none";
    loadingDiv.style.display = "block";

    /* Fetch the HTML content from the specified URL */
    fetch(url)
        .then(response => {
            if (!response.ok) {
                throw new Error(`HTTP error! status: ${response.status}`);
            }
            return response.text();
        })
        .then(htmlContent => {
            /* Update the innerHTML of the div with the loaded content */
            mainContentDiv.innerHTML = htmlContent;
        })
        .catch(error => {
            console.error("Error loading HTML:", error);
            mainContentDiv.innerHTML = "<p>Failed to load content. Please try again later.</p>";
        });

    waitContentLoad(() => {
        loadingDiv.style.display = "none";
        mainContentDiv.style.display = "block";

        /* If we're on chatbots, we'll wait for the sessions on GCS */
        if (page == "codechatbot" || page == "docchatbot") {
            checkReady();
        } else {
            if (page == "userstory" || page == "testcase" || page == "testscript") {
                fetchAndPopulateSelect(page);
            } else if (page == "selectproject") {
                loadProjectList();
            }
        }
    });
}