{{ include('@WebProfiler/Profiler/toolbar.html.twig', { templates: { request: '@WebProfiler/Profiler/cancel.html.twig', }, profile: null, profiler_url: url('_profiler', {token: token}), profiler_markup_version: 3, }) }}
{# CAUTION: the contents of this file are processed by Twig before loading them as JavaScript source code. Always use '/*' comments instead of '//' comments to avoid impossible-to-debug side-effects #} /* 0) { addClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); } else if (successStreak < 4) { addClass(ajaxToolbarPanel, 'sf-toolbar-status-red'); removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); } else { removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading'); removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red'); } }; var startAjaxRequest = function(index) { var tbody = document.querySelector('.sf-toolbar-ajax-request-list'); if (!tbody) { return; } var nbOfAjaxRequest = tbody.rows.length; if (nbOfAjaxRequest >= 100) { tbody.deleteRow(0); } var request = requestStack[index]; pendingRequests++; var row = document.createElement('tr'); request.DOMNode = row; var requestNumberCell = document.createElement('td'); requestNumberCell.textContent = index + 1; row.appendChild(requestNumberCell); var profilerCell = document.createElement('td'); profilerCell.textContent = 'n/a'; row.appendChild(profilerCell); var methodCell = document.createElement('td'); methodCell.textContent = request.method; row.appendChild(methodCell); var typeCell = document.createElement('td'); typeCell.textContent = request.type; row.appendChild(typeCell); var statusCodeCell = document.createElement('td'); var statusCode = document.createElement('span'); statusCode.textContent = 'n/a'; statusCodeCell.appendChild(statusCode); row.appendChild(statusCodeCell); var pathCell = document.createElement('td'); pathCell.className = 'sf-ajax-request-url'; if ('GET' === request.method) { var pathLink = document.createElement('a'); pathLink.setAttribute('href', request.url); pathLink.textContent = request.url; pathCell.appendChild(pathLink); } else { pathCell.textContent = request.url; } pathCell.setAttribute('title', request.url); row.appendChild(pathCell); var durationCell = document.createElement('td'); durationCell.className = 'sf-ajax-request-duration'; durationCell.textContent = 'n/a'; row.appendChild(durationCell); request.liveDurationHandle = setInterval(function() { durationCell.textContent = (new Date() - request.start) + ' ms'; }, 100); row.className = 'sf-ajax-request sf-ajax-request-loading'; tbody.insertBefore(row, null); var toolbarInfo = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info'); toolbarInfo.scrollTop = toolbarInfo.scrollHeight; renderAjaxRequests(); }; var finishAjaxRequest = function(index) { var request = requestStack[index]; clearInterval(request.liveDurationHandle); if (!request.DOMNode) { return; } if (request.toolbarReplace && !request.toolbarReplaceFinished && request.profile) { /* Flag as complete because finishAjaxRequest can be called multiple times. */ request.toolbarReplaceFinished = true; /* Search up through the DOM to find the toolbar's container ID. */ for (var elem = request.DOMNode; elem && elem !== document; elem = elem.parentNode) { if (elem.id.match(/^sfwdt/)) { Sfjs.loadToolbar(elem.id.replace(/^sfwdt/, ''), request.profile); break; } } } if (pendingRequests > 0) { pendingRequests--; } var row = request.DOMNode; /* Unpack the children from the row */ var profilerCell = row.children[1]; var methodCell = row.children[2]; var statusCodeCell = row.children[4]; var statusCodeElem = statusCodeCell.children[0]; var durationCell = row.children[6]; if (request.error) { row.className = 'sf-ajax-request sf-ajax-request-error'; methodCell.className = 'sf-ajax-request-error'; successStreak = 0; } else { row.className = 'sf-ajax-request sf-ajax-request-ok'; successStreak++; } if (request.statusCode) { if (request.statusCode < 300) { statusCodeElem.setAttribute('class', 'sf-toolbar-status'); } else if (request.statusCode < 400) { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow'); } else { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red'); } statusCodeElem.textContent = request.statusCode; } else { statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red'); } if (request.duration) { durationCell.textContent = request.duration + ' ms'; } if (request.profilerUrl) { profilerCell.textContent = ''; var profilerLink = document.createElement('a'); profilerLink.setAttribute('href', request.profilerUrl); profilerLink.textContent = request.profile; profilerCell.appendChild(profilerLink); } renderAjaxRequests(); }; {% if excluded_ajax_paths is defined %} if (window.EventSource) { var oldEventSource = window.EventSource; function patchedEventSource(url, options) { var es = new oldEventSource(url, options); if (!url.toString().match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var stackElement = { error: false, url: url, method: 'GET', type: 'event-stream', start: new Date() }; var idx = requestStack.push(stackElement) - 1; startAjaxRequest(idx); addEventListener(es, 'error', function () { stackElement.error = true; finishAjaxRequest(idx); }); addEventListener(es, 'open', function () { stackElement.statusCode = 200; stackElement.toolbarReplaceFinished = false; stackElement.toolbarReplace = true; }); addEventListener(es, 'symfony:debug:started', function (event) { var items = event.data.split('\n'); stackElement.profile = items[0]; stackElement.profilerUrl = items[1]; }); addEventListener(es, 'symfony:debug:error', function (event) { stackElement.error = true; stackElement.statusCode = event.data; finishAjaxRequest(idx); }); addEventListener(es, 'symfony:debug:finished', function () { stackElement.duration = new Date() - stackElement.start; stackElement.toolbarReplaceFinished = false; stackElement.toolbarReplace = true; finishAjaxRequest(idx); }); } return es; }; Object.defineProperties(patchedEventSource, Object.getOwnPropertyDescriptors(oldEventSource)); window.EventSource = patchedEventSource; } if (window.fetch && window.fetch.polyfill === undefined) { var oldFetch = window.fetch; window.fetch = function () { var promise = oldFetch.apply(this, arguments); var url = arguments[0]; var params = arguments[1]; var paramType = Object.prototype.toString.call(arguments[0]); if (paramType === '[object Request]') { url = arguments[0].url; params = { method: arguments[0].method, credentials: arguments[0].credentials, headers: arguments[0].headers, mode: arguments[0].mode, redirect: arguments[0].redirect }; } else { url = String(url); } if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var method = 'GET'; if (params && params.method !== undefined) { method = params.method; } var stackElement = { error: false, url: url, method: method, type: 'fetch', start: new Date() }; var idx = requestStack.push(stackElement) - 1; promise.then(function (r) { stackElement.duration = new Date() - stackElement.start; stackElement.error = r.status < 200 || r.status >= 400; stackElement.statusCode = r.status; stackElement.profile = r.headers.get('x-debug-token'); stackElement.profilerUrl = r.headers.get('x-debug-token-link'); stackElement.toolbarReplaceFinished = false; stackElement.toolbarReplace = '1' === r.headers.get('Symfony-Debug-Toolbar-Replace'); finishAjaxRequest(idx); }, function (e){ stackElement.error = true; finishAjaxRequest(idx); }); startAjaxRequest(idx); } return promise; }; } if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) { var proxied = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url, async, user, pass) { var self = this; url = String(url); /* prevent logging AJAX calls to static and inline files, like templates */ var path = url; if (url.slice(0, 1) === '/') { if (0 === url.indexOf('{{ request.basePath|e('js') }}')) { path = url.slice({{ request.basePath|length }}); } } else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) { path = url.slice({{ (request.schemeAndHttpHost ~ request.basePath)|length }}); } if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) { var stackElement = { error: false, url: url, method: method, type: 'xhr', start: new Date() }; var idx = requestStack.push(stackElement) - 1; this.addEventListener('readystatechange', function() { if (self.readyState == 4) { stackElement.duration = new Date() - stackElement.start; stackElement.error = self.status < 200 || self.status >= 400; stackElement.statusCode = self.status; extractHeaders(self, stackElement); finishAjaxRequest(idx); } }, false); startAjaxRequest(idx); } proxied.apply(this, Array.prototype.slice.call(arguments)); }; } {% endif %} return { hasClass: hasClass, removeClass: removeClass, addClass: addClass, toggleClass: toggleClass, getPreference: getPreference, setPreference: setPreference, addEventListener: addEventListener, request: request, renderAjaxRequests: renderAjaxRequests, getSfwdt: function(token) { return document.getElementById('sfwdt' + token); }, load: function(selector, url, onSuccess, onError, options) { var el = document.getElementById(selector); if (el && el.getAttribute('data-sfurl') !== url) { request( url, function(xhr) { el.innerHTML = xhr.responseText; el.setAttribute('data-sfurl', url); removeClass(el, 'loading'); var pending = pendingRequests; for (var i = 0; i < requestStack.length; i++) { startAjaxRequest(i); if (requestStack[i].duration || requestStack[i].error) { finishAjaxRequest(i); } } /* Revert the pending state in case there was a start called without a finish above. */ pendingRequests = pending; (onSuccess || noop)(xhr, el); }, function(xhr) { (onError || noop)(xhr, el); }, '', options ); } return this; }, showToolbar: function(token) { var sfwdt = this.getSfwdt(token); var toggleButton = document.querySelector(`#sfToolbarToggleButton-${token}`); if ('closed' === getPreference('toolbar/displayState')) { addClass(sfwdt.parentNode, 'sf-toolbar-closed'); removeClass(sfwdt.parentNode, 'sf-toolbar-opened'); if (toggleButton) { toggleButton.setAttribute('aria-expanded', 'false'); } } else { addClass(sfwdt.parentNode, 'sf-toolbar-opened'); removeClass(sfwdt.parentNode, 'sf-toolbar-closed'); if (toggleButton) { toggleButton.setAttribute('aria-expanded', 'true'); } } }, hideToolbar: function(token) { var sfwdt = this.getSfwdt(token); var toggleButton = document.querySelector(`#sfToolbarToggleButton-${token}`); addClass(sfwdt.parentNode, 'sf-toolbar-closed'); removeClass(sfwdt.parentNode, 'sf-toolbar-opened'); if (toggleButton) { toggleButton.setAttribute('aria-expanded', 'false'); } }, initToolbar: function(token) { this.showToolbar(token); var toggleButton = document.querySelector(`#sfToolbarToggleButton-${token}`); addEventListener(toggleButton, 'click', function (event) { event.preventDefault(); const newState = 'closed' === getPreference('toolbar/displayState') ? 'opened' : 'closed'; setPreference('toolbar/displayState', newState); 'opened' === newState ? Sfjs.showToolbar(token) : Sfjs.hideToolbar(token); }); }, loadToolbar: function(token, newToken) { var that = this; var triesCounter = document.getElementById('sfLoadCounter-' + token); var options = { retry: true, onSend: function (count) { if (count === 3) { that.initToolbar(token); } if (triesCounter) { triesCounter.textContent = count; } }, }; var cancelButton = document.getElementById('sfLoadCancel-' + token); if (cancelButton) { addEventListener(cancelButton, 'click', function (event) { event.preventDefault(); options.stop = true; that.hideToolbar(token); }); } newToken = (newToken || token); this.load( 'sfwdt' + token, '{{ url('_wdt', {token: 'xxxxxx'})|escape('js') }}'.replace(/xxxxxx/, newToken), function(xhr, el) { var toolbarContent = document.getElementById('sfToolbarMainContent-' + newToken); /* Do nothing in the edge case where the toolbar has already been replaced with a new one */ if (!toolbarContent) { return; } /* Drop listeners attached during the previous load so they don't stack on AJAX replacements */ if (toolbarLoadAborter && typeof toolbarLoadAborter.abort === 'function') { toolbarLoadAborter.abort(); } toolbarLoadAborter = (typeof AbortController === 'function') ? new AbortController() : null; var toolbarLoadSignal = toolbarLoadAborter ? { signal: toolbarLoadAborter.signal } : false; /* Replace the ID, it has to match the new token */ toolbarContent.parentElement.id = 'sfwdt' + newToken; /* Evaluate in global scope scripts embedded inside the toolbar */ var i, scripts = [].slice.call(el.querySelectorAll('script')); for (i = 0; i < scripts.length; ++i) { if (scripts[i].firstChild) { eval.call({}, scripts[i].firstChild.nodeValue); } } el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none'; if (el.style.display == 'none') { return; } that.initToolbar(newToken); /* Handle toolbar-info position */ var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block')); var positionToolbarInfo = function () { var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0]; var pageWidth = document.body.clientWidth; var elementWidth = toolbarInfo.offsetWidth; var leftValue = (elementWidth + this.offsetLeft) - pageWidth; var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth; /* Reset right and left value, useful on window resize */ toolbarInfo.style.right = ''; toolbarInfo.style.left = ''; if (elementWidth > pageWidth) { toolbarInfo.style.left = 0; } else if (leftValue > 0 && rightValue > 0) { toolbarInfo.style.right = (rightValue * -1) + 'px'; } else if (leftValue < 0) { toolbarInfo.style.left = 0; } else { toolbarInfo.style.right = '0px'; } }; for (i = 0; i < toolbarBlocks.length; ++i) { addEventListener(toolbarBlocks[i], 'focusin', positionToolbarInfo, toolbarLoadSignal); toolbarBlocks[i].onmouseover = function () { /* Transfer focus away from any other toolbar block so that */ /* :focus-within and :hover are never active simultaneously */ var focused = document.activeElement; if (focused && !this.contains(focused) && focused.closest) { var focusedBlock = focused.closest('.sf-toolbar-block'); if (focusedBlock) { focused.blur(); } } positionToolbarInfo.call(this); }; } /* Roving tabindex for WAI-ARIA toolbar pattern */ var triggers = []; for (i = 0; i < toolbarBlocks.length; ++i) { var icon = toolbarBlocks[i].querySelector('.sf-toolbar-icon'); var trigger = (icon && icon.parentElement.tagName === 'A') ? icon.parentElement : icon; if (trigger) { trigger.setAttribute('tabindex', triggers.length === 0 ? '0' : '-1'); triggers.push(trigger); } /* Inject accessible label when no visible SVG provides one */ var label = toolbarBlocks[i].getAttribute('data-accessible-label'); if (label) { var svg = toolbarBlocks[i].querySelector('.sf-toolbar-icon svg'); var hasVisibleTitle = svg && svg.querySelector('title') && window.getComputedStyle(svg).display !== 'none' && svg.getAttribute('aria-hidden') !== 'true'; if (!hasVisibleTitle) { var span = document.createElement('span'); span.className = 'visually-hidden'; span.textContent = label; var parent = trigger || toolbarBlocks[i]; parent.insertBefore(span, parent.firstChild); } } } var toggleButton = document.getElementById('sfToolbarToggleButton-' + newToken); if (toggleButton) { toggleButton.setAttribute('tabindex', triggers.length === 0 ? '0' : '-1'); triggers.push(toggleButton); } var isTriggerVisible = function(trigger) { var block = trigger.closest('.sf-toolbar-block'); return block && window.getComputedStyle(block).display !== 'none'; }; var findVisibleIndex = function(fromIndex, direction) { var len = triggers.length; for (var step = 1; step < len; step++) { var candidate = (fromIndex + direction * step + len) % len; if (isTriggerVisible(triggers[candidate])) { return candidate; } } return fromIndex; }; var findFirstVisible = function() { for (var t = 0; t < triggers.length; t++) { if (isTriggerVisible(triggers[t])) return t; } return 0; }; var findLastVisible = function() { for (var t = triggers.length - 1; t >= 0; t--) { if (isTriggerVisible(triggers[t])) return t; } return triggers.length - 1; }; var setRovingFocus = function(newIndex) { for (var t = 0; t < triggers.length; t++) { triggers[t].setAttribute('tabindex', t === newIndex ? '0' : '-1'); } triggers[newIndex].focus(); }; for (i = 0; i < triggers.length; ++i) { (function(index) { addEventListener(triggers[index], 'keydown', function(event) { var handled = true; switch (event.key) { case 'ArrowRight': setRovingFocus(findVisibleIndex(index, 1)); break; case 'ArrowLeft': setRovingFocus(findVisibleIndex(index, -1)); break; case 'Home': setRovingFocus(findFirstVisible()); break; case 'End': setRovingFocus(findLastVisible()); break; case 'ArrowDown': var block = triggers[index].closest('.sf-toolbar-block'); if (block) { var info = block.querySelector('.sf-toolbar-info'); if (info) { info.focus(); } } break; default: handled = false; } if (handled) { event.preventDefault(); } }, toolbarLoadSignal); })(i); } /* Escape from popover returns focus to trigger */ var infoElements = el.querySelectorAll('.sf-toolbar-info[tabindex]'); for (i = 0; i < infoElements.length; ++i) { (function(infoEl) { addEventListener(infoEl, 'keydown', function(event) { if (event.key === 'Escape') { var block = infoEl.closest('.sf-toolbar-block'); if (block) { removeClass(block, 'hover'); var blockIcon = block.querySelector('.sf-toolbar-icon'); var trigger = (blockIcon && blockIcon.parentElement.tagName === 'A') ? blockIcon.parentElement : blockIcon; if (trigger) { trigger.focus(); } } event.preventDefault(); } }, toolbarLoadSignal); })(infoElements[i]); } renderAjaxRequests(); addEventListener(document.querySelector('.sf-toolbar-ajax-clear'), 'click', function() { requestStack = []; renderAjaxRequests(); successStreak = 4; document.querySelector('.sf-toolbar-ajax-request-list').innerHTML = ''; }); addEventListener(document.querySelector('.sf-toolbar-block-ajax'), 'mouseenter', function (event) { var elem = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info'); elem.scrollTop = elem.scrollHeight; }); addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) { event.preventDefault(); toggleClass(this.parentNode, 'hover'); }); var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info'); if (null !== dumpInfo) { addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () { dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px'; }); addEventListener(dumpInfo, 'mouseleave', function () { dumpInfo.style.minHeight = ''; }); } }, function(xhr) { if (xhr.status !== 0 && !options.stop) { var sfwdt = that.getSfwdt(token); sfwdt.innerHTML = '\ <div class="sf-toolbarreset notranslate">\ <div class="sf-toolbar-icon"><svg width="26" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 26 28" enable-background="new 0 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 2.8 1.9 c0.5-1.3 1.1-2.6 2-3.8c0.9-1 2-1.7 3.3-1.8C20 4.8 21 5.4 21 6.3C21 6.7 20.8 7.5 20 7.5z"/></svg></div>\ An error occurred while loading the web debug toolbar. <a href="{{ url('_profiler_home')|escape('js') }}' + newToken + '">Open the web profiler.</a>\ </div>\ '; sfwdt.parentElement.setAttribute('class', 'sf-toolbar sf-error-toolbar'); } }, options ); return this; }, toggle: function(selector, elOn, elOff) { var tmp = elOn.style.display, el = document.getElementById(selector); elOn.style.display = elOff.style.display; elOff.style.display = tmp; if (el) { el.style.display = 'none' === tmp ? 'none' : 'block'; } return this; }, }; })(); } Sfjs.loadToolbar('{{ token }}'); /*]]>*/</script> </div> <!-- END of Symfony Web Debug Toolbar -->