PageSourceSearch

https://www.stcloudstate.edu/header-footer/department-api.js

js stcloudstate.edu collected 2026-09-24 08:35:38 UTC 6,743 bytes, 135 lines download raw bytes

1let attempts = 0;
2let maxAttempts = 20;
3let checkForToggle = setInterval(function() {
4    if ($('.cludo-input-form').length) {
5        $('.cludo-input-form').hide();
6        clearInterval(checkForToggle);
7    }
8    if (++attempts >= maxAttempts) {
9        clearInterval(checkForToggle);
10    }
11}, 100);
12
13// Fetch department data
14const dataParams = {
15    footerUrl: document.URL
16};
17const fetchUrl = new URL("https://azfunc-api-scsu-prod-apim.azure-api.net/department/ns1/footerInfo");
18for (let key in dataParams) {
19    fetchUrl.searchParams.append(key, dataParams[key]);
20}
21fetch(fetchUrl).then(response => response.json()).then(async data => {
22    const gakey = data[0].AnalyticsAccount;
23    $.get('/header-footer/header.html', header => {
24        $('body').prepend(header);
25        $('html').css('visibility', 'visible');
26        $('#scroll-down-button').show();
27        $('.carousel__slides').css('visibility', 'visible').addClass('display__slides');
28    });
29    $.get('/header-footer/analytics.html', analytics => {
30        $('head').append(analytics.replace(/gakey/g, gakey));
31    });
32    $("#api-footer").load("/header-footer/footer.html", function() {
33        document.querySelector("#year-api").textContent = new Date().getFullYear();
34        let footerHTML = '';
35        if (data[0].OfficeName) footerHTML += `<span id="footer-office-name"><strong>${data[0].OfficeName}</strong><br></span>`;
36        if (data[0].DeptID) footerHTML += `<a id="footer-office-link" href="https://directory.stcloudstate.edu/Departments/DeptContact?deptId=${data[0].DeptID}">Contact Information<br></a>`;
37        if (data[0].Phone) footerHTML += `<a id="footer-office-phone" href="tel:${data[0].Phone}">${data[0].Phone}<br></a>`;
38        if (footerHTML) footerHTML += '<br>';
39        if (data[0].CampusAddress) footerHTML += `<span id="footer-address">${data[0].CampusAddress}</span>`;
40        $(this).html($(this).html().replaceAll("<!--DeptFooter-->", footerHTML));
41    });
42}).catch(() => {
43    $.get('/header-footer/header.html', header => {
44        $('body').prepend(header);
45        $('html').css('visibility', 'visible');
46        $('#scroll-down-button').show();
47        $('.carousel__slides').css('visibility', 'visible').addClass('display__slides');
48    });
49    $.get('/header-footer/analytics.html', analytics => {
50        $('head').append(analytics.replace(/gakey/g, ''));
51    });
52    $("#api-footer").load("/header-footer/footer.html", function() {
53        document.querySelector("#year-api").textContent = new Date().getFullYear();
54        $(this).html($(this).html().replaceAll("<!--DeptFooter-->", `<span id="footer-address">St. Cloud State University<br>720 4th Avenue South<br>St. Cloud, MN 56301-4498<br><a href="tel:320-308-0121">(320) 308-0121</a></span>`));
55    });
56    console.error("Is " + document.URL + " in the Department database?");
57}).finally(() => {
58    $(document).ready(function() {
59        $('html').css('visibility', 'visible');
60        $('#scroll-down-button').show();
61
62        // --- Cludo injection ---
63        (function() {
64            const MAIN_SCRIPT = "https://customer.cludo.com/scripts/bundles/search-script.min.js";
65            const RESULTS_SCRIPT = "https://customer.cludo.com/templates/rich-inline/v1.0/dist/js/cludo-search-results.js";
66            const MAX_WAIT_MS = 20000; // 20s max wait
67            const POLL_INTERVAL = 100;
68            
69            let attempts = 0;
70            const waitForInput = setInterval(() => {
71                const inputEl = document.querySelector('.cludo-input-form');
72                if (inputEl) {
73                    clearInterval(waitForInput);
74                    
75                    // Example: fetch customerId/engineId from data attributes or defaults
76                    const customerId = inputEl.getAttribute('data-customer-id') || "10000410";
77                    const engineId = inputEl.getAttribute('data-engine-id') || "10000606";
78                    if (!customerId || !engineId) {
79                        console.warn("Missing Cludo config values. Skipping Cludo initialization.");
80                        showFallback();
81                        return;
82                    }
83
84                    // Set Cludo config
85                    window.cludoConfig = {
86                        customerId: customerId,
87                        engineId: engineId,
88                        language: "en",
89                        searchUrl: "https://www.stcloudstate.edu/search/results.aspx",
90                        searchInputSelectors: [".cludo-input-form", "#cludo-search-form"],
91                        showInstantSuggestions: true,
92                        autocomplete: { useSearchAsYouType: true },
93                        behavior: { endlessScroll: { stopAfterPage: 3, resultsPerPage: 10, bottomOffset: 550 } }
94                    };
95
96                    // Load main script
97                    loadScript(MAIN_SCRIPT).then(() => loadScript(RESULTS_SCRIPT))
98                        .then(() => $('.cludo-input-form').show())
99                        .catch(err => { console.error("Cludo script load failed:", err); showFallback(); });
100
101                    function loadScript(src) {
102                        return new Promise((resolve, reject) => {
103                            const s = document.createElement("script");
104                            s.src = src;
105                            s.async = true;
106                            s.onload = () => resolve(src);
107                            s.onerror = () => reject(new Error("Failed to load " + src));
108                            (document.body || document.head).appendChild(s);
109                        });
110                    }
111
112                    function showFallback() {
113                        const $form = $('.cludo-input-form');
114                        if ($form.length && !$form.data('search-message-shown')) {
115                            $form.hide().data('search-message-shown', true);
116                            $form.after(`
117                                <p style="margin-top: 6rem; text-align: center; color: white; font-size: 1.6rem">
118                                    Search functionality is currently unavailable. Please try again later.
119                                </p>
120                            `);
121                        }
122                    }
123
124                } else if ((attempts * POLL_INTERVAL) >= MAX_WAIT_MS) {
125                    clearInterval(waitForInput);
126                    console.warn("Cludo input form not found within timeout. Skipping script injection.");
127                    showFallback();
128                } else {
129                    attempts++;
130                }
131            }, POLL_INTERVAL);
132        })();
133        // --- End Cludo injection ---
134    });
135});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.