1 2var style = document.createElement('style'); 3style.innerHTML = '.dwmodal{overflow-y: scroll;}.dwmodal::-webkit-scrollbar {display: none;}.dwmodal .dwmodal-box{transform: translate(-50%, 10%); top: 0;}.dwmodal .dwmodal-disclaimer{font-size: 12px; line-height: 14px;}.dwmodal #form-3c2c6256-aafe-4ada-8e73-d7b1297f5c69{width: 100%}.dwmodal #form-3c2c6256-aafe-4ada-8e73-d7b1297f5c69 > div{padding-bottom: 0px;}.dwmodal-box,.dwmodal-box-sticky{max-width:380px;text-align:center}.dwmodal-box label{text-align:left; font-size:16px}.dwmodal{z-index:100000;position:fixed;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);opacity:0;visibility:hidden}.dwmodal-box{z-index:1000;position:absolute;top:40%;left:50%;transform:translate(-50%,-50%);background-color:#fff;padding:0 0 30px;width:85%;border-radius:10px}.dwmodal-box-sticky{z-index:100000;position:fixed;bottom:25px;left:25px;background-color:#769ca3;border-radius:3px;box-shadow:0 4px 8px 0 rgba(0,0,0,.3);transition:.3s;display:flex;align-items:center;padding:7px 15px 7px 20px;opacity:0;visibility:hidden}.dwmodal-box-sticky:hover{box-shadow:0 8px 16px 0 rgba(0,0,0,.6)}.dwmodal-image{max-height:393px;min-height:150px;width:100%;border-top-left-radius:10px;border-top-right-radius:10px;object-fit:cover;object-position:0% 100%}.dwmodal-close-button,.dwmodal-sticky-close-button{width:26px;height:26px;text-align:center;cursor:pointer;background:0 0;border:none;padding:0;display:flex;align-items:center;justify-content:center}.dwmodal-close-button{position:fixed;right:10px;top:10px;background:#000;border-radius:50px}.dwmodal-close-button:focus{outline:purple solid 2px}.dwmodal-sticky-close-button{position:relative}.dwmodal-sticky-link,.dwmodal-sticky-link:hover{text-decoration:none}.dwmodal-vertical-button-wrapper{width:100%;padding:0 10%}.dwmodal-vertical-button-wrapper .dwmodal-first-btn{margin-right:0;margin-bottom:7px}.dwmodal-disclaimer{margin:25px 15px 5px;text-align:center}.dwmodal-wrapper{display:flex;flex-wrap:nowrap;justify-content:center}.dwmodal-show-modal,.dwmodal-show-sticky-box{opacity:1;visibility:visible;transform:scale(1)}#dwmodal-label-span,.dwmodal-hide-sticky-box{display:none}@media only screen and (max-width:600px){.dwmodal-headline{font-size:2.25rem}.dwmodal-subheadline{font-size:1rem}.dwmodal-box-sticky{bottom:10px;left:10px}}'; 4document.head.appendChild(style); 5 6var json = {"popup":{"image":{"path":"/assets/images/popups/NEWpopup.jpg","site":"THAIEXPRESS-WWW","dynamic-metadata":[{"name":"CANONICAL"},{"name":"ADA-ID-AMP"},{"name":"REMOVE-FROM-MENU","value":"NO"}],"link":"site://THAIEXPRESS-WWW/assets/images/popups/NEWpopup.jpg","name":"NEWpopup.jpg","file-size":68424,"width":600,"type":"file","content":"","height":400},"imageAltText":"Order Thai Express Online","buttonGroup":{"button":[{"buttonTarget":"_self","buttonText":"Order Delivery","buttonAriaLabel":"Order Delivery","buttonLink":"https://order.thaiexpressfood.com/"},{"buttonTarget":"_self","buttonText":"Order Pick-Up","buttonAriaLabel":"Order Pick-Up","buttonLink":"https://order.thaiexpressfood.com/"}],"buttonLayout":"vertical"},"buttonGroupDisplay":{"value":"yes"},"singleDayReoccuringGroup":{"singleDayReoccurringDays":{"value":["monday","tuesday","sunday"]}},"pathsGroup":{"globalRegexPath":"","excludeContainsPath":"","includeContainsPath":""},"formDisplay":"","singleDayReoccurring":"","addcss":"","imageAriaLabel":"Order Thai Express Online","startEndDateGroup":{"endDate":"","startDate":""},"subHeadline":"Earn Thai Express Rewards points with every order","disclaimerDisplay":"","disclaimerGroup":{"disclaimerText":"","disclaimerExpandable":""},"headline":"Save Time & Skip the Line","infoBipID":""},"active":true}; 7var domain = 'https://www.thaiexpressfood.com/'; 8if (domain.endsWith("/")) { 9 domain = domain.slice(0, -1); 10} 11 12var currentPopUp = 0; 13//var kbKey = 0; 14var inTimeRange; 15var inDayRange; 16var popupScheduled = false; 17const now = new Date(); 18var activePopup = json['active']; 19 20if (activePopup == true) { 21 //convert single object to array 22 if (!Array.isArray(json['popup'])) { 23 json['popup'] = [json['popup']] 24 } 25
26 const kbKeys = Object.keys(json['popup']); 27 28 for (const kbKey of kbKeys) { 29 30 inTimeRange = false; 31 inDayRange = false; 32 var startDate = json['popup'][kbKey].startEndDateGroup.startDate; // leave as '' if no start date, string, ex. '05/22/2022'; 33 //console.log(startDate); 34 var endDate = json['popup'][kbKey].startEndDateGroup.endDate; // leave as '' if no end date, string, ex. '05/27/2022'; 35 var isSingleDayReoccuring = json['popup'][kbKey].singleDayReoccurring; 36 var daysForSingleDayReoccuring = json['popup'][kbKey].singleDayReoccuringGroup.singleDayReoccurringDays.value; 37 38 if (startDate && !endDate) { 39 const startDateDateTime = new Date(startDate); 40 if (now > startDateDateTime) { 41 inTimeRange = true; 42 } else { 43 inTimeRange = false; 44 } 45 } else if (startDate && endDate) { 46 const startDateDateTime = new Date(startDate); 47 const endDateDateTime = new Date(endDate + ' 23:59:00'); 48 if (now > startDateDateTime && now < endDateDateTime) { 49 inTimeRange = true; 50 } else { 51 inTimeRange = false; 52 } 53 } else if (!startDate && endDate) { 54 const endDateDateTime = new Date(endDate + ' 23:59:00'); 55 if (now < endDateDateTime) { 56 inTimeRange = true; 57 } else { 58 inTimeRange = false; 59 } 60 } else if (!startDate && !endDate) { 61 inTimeRange = true; 62 } 63 64 if (isSingleDayReoccuring && daysForSingleDayReoccuring) { 65 const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday']; 66 var singleDayReoccuringDayIndexes = []; 67 daysForSingleDayReoccuring.forEach((element) => { 68 singleDayReoccuringDayIndexes.push(days.indexOf(element.toLowerCase())); 69 }); 70 const dateDay = now.getDay(); 71 if (singleDayReoccuringDayIndexes.includes(dateDay)) { 72 inDayRange = true; 73 } else { 74 inDayRange = false; 75 } 76 } else { 77 inDayRange = true; 78 } 79 80 if (inTimeRange && inDayRange) { 81 currentPopUp = kbKey 82 popupScheduled = true; 83 } 84 } 85 86 function lineBreakTextArea(text, html = '') { 87 if (text.includes('
')){ 88 html = text.replace(/
/g, '<br><span>'); 89 html += '</span>' 90 } else { 91 html = text; 92 } 93 94 return html; 95 } 96 97 if (popupScheduled) { 98 var addCss = false; 99 addCss = json['popup'][currentPopUp].addcss; 100 if(addCss){ 101 var style = document.createElement('style'); 102 style.innerHTML = addCss; 103 document.head.appendChild(style); 104 } 105 106 // image 107 const imageUrl = domain + json['popup'][currentPopUp].image.path; 108 const imageAltTxt = json['popup'][currentPopUp].imageAltText; 109 const imageAriaLabel = json['popup'][currentPopUp].imageAriaLabel; 110 111 // headline 112 var headline = lineBreakTextArea(json['popup'][currentPopUp].headline); 113 // sub headline 114 const subheadline = lineBreakTextArea(json['popup'][currentPopUp].subHeadline); 115 116 // cta buttons 117 var buttonGroupDisplay = false; 118 if (json['popup'][currentPopUp].buttonGroupDisplay.value == "yes") { 119 buttonGroupDisplay = true; 120 } 121 var singleButton = false; 122 var singleBtnTxt = ''; 123 var singleBtnUrl = ''; 124 var doubleBtnOneTxt = ''; 125 var doubleBtnTwoTxt = ''; 126 var doubleBtnOneUrl = ''; 127 var doubleBtnTwoUrl = ''; 128 var isVerticalLayout = false; 129 var doubleVerticalBtnOneTxt = ''; 130 var doubleVerticalBtnTwoTxt = ''; 131 132 if(buttonGroupDisplay) { 133 if (json['popup'][currentPopUp].buttonGroup.button.length === undefined || json['popup'][currentPopUp].buttonGroup.button.length < 2) { 134 singleButton = true; 135 singleBtnTxt = json['popup'][currentPopUp].buttonGroup.button.buttonText; // string, ex. 'Order Now'; 136 var singleBtnUrl = json['popup'][currentPopUp].buttonGroup.button.buttonLink; // string, ex. 'https://order.example.com/'; 137 } else { 138 doubleBtnOneTxt = json['popup'][currentPopUp].buttonGroup.button[0].buttonText; // string, ex. 'Delivery'; 139 doubleBtnTwoTxt = json['popup'][currentPopUp].buttonGroup.button[1].buttonText; // string, ex. 'Pickup'; 140 doubleBtnOneUrl = json['popup'][currentPopUp].buttonGroup.button[0].buttonLink; // string, ex. 'https://order.example.com/'; 141 doubleBtnTwoUrl = json['popup'][currentPopUp].buttonGroup.button[1].buttonLink; // string, ex. 'https://order.example.com/'; 142 isVerticalLayout = false; // false if buttons are horizontal, boolean, ex. true (no quotes around true or false) 143 if (json['popup'][currentPopUp].buttonGroup.buttonLayout != 'horizontal') { 144 isVerticalLayout = true; 145 doubleVerticalBtnOneTxt = json['popup'][currentPopUp].buttonGroup.button[0].buttonText; // string, ex. 'Delivery'; 146 doubleVerticalBtnTwoTxt = json['popup'][currentPopUp].buttonGroup.button[1].buttonText; // string, ex. 'Pickup'; 147 } 148 } 149 } 150 151 //infobip form id 152 var formDisplay = false;
153 if (json['popup'][currentPopUp].formDisplay.value == "Yes") { 154 formDisplay = true; 155 } 156 const infoBipFormID = json['popup'][currentPopUp].infoBipID; 157 158 159 // disclaimer 160 var disclaimer = json['popup'][currentPopUp].disclaimerDisplay; 161 const disclaimerTxt = json['popup'][currentPopUp].disclaimerGroup.disclaimerText.replace('lt;','').replace('gt;','').replace('lt;','').replace('gt;',''); 162 const disclaimerExpandable = json['popup'][currentPopUp].disclaimerExpandable; 163 164 // page path rules 165 const excludeContainsPath = json['popup'][currentPopUp].pathsGroup.excludeContainsPath; // string, ex. '/menu/restaurant/'; 166 const includeContainsPath = json['popup'][currentPopUp].pathsGroup.includeContainsPath; // string, ex. '/menu/'; 167 const globalRegexPath = json['popup'][currentPopUp].pathsGroup.globalRegexPath; // string of global regex, ex. 'menu|locations' to include strings, or '^((?!(catering|legal|apply\=1)).)*$' to exclude strings; 168 169 // page path checks 170 const pageHref = window.location.href; 171 var passContainsPagePath = false; 172 var passContainsRegexPath = false; 173 174 if (!excludeContainsPath && !includeContainsPath) { 175 passContainsPagePath = true; 176 } else if (excludeContainsPath && !includeContainsPath) { 177 passContainsPagePath = !pageHref.includes(excludeContainsPath); 178 } else if (!excludeContainsPath && includeContainsPath) { 179 passContainsPagePath = pageHref.includes(includeContainsPath); 180 } else if (excludeContainsPath && includeContainsPath) { 181 passContainsPagePath = !pageHref.includes(excludeContainsPath) && pageHref.includes(includeContainsPath); 182 } 183 184 if (globalRegexPath) { 185 newGlobalRegexPath = new RegExp(globalRegexPath, 'g'); 186 passContainsRegexPath = newGlobalRegexPath.test(pageHref); 187 } else { 188 passContainsRegexPath = true; 189 } 190 191 var popupHTML = ''; 192 popupHTML += '<div aria-hidden="false" class="dwmodal dwmodal-show-modal"><div class="dwmodal-box" role="alertdialog" aria-modal="true" aria-labelledby="dwmodal-label-span dwmodal-dialog-label" aria-describedby="dwmodal-dialog-desc"><span id="dwmodal-label-span">something special from us</span><div><img src="' + imageUrl + '" alt="' + imageAltTxt + '" class="dwmodal-image"></img></div><div><h2>' + headline + '</h2><p class="subHeadline">' + subheadline + '</p><div class="dwmodal-wrapper">'; 193 if(buttonGroupDisplay) { 194 if (singleButton) { 195 popupHTML += '<a id="buttonOne" class="btn" aria-describedby="dwmodal-disclaimer-text" href="'+ singleBtnUrl + '">' + singleBtnTxt + '</a>'; 196 } else { 197 if (isVerticalLayout) { 198 popupHTML += '<div class="dwmodal-vertical-button-wrapper"><a id="buttonOne" class="btn" aria-describedby="dwmodal-disclaimer-text" href="' + doubleBtnOneUrl + '">' + doubleVerticalBtnOneTxt + '</a><a id="buttonTwo" class="btn" aria-describedby="dwmodal-disclaimer-text" href="' + doubleBtnTwoUrl + '">' + doubleVerticalBtnTwoTxt + '</a></div>'; 199 } else { 200 popupHTML += '<a id="buttonOne" class="btn" aria-describedby="dwmodal-disclaimer-text" href="' + doubleBtnOneUrl + '">' + doubleBtnOneTxt + '</a><a id="buttonTwo" class="btn" aria-describedby="dwmodal-disclaimer-text" href="' + doubleBtnTwoUrl + '">' + doubleBtnTwoTxt + '</a>'; 201 } 202 } 203 } 204 205 206 if (formDisplay) { 207 208 popupHTML += '<div id="form-' + infoBipFormID + '"></div>'; 209 var script = document.createElement('script'); 210 document.head.appendChild(script); 211 script.src = 'https://forms.infobip.com/forms/' + infoBipFormID + '.js'; 212 script.onload = function() { 213 let checkForm = setInterval(function() { 214 let form = document.querySelector('#form-' + infoBipFormID + ' form'); 215 if (form) { 216 clearInterval(checkForm); 217 var phoneNumberInput = document.querySelector('#form-' + infoBipFormID + ' input'); 218 219 /* add 1 on load */ 220 var str = phoneNumberInput.value; 221 var firstChar = str.charAt(0); 222 if(firstChar != '1'){ 223 phoneNumberInput.value = "1" + str; 224 } 225 226 /* add 1 on change if 1 is missing */ 227 phoneNumberInput.addEventListener('blur', function(e) { 228 var str = this.value; 229 var firstChar = str.charAt(0); 230 if(firstChar != '1'){ 231 this.value = "1" + str; 232 } 233 }) 234 } 235 }, 500) 236 } 237 } 238 popupHTML += '</div>'; 239 240 if (disclaimer) { 241 popupHTML += '<div class="dwmodal-disclaimer">'; 242 if (disclaimerExpandable) { 243 popupHTML += '<button class="dwmodal-disclaimer-button">View Offer Details</button>'; 244 } 245 popupHTML += '<span id="dwmodal-disclaimer-text">' + disclaimerTxt + '</span></div>' 246 } 247 248 popupHTML += '<button aria-label="close ' + headline + '" class="dwmodal-close-button"><svg alt="close" aria-label="close" xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewB
248ox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button></div></div></div></div>' 249 250 // html 251 //window.addEventListener("load",e=>{ 252 //var body = document.getElementById("popup"); 253 //body.innerHTML = popupHTML; 254 //var test = document.getElementsByClassName("kbPopup"); 255 //test.insertAdjacentHTML('afterbegin',popupHTML); 256 var body = document.getElementsByTagName("BODY")[0]; 257 body.insertAdjacentHTML('afterbegin',popupHTML); 258 259 //}); 260 261 // display logic 262 //window.addEventListener("load",e=>{ 263 var modal = document.querySelector(".dwmodal"); 264 var modalBox = document.querySelector(".dwmodal-box"); 265 var closeButton = document.querySelector(".dwmodal-close-button"); 266 267 //set focus on first button 268 window.addEventListener("load",e=>{ 269 var firstButton = document.getElementById("buttonOne"); 270 firstButton.focus({ focusVisible: true }); 271 }); 272 273 function toggleModal(sticky) { 274 modal.classList.toggle("dwmodal-show-modal"); 275 modal.ariaHidden == "true" ? modal.ariaHidden = "false" : modal.ariaHidden = "true"; 276 modalBox.focus(); 277 sessionStorage.setItem('modalFired', 'true'); 278 sticky; 279 } 280 function windowOnClick(event) { 281 if (event.target === modal) { 282 toggleModal(true); 283 } 284 } 285 286 closeButton.addEventListener("click", () => toggleModal(true)); 287 window.addEventListener("click", windowOnClick); 288 if (sessionStorage.getItem('modalFired') && inTimeRange && inDayRange && passContainsPagePath && passContainsRegexPath) { 289 toggleModal(false); 290 }; 291 292 // accessibility 293 const focusableElements = 'button, [href], a, [tabindex]:not([tabindex="-1"])'; 294 //window.addEventListener("load",e=>{ 295 const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; 296 const secondFocusableElement = modal.querySelectorAll(focusableElements)[1]; 297 const focusableContent = modal.querySelectorAll(focusableElements); 298 const lastFocusableElement = focusableContent[focusableContent.length - 1]; 299 //}); 300 301 document.addEventListener('keydown', function(e) { 302 let isTabPressed = e.key === 'Tab' || e.code === 'Tab'; 303 let isEscPressed = e.key === 'Escape' || e.code === 'Escape'; 304 if (isEscPressed) { 305 toggleModal(); 306 return; 307 } else if (!isTabPressed) { 308 return; 309 } 310 if (e.shiftKey) { 311 if (document.activeElement === firstFocusableElement) { 312 e.preventDefault(); 313 lastFocusableElement.focus(); 314 315 } 316 } else { 317 if (document.activeElement === lastFocusableElement) { 318 e.preventDefault(); 319 firstFocusableElement.focus(); 320 } 321 } 322 }); 323 //}); 324 } 325} 326 327
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.