1(function () { 2 function isCsrUrl(url) { 3 if (!url) return false; 4 5 try { 6 const parsed = new URL(url, window.location.origin); 7 return parsed.pathname.toLowerCase().startsWith("/partnershipwithindustry/csr"); 8 } catch { 9 return false; 10 } 11 } 12 13 function getCsrContainer() { 14 return document.getElementById("csrContent"); 15 } 16 17 function ensureLoaderStyle() { 18 if (document.getElementById("csrAjaxStyle")) return; 19 20 const style = document.createElement("style"); 21 style.id = "csrAjaxStyle"; 22 style.innerHTML = ` 23 #csrContent.csr-loading { 24 position: relative; 25 min-height: 180px; 26 } 27 28 #csrContent.csr-loading::before { 29 content: ""; 30 position: absolute; 31 inset: 0; 32 background: rgba(255,255,255,0.75); 33 z-index: 10; 34 } 35 36 #csrContent.csr-loading::after { 37 content: ""; 38 position: absolute; 39 top: 50%; 40 left: 50%; 41 width: 42px; 42 height: 42px; 43 margin-top: -21px; 44 margin-left: -21px; 45 border: 4px solid #d9d9d9;
46 border-top: 4px solid #015198; 47 border-radius: 50%; 48 animation: csrSpin 0.8s linear infinite; 49 z-index: 11; 50 } 51 52 @keyframes csrSpin { 53 0% { transform: rotate(0deg); } 54 100% { transform: rotate(360deg); } 55 } 56 `; 57 document.head.appendChild(style); 58 } 59 60 function replacePageStyle(tempRoot) { 61 const incomingStyle = tempRoot.querySelector("#csrPageStyle"); 62 if (!incomingStyle) return; 63 64 const existingStyle = document.getElementById("csrPageStyle"); 65 if (existingStyle) { 66 existingStyle.innerHTML = incomingStyle.innerHTML; 67 } else { 68 document.head.appendChild(incomingStyle.cloneNode(true)); 69 } 70 } 71 72 function setActiveTabByUrl(url) { 73 const container = getCsrContainer(); 74 if (!container) return; 75 76 const currentPath = new URL(url, window.location.origin).pathname.toLowerCase(); 77 78 container.querySelectorAll(".tab-nav li").forEach(function (li) { 79 li.classList.remove("active"); 80 }); 81 82 container.querySelectorAll("a[href]").forEach(function (a) { 83 try { 84 const aPath = new URL(a.href, window.location.origin).pathname.toLowerCase(); 85 if (aPath === currentPath) { 86 const li = a.closest("li"); 87 if (li) li.classList.add("active"); 88 } 89 } catch { } 90 }); 91 92 const mobileSelect = container.querySelector("#MobileTabSelect"); 93 if (mobileSelect) { 94 Array.from(mobileSelect.options).forEach(function (opt) { 95 try { 96 const optPath = new URL(opt.value, window.location.origin).pathname.toLowerCase(); 97 opt.selected = optPath === currentPath; 98 } catch { } 99 }); 100 } 101 } 102 103 async function loadCsrSection(url, pushStateToBrowser) { 104 const container = getCsrContainer(); 105 if (!container) { 106 window.location.href = url; 107 return; 108 } 109 110 try { 111 ensureLoaderStyle(); 112 container.classList.add("csr-loading"); 113 114 const response = await fetch(url, { 115 method: "GET", 116 headers: { 117 "X-Requested-With": "XMLHttpRequest" 118 } 119 }); 120 121 if (!response.ok) { 122 window.location.href = url; 123 return; 124 } 125 126 const html = await response.text(); 127 const temp = document.createElement("div"); 128 temp.innerHTML = html; 129 130 const newContent = temp.querySelector("#csrContent"); 131 if (!newContent) { 132 window.location.href = url; 133 return; 134 } 135 136 replacePageStyle(temp); 137 container.innerHTML = newContent.innerHTML; 138 139 if (pushStateToBrowser) { 140 history.pushState({ csrUrl: url }, "", url); 141 } 142
143 setActiveTabByUrl(url); 144 window.scrollTo({ top: 0, behavior: "auto" }); 145 } catch { 146 window.location.href = url; 147 } finally { 148 container.classList.remove("csr-loading"); 149 } 150 } 151 152 document.addEventListener("click", function (e) { 153 const link = e.target.closest("a[href]"); 154 if (!link) return; 155 156 const href = link.getAttribute("href"); 157 if (!isCsrUrl(href)) return; 158 159 const container = getCsrContainer(); 160 if (!container) return; 161 162 e.preventDefault(); 163 e.stopPropagation(); 164 loadCsrSection(href, true); 165 }, true); 166 167 document.addEventListener("change", function (e) { 168 const select = e.target; 169 if (!select || select.tagName !== "SELECT") return; 170 if (select.id !== "MobileTabSelect") return; 171 172 const value = select.value; 173 if (!isCsrUrl(value)) return; 174 175 const container = getCsrContainer(); 176 if (!container) return; 177 178 e.preventDefault(); 179 e.stopPropagation(); 180 loadCsrSection(value, true); 181 }, true); 182 183 if (!window.__csrPopStateBound) { 184 window.__csrPopStateBound = true; 185 186 window.addEventListener("popstate", function (e) { 187 const url = e.state && e.state.csrUrl ? e.state.csrUrl : window.location.href; 188 if (isCsrUrl(url)) { 189 loadCsrSection(url, false); 190 } 191 }); 192 } 193 194 document.addEventListener("DOMContentLoaded", function () { 195 setActiveTabByUrl(window.location.href); 196 }); 197})();
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.