1var outageJS = (typeof outageJS == "undefined" || !outageJS) ? {} : outageJS; 2 3outageJS.outages = []; 4 5outageJS.getClassName = function(inputString){ 6 let style = inputString; 7 if (style == "Grey with white text (Hex #323E48)"){ 8 return "outageGrey"; 9 } else if (style == "Red with white text (Hex #CC0000)") { 10 return"outageRed"; 11 } else if (style == "Black with white text (Hex #000000)") { 12 return"outageBlack"; 13 } else if (style == "Yellow with black text (Hex #F49F0C)") { 14 return"outageYellow"; 15 } else if (style == "Custom with white text") { 16 return"customWhite"; 17 } else if (style == "Custom with black text") { 18 return"customBlack" 19 } 20} 21 22outageJS.getHostUrlSegment = function (){ 23 return location.origin; 24} 25 26outageJS.menuPath = "/wcm/connect/co-op.crs%20content/outages?cmpntid=bbf0bed4-b816-4c6f-af76-7729481c8668&srv=cmpnt&source=library&WCM_Page.ResetAll=TRUE&CACHE=NONE&CONTENTCACHE=NONE&CONNECTORCACHE=NONE" 27 28outageJS.fetch = async function(){ 29 return HTTPHelper.callApi('GET', outageJS.menuPath, false, null, outageJS.getHostUrlSegment(), {}) 30 .then(resp => { 31 $(".outage-container-html").html(resp.data); 32 }); 33} 34 35outageJS.parseHtmlToJson = function(node){ 36 let obj = {}; 37 let arr = Array.from($(node).children()) 38 obj.id = "id-" + node.id; 39 obj.type = arr.find(i => i.classList.contains('type')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim(); 40 obj.title = window.btoa(arr.find(i => i.classList.contains('title')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim()); 41 obj.description = window.btoa(arr.find(i => i.classList.contains('description')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim()); 42 obj.dismiss = (arr.find(i => i.classList.contains('dismiss')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim() == "Yes"); 43 obj.className = outageJS.getClassName(arr.find(i => i.classList.contains('notification-colour')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim()); 44 obj.customColour = (obj.className.includes('custom')) ? arr.find(i => i.classList.contains('custom-colour')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim() : null; 45 obj.pages = arr.find(i => i.classList.contains('pages')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim().split(',') 46 obj.startDate = arr.find(i => i.classList.contains('start-date')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim(); 47 obj.endDate = arr.find(i => i.classList.contains('end-date')).innerHTML.replaceAll('\n', '').replaceAll('\t', '').trim(); 48 return obj; 49} 50 51outageJS.pageKey = [ 52 { 53 "title" : "homepage", 54 "pathname" : "/", 55 "key" : "Homepage - Web" 56 }, 57 { 58 "title" : "homepage", 59 "pathname" : "/home", 60 "key" : "Homepage - Web" 61 }, 62 { 63 "title" : "sitewide", 64 "pathname" : null, 65 "key" : "Sitewide - Web", 66 }, 67 { 68 "title" : "account", 69 "pathname" : "/my-account", 70 "key" : "Account page - Web", 71 }, 72 { 73 "title" : "become-a-member", 74 "pathname" : "/membership/become-a-member", 75 "key" : "Become a Member page - Web" 76 }, 77 { 78 "title" : "membership", 79 "pathname" : "/membership", 80 "key" : "Membership page - Web" 81 }, 82 { 83 "title" : "contact", 84 "pathname" : "/contact-us", 85 "key" : "Contact Us page - Web" 86 }, 87 { 88 "title" : "faq", 89 "pathname" : "/my-account/faq", 90 "key" : "FAQ page - Web" 91 }, 92 { 93 "title" : "locations", 94 "pathname" : "/locations", 95 "key" : "Locations page - Web" 96 } 97] 98 99outageJS.modalKey = [ 100 { 101 "title" : "sign-in-modal", 102 "modalId" : "emailModal", 103 "key" : "Sign In modal - Web" 104 } 105] 106 107//Function to check if there should be an outage displayed on the current page 108outageJS.isOutageOnPage = function(obj){ 109 let curr = false;
110 let match = []; 111 if (obj && obj.pages){ 112 for(let page of obj.pages){ 113 if (page == 'Sitewide - Web'){ 114 return true; 115 } 116 let tmp = outageJS.pageKey.filter(i => i.key == page); 117 for (let i of tmp){ 118 if (i){ 119 match.push(i.pathname); 120 } 121 } 122 } 123 if (location.pathname.includes('internal-authoring') || match.includes(location.pathname)){ 124 curr = true; 125 } 126 } 127 return curr; 128} 129 130//Function to check if there should be an outage displayed on any modal 131outageJS.isOutageOnModal = function(obj){ 132 let match = []; 133 if (obj && obj.pages){ 134 for(let page of obj.pages){ 135 let tmp = outageJS.modalKey.filter(i => i.key == page); 136 for (let i of tmp){ 137 if (i){ 138 match.push(i.modalId); 139 } 140 } 141 } 142 } 143 return match; 144} 145 146//Check for cookie 147outageJS.isDismissed = function(obj){ 148 return (FCLCookies.getCookie(window.btoa(obj.id)) && FCLCookies.getCookie(window.btoa(obj.id)).length > 0); 149} 150 151outageJS.dismiss = function(id){ 152 FCLCookies.setCookie(window.btoa(id), "hidden"); 153 $(".outage-container-notification").hide(); 154 $(".outage-container-notification").html(""); 155} 156 157//Function to build notification 158outageJS.buildNotification = function(obj, type){ 159 let template = (type == 'Minor') ? document.querySelector("#outage-minor-template").innerHTML : document.querySelector("#outage-major-template").innerHTML; 160 let compiled = Handlebars.compile(template); 161 let templateInfo = {}; 162 templateInfo.title = window.atob(obj.title); 163 templateInfo.description = (obj.description.length > 0) ? window.atob(obj.description) : null; 164 templateInfo.className = obj.className; 165 templateInfo.id = obj.id; 166 templateInfo.dismiss = obj.dismiss; 167 templateInfo.customColour = (obj.customColour) ? obj.customColour : null; 168 ( templateInfo.className == "outageGrey" || 169 templateInfo.className == "outageRed" || 170 templateInfo.className == "customWhite" || 171 templateInfo.className == "outageBlack" 172 ) ? templateInfo.whiteIcon = true : templateInfo.blackIcon = true; 173 174 let rendered = compiled(templateInfo); 175 $(".outage-container-notification").append(rendered).show(); 176} 177 178//Function to build modal notification 179outageJS.buildModalNotification = function(obj, modalId){ 180 let template = document.querySelector("#outage-modal-template").innerHTML; 181 let compiled = Handlebars.compile(template); 182 let templateInfo = {}; 183 templateInfo.title = window.atob(obj.title); 184 templateInfo.description = (obj.description.length > 0) ? window.atob(obj.description) : null; 185 186 let rendered = compiled(templateInfo); 187 $("#" + modalId + " .outage-modal-container-notification").append(rendered).show(); 188} 189 190//Function to initialize library 191outageJS.init = async function(){ 192 outageJS.fetch().then(() => { 193 Array.from($(".js-outageRaw").children()).forEach(item => { 194 let obj = outageJS.parseHtmlToJson(item) 195 outageJS.outages.push(obj); 196 }); 197 if (outageJS.isOutageOnPage(outageJS.outages[0])){ 198 //Check if dismissed 199 if (!outageJS.isDismissed(outageJS.outages[0])){ 200 //Confirm Date 201 if (new Date(outageJS.outages[0].endDate) > new Date() && new Date(outageJS.outages[0].startDate) < new Date()){ 202 //Identify if minor or major 203 if (outageJS.outages[0].type == 'Minor'){ 204 outageJS.buildNotification(outageJS.outages[0], 'Minor'); 205 } else if (outageJS.outages[0].type == 'Major') { 206 outageJS.buildNotification(outageJS.outages[0], 'Major'); 207 } 208 } 209 } 210 } 211 let modalsOutage = outageJS.isOutageOnModal(outageJS.outages[0]); 212 if (modalsOutage.length > 0){ 213 //Confirm Date 214 if (new Date(outageJS.outages[0].endDate) > new Date() && new Date(outageJS.outages[0].startDate) < new Date()){ 215 for (const modal of document.getElementsByClassName("modal")){ 216 if (modalsOutage.includes(modal.id)){ 217 outageJS.buildModalNotification(outageJS.outages[0], modal.id); 218 } 219 } 220 } 221 } 222 }) 223 224}
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.