1 2 import { hideLoader } from './loader.js'; 3 import { DataLayerHelper } from './dataLayerHelper.js' 4 5 export function removeAjaxError(container) { 6 const target = container ?? $("#ajax-status-container"); 7 target.addClass("d-none"); 8 } 9 10 export function handleAjaxError(xhr, request, options = {}) { 11 12 const opts = $.extend(true, { 13 14 scrollTo: true, 15 logError: true, 16 showError: true, 17 container: $("#ajax-status-container"), 18 useDataLayer: true 19 20 }, options); 21 22 const status = { 23 code: request.status, 24 path: xhr.url, 25 text: request.responseJSON?.title ?? request.statusText, 26 error: request.responseJSON ? request.responseJSON?.title ?? request.statusText : request.responseText 27 }; 28 29 if (opts.showError) { 30 31 let alertCode = [401, 500].includes(status.code) ? status.code : 500; 32 opts.container.removeClass("d-none"); 33 34 $(".alert", opts.container).addClass("d-none"); 35 $(`.alert-${alertCode}`, opts.container)?.removeClass("d-none"); 36 $(".alert-close", opts.container).removeClass("d-none").click(function (e) { 37 e.preventDefault(); 38 removeAjaxError(opts.container); 39 }) 40 } 41 42 if (opts.scrollTo) { 43 window.scrollTo(0, 0); 44 } 45 46 if (opts.logError) { 47 console.error(JSON.stringify(status)); 48 } 49 50 if (status.code === 401) { 51 $("[data-auth-logout-button]").removeClass("d-block").hide(); 52 }; 53 54 if (opts.useDataLayer) { 55 56 const helper = new DataLayerHelper(); 57 window.dataLayer = window.dataLayer || []; 58 59 helper.pushDataLayerEvent({ 60 event: "error_ajax", 61 status 62 }, true); 63 } 64 65 hideLoader(); 66 } 67
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.