"src/vscode:/vscode.git/clone" did not exist on "4b1b412452218c5be5ac0f238454ec9309036798"
script.js 3.13 KB
Newer Older
1
$(() => {
2
    /* Use wider container for the page content */
3
4
5
    $(".wy-nav-content").each(function () {
        this.style.setProperty("max-width", "none", "important");
    });
6

7
8
    /* List each class property item on a new line
       https://github.com/microsoft/LightGBM/issues/5073 */
9
10
11
12
    if (window.location.pathname.toLocaleLowerCase().indexOf("pythonapi") !== -1) {
        $(".py.property").each(function () {
            this.style.setProperty("display", "inline", "important");
        });
13
14
    }

15
    /* Collapse specified sections in the installation guide */
16
17
    if (window.location.pathname.toLocaleLowerCase().indexOf("installation-guide") !== -1) {
        $(
18
            '<style>.closed, .opened {cursor: pointer;} .closed:before, .opened:before {font-family: FontAwesome; display: inline-block; padding-right: 6px;} .closed:before {content: "\\f054";} .opened:before {content: "\\f078";}</style>',
19
        ).appendTo("body");
20
        const collapsible = [
21
22
23
24
            "#build-threadless-version-not-recommended",
            "#build-mpi-version",
            "#build-gpu-version",
            "#build-cuda-version",
Jeff Daily's avatar
Jeff Daily committed
25
            "#build-rocm-version",
26
            "#build-java-wrapper",
27
28
            "#build-python-package",
            "#build-r-package",
29
            "#build-c-unit-tests",
30
        ];
31
        $.each(collapsible, (_, val) => {
32
33
34
            const header = `${val} > :header:first`;
            const content = `${val} :not(:header:first)`;
            $(header).addClass("closed");
35
            $(content).hide();
36
37
            $(header).click(() => {
                $(header).toggleClass("closed opened");
38
39
40
41
42
                $(content).slideToggle(0);
            });
        });
        /* Uncollapse parent sections when nested section is specified in the URL or before navigate to it from navbar */
        function uncollapse(section) {
43
44
45
            section.parents().each((_, val) => {
                $(val).children(".closed").click();
            });
46
47
        }
        uncollapse($(window.location.hash));
48
49
        $(".wy-menu.wy-menu-vertical li a.reference.internal").click(function () {
            uncollapse($($(this).attr("href")));
50
        });
51
52
53

        /* Modify src and href attrs of artifacts badge */
        function modifyBadge(src, href) {
54
            $('img[alt="download artifacts"]').each(function () {
55
56
57
58
59
                this.src = src;
                this.parentNode.href = href;
            });
        }
        /* Initialize artifacts badge */
60
        modifyBadge("./_static/images/artifacts-fetching.svg", "#");
61
        /* Fetch latest buildId and construct artifacts badge */
62
63
64
65
66
67
68
69
70
        $.getJSON(
            "https://dev.azure.com/lightgbm-ci/lightgbm-ci/_apis/build/builds?branchName=refs/heads/master&resultFilter=succeeded&queryOrder=finishTimeDescending&%24top=1&api-version=7.1-preview.7",
            (data) => {
                modifyBadge(
                    "./_static/images/artifacts-download.svg",
                    `https://dev.azure.com/lightgbm-ci/lightgbm-ci/_apis/build/builds/${data.value[0].id}/artifacts?artifactName=PackageAssets&api-version=7.1-preview.5&%24format=zip`,
                );
            },
        );
71
    }
72
});