1function createQueryArray(path,type, urlFormatted){ 2 3 if(urlFormatted == undefined) 4 urlFormatted = false; 5 6 var arr = path.split('/'); 7 var qo = {}; 8 switch (type) { 9 case 'flightresults': 10 if (path.indexOf('flight-results') === -1 && path.indexOf('rebookFlights') === -1) 11 return qo; 12 if (arr.indexOf('flight-results') == 2 || arr.indexOf('rebookFlights') == 2) { 13 arr[2] = arr[3]; 14 arr[3] = arr[4]; 15 arr[4] = arr[5]; 16 arr[5] = arr[6]; 17 arr[6] = arr[7]; 18 } 19 var fromto = arr[2].split('-'); 20 qo.from = fromto[0]; 21 qo.to = fromto[1]; 22 qo.start = arr[3]; 23 qo.end = arr[4]; 24 if (!urlFormatted) { 25 qo.start = qo.start.replace(/-/g,'/'); 26 qo.end = qo.end.replace(/-/g,'/'); 27 } 28 qo.adults = arr[5]; 29 qo.child = arr[6]; 30 qo.infant = arr[7]; 31 if (qo.infant.indexOf('?') > -1) { 32 qo.infant = qo.infant.substring(0,qo.infant.indexOf('?')); 33 } 34 //Select all elements that are after the ? 35 var queryString = window.location.search.substring(1); 36 var array = queryString.split('&'); 37 array.forEach(function(element) { 38 var keyVal = element.split('='); 39 qo[keyVal[0]] = keyVal[1]; 40 }); 41 break; 42 43 case 'packages': 44 if (path.indexOf('packages') === -1) 45 return qo; 46 qo.style = arr[2]; 47 qo.destination = arr[3]; 48 qo.days = arr[4]; 49 qo.date = arr[5]; 50 break; 51 52 case 'package': 53 if (path.indexOf('package') === -1) 54 return qo; 55 qo.pkgname = arr[2];//.replace(/-/g,' '); 56 break; 57 58 default: 59 break; 60 } 61 return qo; 62} 63 64function createQueryString(path,type,urlFormatted){ 65 66 if(urlFormatted == undefined) 67 urlFormatted = false; 68 69 var qs = "?"; 70 var qo = createQueryArray(path,type, urlFormatted); 71 for(x in qo) { 72 qs += x+"="+qo[x]+"&" 73 } 74 return qs.substring(0,qs.length-1); 75} 76 77function addOrdinalNumberSuffix(num) { 78 if([11,12,13].indexOf(num % 100) < 0) { 79 switch (num % 10) { 80 // Handle 1st, 2nd, 3rd 81 case 1: return num+'st'; 82 case 2: return num+'nd'; 83 case 3: return num+'rd'; 84 } 85 } 86 return num+'th'; 87} 88 89function copyObj(obj) { 90 return JSON.parse(JSON.stringify(obj)); 91} 92 93function getAncestor(obj,generations) { 94 var ret = obj; 95 for(var x = 0; x < generations; x++){ 96 ret = ret.parentElement; 97 } 98 return ret; 99} 100 101// ==== GLOBAL QUEUE FOR SESSION REQUESTS ==== 102window.__sessionQueue = window.__sessionQueue || []; 103window.__sessionActive = false; 104 105function storeInSession(container, action, element, rawData, callback, urlAddition) { 106 107 if(element == undefined) 108 element = false; 109 if(rawData == undefined) 110 rawData = false; 111 if(callback == undefined) 112 callback = false; 113 if (urlAddition == undefined) 114 urlAddition = ''; 115 116 // Prepare the request payload 117 var data = {}; 118 data['container'] = container; 119 120 if (element === false) { 121 data['data'] = rawData; 122 } else { 123 data['data'] = {}; 124 for (var i = 0; i < element.attributes.length; i++) { 125 var attribute = element.attributes[i]; 126 if (attribute.specified && attribute.name.substring(0,5) === 'data-') { 127 var key = attribute.name.substring(5); 128 if (key !== 'selected') 129 data['data'][key] = attribute.value; 130 } 131 } 132 } 133 134 data['action'] = action; 135 136 137 // ===== QUEUE WRAPPER ===== 138 function enqueue() { 139 window.__sessionQueue.push({ 140 data, 141 urlAddition, 142 callback 143 }); 144 processQueue(); 145 } 146 147 function processQueue() { 148 if (window.__sessionActive) return; 149 if (window.__sessionQueue.length === 0) return; 150 151 window.__sessionActive = true; 152 153 const job = window.__sessionQueue.shift(); 154 155 var request = new XMLHttpRequest(); 156 var url = '/controllers/general/sessionHandler.php' + job.urlAddition; 157 158 request.open("POST", url, true); 159 request.onreadystatechange = function() { 160 if (window.CsrfTokenManager) 161 window.CsrfTokenManager.updateCsrfTokenFromResponse(this); 162 163 if (this.readyState == 4) { 164 165 // fire the callback if provided 166 if (this.status == 200 && typeof job.callback === 'function') { 167 job.callback(this.responseText); 168 } 169 170 // allow next item to run 171 window.__sessionActive = false;
172 173 // process next 174 setTimeout(processQueue, 0); 175 } 176 }; 177 178 request.send(JSON.stringify(job.data)); 179 } 180 181 // Add session call to queue 182 enqueue(); 183} 184 185 186/* 187 * removeAllFromLocation - removes all nodes of this class, starting from the location 188*/ 189function cloneElement(className, location, remove, removeAllFromLocation) { 190 191 if(remove == undefined) 192 remove = true; 193 if(removeAllFromLocation == undefined) 194 removeAllFromLocation = false; 195 196 var cloned = (document.getElementsByClassName(className)[location]) !== undefined ? document.getElementsByClassName(className)[location].cloneNode(true,true,true) : false; 197 if (remove) 198 removeElement(className, location, removeAllFromLocation); 199 return cloned; 200} 201 202function removeElement(className, location, removeAllFromLocation) { 203 if ($('.'+className+':eq('+location+')') !== undefined) { 204 for (var i = location; document.getElementsByClassName(className)[location] !== undefined && document.getElementsByClassName(className)[location] !== null; i++) { 205 $('.'+className+':eq('+location+')').remove(); 206 if (!removeAllFromLocation) 207 break; 208 } 209 } 210} 211 212function validateName(name) { 213 214 var allowNonEnglishChar = $('#allowNonEnglishChar').val(); 215 var flag = false; 216 var nameRegex = /^[^\.|,|\-|@|\d\s][^0-9_!¡?÷?¿/\\+=@#$%Ë&*(){}|~<>;:[\]]{1,}$/ 217 //You can't touch this!!!!! ^^ 218 //Only if there is at least one letter then flag = true 219 if((allowNonEnglishChar == 1 && (/^(?=.*).{2,}$/.test(name)) || (allowNonEnglishChar == 0 && /[A-Za-z]/.test(name)))) { 220 flag = true; 221 } 222 //if there are char's that are not letters or quote or hyphen then flag = false 223 if(flag && ((allowNonEnglishChar == 1 && !(nameRegex.test(name))) ||(allowNonEnglishChar == 0 && !(/^[a-zA-Z ]*$/.test(name))))) { 224 flag = false; 225 } 226 227 return flag; 228} 229 230function validateAddress(data) { 231 var unicodeAddressRegex; 232 try { 233 unicodeAddressRegex = new RegExp("^[\\p{L}0-9\\s/\\\\\"'\\u05F3,.;\\-]*$", "u"); 234 } catch (e) { 235 unicodeAddressRegex = /^[a-zA-Z\u0590-\u05FF0-9\s\/\\"'\u05F3,.;\-\s]*$/; 236 } 237 return unicodeAddressRegex.test(data); 238} 239 240//When we need to send a manual error 241function logError (e){ 242 if (typeof(e) == 'object') { 243 rg4js('send', { 244 error: e, 245 tags: generateTagsCallback 246 }); 247 } 248} 249 250// CRS 2148 251function buildDynamicLi(name, logo, description, newpage) { 252 if (newpage == undefined) 253 newpage = false; 254 var newI = document.createElement("i") 255 newI.classList.add("fas", logo) 256 257 var newDiv = document.createElement("div") 258 259 var newLi = document.createElement("li") 260 if (newpage) { 261 newLi.classList.add("content__list") 262 newDiv.classList.add("content__list__icon") 263 newDiv.appendChild(newI) 264 265 var span2div = document.createElement("span") 266 span2div.classList.add("content__list__text") 267 span2div.innerHTML = description 268 269 var new2Div = document.createElement("div") 270 new2Div.classList.add("content__list_content") 271 new2Div.appendChild(span2div) 272 273 newLi.appendChild(newDiv) 274 newLi.appendChild(new2Div) 275 } 276 else { 277 newDiv.classList.add("svgHolder") 278 279 newLi.appendChild(newDiv).appendChild(newI) 280 } 281 282 name = name.trim().replace(/ /g, '_'); 283 newLi.classList.add(name) 284 285 return newLi 286} 287 288function buildDynamicLiTooltip(name, logo, description) { 289 var newITt = document.createElement("i") 290 newITt.classList.add("fas", logo) 291 newITt.style.color = "black" 292 293 var newInsideDivTt = document.createElement("div") 294 newInsideDivTt.classList.add("svgHolder") 295 newInsideDivTt.appendChild(newITt) 296 297 var newSpanTt = document.createElement("span") 298 newSpanTt.innerHTML = description 299 300 var newDivTt = document.createElement("div") 301 newDivTt.classList.add("imgHolder") 302 newDivTt.appendChild(newInsideDivTt) 303 304 var newLiTt = document.createElement("li"); 305 name = name.trim().replace(/ /g, '_'); 306 newLiTt.classList.add(name) 307 newLiTt.appendChild(newDivTt) 308 newLiTt.appendChild(newSpanTt) 309 310 return newLiTt 311} 312 313function manageTooltipDisplay() { 314 $('.flightChoice_tooltipHolder').hover(function() { 315 var flightChoice_tooltip = $(this).find('.flightChoice_tooltip'); 316 var flightChoice_tooltipText = $(flightChoice_tooltip).html().trim().toLowerCase(); 317 if (flightChoice_tooltipText.indexOf("direct") > -1 || flightChoice_tooltipText === "" || flightChoice_tooltipText.indexOf("non stop") > -1 ) { 318 $(this).addClass('dontAllowHover'); 319 } 320 }) 321}
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.