1$(function () { 2 var impersonateCheckInterval = 5000; 3 var impersonateScript = $('[data-purpose="impersonate"]') 4 var baseUrl = $(impersonateScript).attr('data-root-url'); 5 var numRequests = 0; 6 7 if (baseUrl && baseUrl.slice(-1) !== '/') { 8 baseUrl = baseUrl + '/'; 9 } 10 11 var pollUrl = baseUrl + 'Impersonation/PollSession'; 12 var impersonationData = null; 13 14 var create = function () { 15 var html = 16 '<div id="impersonate-status" class="impersonate-panel">' + 17 '<span class="impersonate-title">Impersonating User</span>' + 18 '<p id="impersonate-user"></p>' + 19 '</div>'; 20 21 return $(html); 22 }; 23 24 var overlay = function () { 25 var html = 26 '<div id="impersonate-overlay-single" class="impersonate-overlay">' + 27 '<div class="impersonate-overlay-message-container">' + 28 '<p class="impersonate-overlay-message">' + 29 'This browser window has been deactivated because your session ' + 30 'has timed out or you have impersonated a different user.' + 31 '</p>' + 32 '</div>' + 33 '</div>'; 34 return $(html); 35 }; 36 37 // ERROR Setup 38 $(document).ajaxError(function (event, jqxhr, settings) { 39 if (settings.url === pollUrl) { 40 /* Give two attempts to find an impersonation context, if not, then stop polling. */ 41 if (numRequests < 2 && jqxhr.status === 404) { 42 // Check again in 250ms 43 setTimeout(checkImpersonationState, 250); 44 } 45 } 46 }); 47 48 var handleImpersonationResponse = function (data) { 49 if (typeof (data) === 'string') { 50 data = JSON.parse(data); 51 } 52 53 if (!impersonationData) { 54 impersonationData = data; 55 } 56 57 if (impersonationData.ImpersonatingUser !== data.ImpersonatingUser 58 || impersonationData.Hash !== data.Hash) { 59 60 var overlayElement = overlay(); 61 $('body').append(overlayElement); 62 $('#impersonate-overlay-single').show(); 63 64 // Return early if status check fails or indicates a different user being impersonated. 65 return; 66 } 67 68 var dataElement = $('#impersonate-status'); 69 if (dataElement.length === 0) { 70 var element = create(); 71 element.find('#impersonate-user').text(data.ImpersonatingUser); 72 $('body').append(element); 73 } 74 75 // This will only check again, if the status was polled and the impersonation status is still valid. 76 setTimeout(checkImpersonationState, impersonateCheckInterval); 77 }; 78 79 var checkImpersonationState = function () { 80 numRequests++; 81 $.get(pollUrl, handleImpersonationResponse); 82 }; 83 84 // This will execute the initial call in a separate "thread" that won't block execution of the rest of the page. 85 setTimeout(checkImpersonationState, 0); 86});
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.