1 2(function () { 3 4 try { 5 6 var isPublicPage = (window.location.host.indexOf('www') === 0); 7 if (isPublicPage) { 8 9 var psMlsUrlParam = getUrlParameter('ps_mls'); 10 if (psMlsUrlParam !== null) { 11 setPsMlsToLocalStorage(); 12 } 13 14 var psMlsParam = getPsMlsFromLocalStorage(); 15 var autologinToken = findAutoLoginToken(); 16 17 var encodedDomain = encodeURIComponent(window.location.host); 18 var encodedPathInfo = encodeURIComponent(window.location.pathname); 19 20 var requestUrl = secureAdminContextUrl + '/api/v1/public-page-redirect?domain=' + encodedDomain + '&pathInfo=' + encodedPathInfo; 21 22 if (psMlsParam === true) { 23 requestUrl += '&ps_mls=true'; 24 } 25 26 if (autologinToken !== undefined) { 27 if (window.location.href.includes('?dal=true')) { 28 removeAutoLoginToken(); 29 } else { 30 requestUrl += ('&autologinToken=' + autologinToken); 31 } 32 } 33 34 var xhr = new XMLHttpRequest(); 35 36 window.xhr = xhr; 37 xhr.open('GET', requestUrl, true); 38 xhr.onload = function () { 39 40 if (xhr.status === 200 && xhr.response) { 41 42 var jsonResponse = JSON.parse(xhr.response); 43 if (jsonResponse.hasOwnProperty('redirectUrl')) { 44 var newLocation = jsonResponse.redirectUrl; 45 window.location.replace(newLocation); 46 return; 47 } 48 49 } else { 50 removeAutoLoginToken(); 51 } 52 53 removeBodyStyle(); 54 }; 55 56 xhr.onerror = function () { 57 removeBodyStyle(); 58 } 59 60 xhr.send(); 61 62 } else { 63 removeBodyStyle(); 64 } 65 66 } catch (e) { 67 removeBodyStyle(); 68 throw e; 69 } 70})() 71 72function getUrlParameter(paramName) { 73 74 paramName = paramName.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); 75 76 var paramRegex = new RegExp('[\\?&]' + paramName + '=([^&#]*)'); 77 var paramRegexResults = paramRegex.exec(location.search); 78 79 return (paramRegexResults === null ? null : decodeURIComponent(paramRegexResults[1].replace(/\+/g, ' '))); 80} 81 82function setPsMlsToLocalStorage() { 83 window.localStorage.setItem('psMls', new Date().getTime()); 84} 85 86function getPsMlsFromLocalStorage() { 87 88 var psMlsCreatedMillis = window.localStorage.getItem('psMls'); 89 90 if (!psMlsCreatedMillis) { 91 return false; 92 } 93 94 var nowMillis = new Date().getTime(); 95 if (nowMillis - psMlsCreatedMillis > 94672800000) { // 3 months 96 window.localStorage.removeItem('psMls'); 97 return false; 98 } else { 99 return true; 100 } 101} 102 103function findAutoLoginToken() { 104 return psCookie.get('providesupport-auto-login'); 105} 106 107function removeAutoLoginToken() { 108 var domainArray = window.location.host.split("."); 109 domainArray.shift(); 110 psCookie.remove('providesupport-auto-login', "." + domainArray.join("."), false); 111} 112 113function removeBodyStyle() { 114 document.getElementById('body-root').removeAttribute('style'); 115}
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.