PageSourceSearch

https://blogs.iis.net/wwwroot/scripts/userblog-script.js

js iis.net collected 2026-10-01 06:50:30 UTC 10,087 bytes, 307 lines download raw bytes

1(function () {
2  let siteConsent = null;
3
4  const analytics = new oneDS.ApplicationInsights();
5  const config = {
6    instrumentationKey:
7      "4181d76f98054ec6a4a9b8e669b3d510-a9e74d90-c641-41b4-8498-056decd0ac58-7286",
8    channelConfiguration: {
9      // Post channel configuration
10      eventsLimitInMem: 5000,
11    },
12    propertyConfiguration: {
13      // Properties Plugin configuration
14      env: "PROD", // Environment can be set to PPE or PROD as needed.
15      // false = opted out. Prefer server-injected GPC_DataSharingOptIn (matches .NET); else the browser GPC signal.
16      gpcDataSharingOptIn:
17        typeof GPC_DataSharingOptIn !== "undefined"
18          ? GPC_DataSharingOptIn
19          : navigator.globalPrivacyControl === true
20            ? false
21            : true,
22      callback: {
23        userConsentDetails: function () {
24          return typeof WcpConsent !== "undefined" && WcpConsent.siteConsent
25            ? WcpConsent.siteConsent.getConsent()
26            : undefined;
27        },
28      },
29    },
30    webAnalyticsConfiguration: {
31      // Web Analytics Plugin configuration
32      autoCapture: {
33        scroll: true,
34        pageView: true,
35        onLoad: true,
36        onUnload: true,
37        click: true,
38        resize: true,
39        jsError: true,
40      },
41    },
42  };
43
44  window.addEventListener("DOMContentLoaded", function () {
45    WcpConsent.init("en-US", "cookie-banner", function (err, _siteConsent) {
46      if (err != undefined) {
47        return error;
48      } else {
49        siteConsent = _siteConsent; // SiteConsent is used to get the current consent
50      }
51    });
52
53    if (siteConsent.isConsentRequired) {
54      isConsentAdvertising = siteConsent.getConsentFor(
55        WcpConsent.consentCategories.Advertising,
56      );
57      document.getElementsByClassName("manageCookieChoice")[0].style.display =
58        "inline-block";
59    } else {
60      document.getElementsByClassName("manageCookieChoice")[0].style.display =
61        "none";
62      isConsentAdvertising = true;
63    }
64
65    addNavBarMobileEvent();
66
67    const solutionsMenu = document.getElementById("solutions-menu");
68
69    if (!!solutionsMenu) {
70      const anchor = solutionsMenu.querySelector('a[data-toggle="dropdown"]');
71
72      if (anchor) {
73        anchor.addEventListener("click", function (e) {
74          e.preventDefault();
75          toggleDropdown(solutionsMenu);
76        });
77
78        // Close dropdown when clicking outside
79        document.addEventListener("click", function (e) {
80          if (
81            !solutionsMenu.contains(e.target) &&
82            anchor.getAttribute("aria-expanded") === "true"
83          ) {
84            anchor.setAttribute("aria-expanded", "false");
85            const dropdown = solutionsMenu.querySelector("div");
86            if (dropdown) dropdown.style.display = "none";
87            solutionsMenu.classList.remove("open");
88          }
89        });
90      }
91    }
92
93    siteConsent.onConsentChanged(watchConsentChanges);
94
95    if (siteConsent.getConsentFor(WcpConsent.consentCategories.Analytics)) {
96      // Load analytics scripts or enable analytics features
97    } else {
98      dropAnalyticsCookies();
99    }
100
101    manageNonAdvertise();
102
103    function watchConsentChanges(categoryPreferences) {
104      manageNonAdvertise();
105      // Scan through the categories and take action based on user consent.
106      if (siteConsent.getConsentFor(WcpConsent.consentCategories.Analytics)) {
107        // Load analytics scripts or enable analytics features
108      } else {
109        dropAnalyticsCookies();
110      }
111    }
112  });
113
114  // Cross-domain iframe to read 3PAdsOptOut cookie from the microsoft.com domain.
115  (function () {
116    const PRIVACY_ORIGIN = "https://iisprivacy.microsoft.com";
117    const iFrame = document.createElement("iframe");
118    iFrame.style.width = "0";
119    iFrame.style.height = "0";
120    iFrame.style.position = "absolute";
121    iFrame.style.border = "none";
122    iFrame.src = PRIVACY_ORIGIN;
123
124    let messageEventListener;
125    window.optOutPromise = new Promise(function (resolve) {
126      messageEventListener = function (event) {
127        if (event.origin === PRIVACY_ORIGIN) {
128          const optOutEventData = event.data && event.data["3PAdsOptOut"];
129          if (typeof optOutEventData !== "undefined") {
130            resolve(optOutEventData === "1");
131          } else {
132            resolve(false);
133          }
134          window.removeEventListener("message", messageEventListener);
135          iFrame.remove();
136        }
137      };
138    });
139    window.addEventListener("message", messageEventListener);
140
141    window.addEventListener("DOMContentLoaded", function () {
142      document.body.appendChild(iFrame);
143    });
144  })();
145
146  // Defer SDK initialization until the data-sharing opt-out state is resolved so
147  // the first auto-captured page view carries the correct value. GPC is read
148  // after load to avoid the Chromium extension-injection race (reading too early
149  // could miss a real opt-out).
150  let sdkInitialized = false;
151
152  function initializeWith(optedOut) {
153    if (sdkInitialized) {
154      return;
155    }
156    sdkInitialized = true;
157    config.propertyConfiguration.gpcDataSharingOptIn = !optedOut;
158    analytics.initialize(config, []);
159  }
160
161  // Returns true (opted out), false (not opted out) or null (unknown, use cookie).
162  function readDataSharingOptOut() {
163    // Prefer a server/edge-injected value, matching the .NET implementation.
164    if (typeof GPC_DataSharingOptIn !== "undefined") {
165      return !GPC_DataSharingOptIn;
166    }
167    // Static-site fallback: honor the browser/extension GPC signal.
168    if (navigator.globalPrivacyControl === true) {
169      return true;
170    }
171    return null;
172  }
173
174  function resolveOptOutAndInitialize() {
175    const optedOut = readDataSharingOptOut();
176    if (optedOut !== null) {
177      initializeWith(optedOut);
178      return;
179    }
180
181    // No explicit signal yet: fall back to the 3PAdsOptOut cookie.
182    let settled = false;
183    window.optOutPromise.then(function (isOptedOut) {
184      settled = true;
185      initializeWith(isOptedOut);
186    });
187
188    // Never lose telemetry if the cross-domain iframe is blocked or slow.
189    setTimeout(function () {
190      if (!settled) {
191        initializeWith(readDataSharingOptOut() === true);
192      }
193    }, 2000);
194  }
195
196  if (document.readyState === "complete") {
197    resolveOptOutAndInitialize();
198  } else {
199    window.addEventListener("load", resolveOptOutAndInitialize);
200  }
201
202  /**
203   * Toggle dropdown menu visibility
204   * @param {HTMLElement} element The dropdown menu element
205   */
206  function toggleDropdown(element) {
207    const anchor = element.querySelector('a[data-toggle="dropdown"]');
208    const dropdown = element.querySelector("div");
209
210    if (!anchor || !dropdown) return;
211
212    const expanded = anchor.getAttribute("aria-expanded") === "true";
213    anchor.setAttribute("aria-expanded", !expanded);
214    dropdown.style.display = expanded ? "none" : "block";
215    element.classList.toggle("open", !expanded);
216  }
217
218  function addNavBarMobileEvent() {
219    const menuBtn = document.querySelector(".icon-menu");
220    const navMenu = document.querySelector("#nav-primary .menu");
221
222    if (!menuBtn || !navMenu) return;
223    menuBtn?.addEventListener("click", () => {
224      navMenu.classList.toggle("active");
225    });
226  }
227
228  function manageConsent() {
229    if (siteConsent.isConsentRequired) {
230      siteConsent.manageConsent();
231    }
232  }
233
234  function manageNonAdvertise() {
235    const userDocument = document.getElementsByTagName("body");
236    if (siteConsent.getConsentFor(WcpConsent.consentCategories.Advertising)) {
237      $(userDocument).removeClass("no-ad");
238    } else {
239      $(userDocument).addClass("no-ad");
240    }
241  }
242
243  function dropAnalyticsCookies() {
244    clearCookie("_ga", location.hostname, "/");
245    clearCookie("_gid", location.hostname, "/");
246    clearCookie("_gat", location.hostname, "/");
247  }
248
249  function clearCookie(name, domain, path) {
250    try {
251      function Get_Cookie(check_name) {
252        // first we'll split this cookie up into name/value pairs
253        // note: document.cookie only returns name=value, not the other components
254        const a_all_cookies = document.cookie.split(";");
255        let a_temp_cookie = "";
256        let cookie_name = "";
257        let cookie_value = "";
258        let b_cookie_found = false;
259
260        for (let i = 0; i < a_all_cookies.length; i++) {
261          // now we'll split apart each name=value pair
262          a_temp_cookie = a_all_cookies[i].split("=");
263
264          // and trim left/right whitespace while we're at it
265          cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, "");
266
267          // if the extracted name matches passed check_name
268          if (cookie_name == check_name) {
269            b_cookie_found = true;
270            // we need to handle case where cookie has no value but exists (no = sign, that is):
271            if (a_temp_cookie.length > 1) {
272              cookie_value = decodeURIComponent(
273                a_temp_cookie[1].replace(/^\s+|\s+$/g, ""),
274              );
275            }
276            // note that in cases where cookie is initialized but no value, null is returned
277            return cookie_value;
278          }
279          a_temp_cookie = null;
280          cookie_name = "";
281        }
282        if (!b_cookie_found) {
283          return null;
284        }
285      }
286
287      if (Get_Cookie(name)) {
288        domain = domain || location.hostname;
289        path = path || "/";
290        const today = new Date();
291        const expiryDate = new Date();
292        expiryDate.setDate(today.getDate() - 2);
293        document.cookie =
294          name +
295          "=; expires=" +
296          expiryDate +
297          "; domain=" +
298          domain +
299          "; path=" +
300          path;
301      }
302    } catch (err) {}
303  }
304
305  // Expose to HTML onclick handlers
306  window.manageConsent = manageConsent;
307})();

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.