vendor/symfony/web-profiler-bundle/Resources/views/Profiler/base_js.html.twig line 1

Open in your IDE?
  1. {# This file is partially duplicated in src/Symfony/Component/ErrorHandler/Resources/assets/js/exception.js.
  2.    If you make any change in this file, verify the same change is needed in the other file. #}
  3. <script{% if csp_script_nonce is defined and csp_script_nonce %} nonce="{{ csp_script_nonce }}"{% endif %}>/*<![CDATA[*/
  4.     {# Caution: the contents of this file are processed by Twig before loading
  5.                 them as JavaScript source code. Always use '/*' comments instead
  6.                 of '//' comments to avoid impossible-to-debug side-effects #}
  7. if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
  8.     Sfjs = (function() {
  9.         "use strict";
  10.         if ('classList' in document.documentElement) {
  11.             var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
  12.             var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
  13.             var addClass = function(el, cssClass) { el.classList.add(cssClass); };
  14.             var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
  15.         } else {
  16.             var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\b' + cssClass + '\\b')); };
  17.             var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\b' + cssClass + '\\b'), ' '); };
  18.             var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += " " + cssClass; } };
  19.             var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
  20.         }
  21.         var noop = function() {};
  22.         var profilerStorageKey = 'symfony/profiler/';
  23.         var addEventListener;
  24.         var el = document.createElement('div');
  25.         if (!('addEventListener' in el)) {
  26.             addEventListener = function (element, eventName, callback) {
  27.                 element.attachEvent('on' + eventName, callback);
  28.             };
  29.         } else {
  30.             addEventListener = function (element, eventName, callback) {
  31.                 element.addEventListener(eventName, callback, false);
  32.             };
  33.         }
  34.         if (navigator.clipboard) {
  35.             document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
  36.                 removeClass(element, 'hidden');
  37.                 element.addEventListener('click', function() {
  38.                     navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
  39.                 })
  40.             });
  41.         }
  42.         var request = function(url, onSuccess, onError, payload, options, tries) {
  43.             var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  44.             options = options || {};
  45.             options.retry = options.retry || false;
  46.             tries = tries || 1;
  47.             /* this delays for 125, 375, 625, 875, and 1000, ... */
  48.             var delay = tries < 5 ? (tries - 0.5) * 250 : 1000;
  49.             xhr.open(options.method || 'GET', url, true);
  50.             xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  51.             xhr.onreadystatechange = function(state) {
  52.                 if (4 !== xhr.readyState) {
  53.                     return null;
  54.                 }
  55.                 if (xhr.status == 404 && options.retry && !options.stop) {
  56.                     setTimeout(function() {
  57.                         if (options.stop) {
  58.                             return;
  59.                         }
  60.                         request(url, onSuccess, onError, payload, options, tries + 1);
  61.                     }, delay);
  62.                     return null;
  63.                 }
  64.                 if (200 === xhr.status) {
  65.                     (onSuccess || noop)(xhr);
  66.                 } else {
  67.                     (onError || noop)(xhr);
  68.                 }
  69.             };
  70.             if (options.onSend) {
  71.                 options.onSend(tries);
  72.             }
  73.             xhr.send(payload || '');
  74.         };
  75.         var getPreference = function(name) {
  76.             if (!window.localStorage) {
  77.                 return null;
  78.             }
  79.             return localStorage.getItem(profilerStorageKey + name);
  80.         };
  81.         var setPreference = function(name, value) {
  82.             if (!window.localStorage) {
  83.                 return null;
  84.             }
  85.             localStorage.setItem(profilerStorageKey + name, value);
  86.         };
  87.         var requestStack = [];
  88.         var extractHeaders = function(xhr, stackElement) {
  89.             /* Here we avoid to call xhr.getResponseHeader in order to */
  90.             /* prevent polluting the console with CORS security errors */
  91.             var allHeaders = xhr.getAllResponseHeaders();
  92.             var ret;
  93.             if (ret = allHeaders.match(/^x-debug-token:\s+(.*)$/im)) {
  94.                 stackElement.profile = ret[1];
  95.             }
  96.             if (ret = allHeaders.match(/^x-debug-token-link:\s+(.*)$/im)) {
  97.                 stackElement.profilerUrl = ret[1];
  98.             }
  99.             if (ret = allHeaders.match(/^Symfony-Debug-Toolbar-Replace:\s+(.*)$/im)) {
  100.                 stackElement.toolbarReplaceFinished = false;
  101.                 stackElement.toolbarReplace = '1' === ret[1];
  102.             }
  103.         };
  104.         var successStreak = 4;
  105.         var pendingRequests = 0;
  106.         var renderAjaxRequests = function() {
  107.             var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter');
  108.             if (!requestCounter) {
  109.                 return;
  110.             }
  111.             requestCounter.textContent = requestStack.length;
  112.             var infoSpan = document.querySelector(".sf-toolbar-ajax-info");
  113.             if (infoSpan) {
  114.                 infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : '');
  115.             }
  116.             var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');
  117.             if (requestStack.length) {
  118.                 ajaxToolbarPanel.style.display = 'block';
  119.             } else {
  120.                 ajaxToolbarPanel.style.display = 'none';
  121.             }
  122.             if (pendingRequests > 0) {
  123.                 addClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  124.             } else if (successStreak < 4) {
  125.                 addClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  126.                 removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  127.             } else {
  128.                 removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  129.                 removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  130.             }
  131.         };
  132.         var startAjaxRequest = function(index) {
  133.             var tbody = document.querySelector('.sf-toolbar-ajax-request-list');
  134.             if (!tbody) {
  135.                 return;
  136.             }
  137.             var nbOfAjaxRequest = tbody.rows.length;
  138.             if (nbOfAjaxRequest >= 100) {
  139.                 tbody.deleteRow(0);
  140.             }
  141.             var request = requestStack[index];
  142.             pendingRequests++;
  143.             var row = document.createElement('tr');
  144.             request.DOMNode = row;
  145.             var requestNumberCell = document.createElement('td');
  146.             requestNumberCell.textContent = index + 1;
  147.             row.appendChild(requestNumberCell);
  148.             var profilerCell = document.createElement('td');
  149.             profilerCell.textContent = 'n/a';
  150.             row.appendChild(profilerCell);
  151.             var methodCell = document.createElement('td');
  152.             methodCell.textContent = request.method;
  153.             row.appendChild(methodCell);
  154.             var typeCell = document.createElement('td');
  155.             typeCell.textContent = request.type;
  156.             row.appendChild(typeCell);
  157.             var statusCodeCell = document.createElement('td');
  158.             var statusCode = document.createElement('span');
  159.             statusCode.textContent = 'n/a';
  160.             statusCodeCell.appendChild(statusCode);
  161.             row.appendChild(statusCodeCell);
  162.             var pathCell = document.createElement('td');
  163.             pathCell.className = 'sf-ajax-request-url';
  164.             if ('GET' === request.method) {
  165.                 var pathLink = document.createElement('a');
  166.                 pathLink.setAttribute('href', request.url);
  167.                 pathLink.textContent = request.url;
  168.                 pathCell.appendChild(pathLink);
  169.             } else {
  170.                 pathCell.textContent = request.url;
  171.             }
  172.             pathCell.setAttribute('title', request.url);
  173.             row.appendChild(pathCell);
  174.             var durationCell = document.createElement('td');
  175.             durationCell.className = 'sf-ajax-request-duration';
  176.             durationCell.textContent = 'n/a';
  177.             row.appendChild(durationCell);
  178.             request.liveDurationHandle = setInterval(function() {
  179.                 durationCell.textContent = (new Date() - request.start) + ' ms';
  180.             }, 100);
  181.             row.className = 'sf-ajax-request sf-ajax-request-loading';
  182.             tbody.insertBefore(row, null);
  183.             var toolbarInfo = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  184.             toolbarInfo.scrollTop = toolbarInfo.scrollHeight;
  185.             renderAjaxRequests();
  186.         };
  187.         var finishAjaxRequest = function(index) {
  188.             var request = requestStack[index];
  189.             clearInterval(request.liveDurationHandle);
  190.             if (!request.DOMNode) {
  191.                 return;
  192.             }
  193.             if (request.toolbarReplace && !request.toolbarReplaceFinished && request.profile) {
  194.                 /* Flag as complete because finishAjaxRequest can be called multiple times. */
  195.                 request.toolbarReplaceFinished = true;
  196.                 /* Search up through the DOM to find the toolbar's container ID. */
  197.                 for (var elem = request.DOMNode; elem && elem !== document; elem = elem.parentNode) {
  198.                     if (elem.id.match(/^sfwdt/)) {
  199.                         Sfjs.loadToolbar(elem.id.replace(/^sfwdt/, ''), request.profile);
  200.                         break;
  201.                     }
  202.                 }
  203.             }
  204.             pendingRequests--;
  205.             var row = request.DOMNode;
  206.             /* Unpack the children from the row */
  207.             var profilerCell = row.children[1];
  208.             var methodCell = row.children[2];
  209.             var statusCodeCell = row.children[4];
  210.             var statusCodeElem = statusCodeCell.children[0];
  211.             var durationCell = row.children[6];
  212.             if (request.error) {
  213.                 row.className = 'sf-ajax-request sf-ajax-request-error';
  214.                 methodCell.className = 'sf-ajax-request-error';
  215.                 successStreak = 0;
  216.             } else {
  217.                 row.className = 'sf-ajax-request sf-ajax-request-ok';
  218.                 successStreak++;
  219.             }
  220.             if (request.statusCode) {
  221.                 if (request.statusCode < 300) {
  222.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status');
  223.                 } else if (request.statusCode < 400) {
  224.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
  225.                 } else {
  226.                     statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  227.                 }
  228.                 statusCodeElem.textContent = request.statusCode;
  229.             } else {
  230.                 statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  231.             }
  232.             if (request.duration) {
  233.                 durationCell.textContent = request.duration + ' ms';
  234.             }
  235.             if (request.profilerUrl) {
  236.                 profilerCell.textContent = '';
  237.                 var profilerLink = document.createElement('a');
  238.                 profilerLink.setAttribute('href', request.profilerUrl);
  239.                 profilerLink.textContent = request.profile;
  240.                 profilerCell.appendChild(profilerLink);
  241.             }
  242.             renderAjaxRequests();
  243.         };
  244.         {% if excluded_ajax_paths is defined %}
  245.             if (window.fetch && window.fetch.polyfill === undefined) {
  246.                 var oldFetch = window.fetch;
  247.                 window.fetch = function () {
  248.                     var promise = oldFetch.apply(this, arguments);
  249.                     var url = arguments[0];
  250.                     var params = arguments[1];
  251.                     var paramType = Object.prototype.toString.call(arguments[0]);
  252.                     if (paramType === '[object Request]') {
  253.                         url = arguments[0].url;
  254.                         params = {
  255.                             method: arguments[0].method,
  256.                             credentials: arguments[0].credentials,
  257.                             headers: arguments[0].headers,
  258.                             mode: arguments[0].mode,
  259.                             redirect: arguments[0].redirect
  260.                         };
  261.                     } else {
  262.                         url = String(url);
  263.                     }
  264.                     if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  265.                         var method = 'GET';
  266.                         if (params && params.method !== undefined) {
  267.                             method = params.method;
  268.                         }
  269.                         var stackElement = {
  270.                             error: false,
  271.                             url: url,
  272.                             method: method,
  273.                             type: 'fetch',
  274.                             start: new Date()
  275.                         };
  276.                         var idx = requestStack.push(stackElement) - 1;
  277.                         promise.then(function (r) {
  278.                             stackElement.duration = new Date() - stackElement.start;
  279.                             stackElement.error = r.status < 200 || r.status >= 400;
  280.                             stackElement.statusCode = r.status;
  281.                             stackElement.profile = r.headers.get('x-debug-token');
  282.                             stackElement.profilerUrl = r.headers.get('x-debug-token-link');
  283.                             stackElement.toolbarReplaceFinished = false;
  284.                             stackElement.toolbarReplace = '1' === r.headers.get('Symfony-Debug-Toolbar-Replace');
  285.                             finishAjaxRequest(idx);
  286.                         }, function (e){
  287.                             stackElement.error = true;
  288.                             finishAjaxRequest(idx);
  289.                         });
  290.                         startAjaxRequest(idx);
  291.                     }
  292.                     return promise;
  293.                 };
  294.             }
  295.             if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
  296.                 var proxied = XMLHttpRequest.prototype.open;
  297.                 XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
  298.                     var self = this;
  299.                     /* prevent logging AJAX calls to static and inline files, like templates */
  300.                     var path = url;
  301.                     if (url.substr(0, 1) === '/') {
  302.                         if (0 === url.indexOf('{{ request.basePath|e('js') }}')) {
  303.                             path = url.substr({{ request.basePath|length }});
  304.                         }
  305.                     }
  306.                     else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) {
  307.                         path = url.substr({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
  308.                     }
  309.                     if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  310.                         var stackElement = {
  311.                             error: false,
  312.                             url: url,
  313.                             method: method,
  314.                             type: 'xhr',
  315.                             start: new Date()
  316.                         };
  317.                         var idx = requestStack.push(stackElement) - 1;
  318.                         this.addEventListener('readystatechange', function() {
  319.                             if (self.readyState == 4) {
  320.                                 stackElement.duration = new Date() - stackElement.start;
  321.                                 stackElement.error = self.status < 200 || self.status >= 400;
  322.                                 stackElement.statusCode = self.status;
  323.                                 extractHeaders(self, stackElement);
  324.                                 finishAjaxRequest(idx);
  325.                             }
  326.                         }, false);
  327.                         startAjaxRequest(idx);
  328.                     }
  329.                     proxied.apply(this, Array.prototype.slice.call(arguments));
  330.                 };
  331.             }
  332.         {% endif %}
  333.         return {
  334.             hasClass: hasClass,
  335.             removeClass: removeClass,
  336.             addClass: addClass,
  337.             toggleClass: toggleClass,
  338.             getPreference: getPreference,
  339.             setPreference: setPreference,
  340.             addEventListener: addEventListener,
  341.             request: request,
  342.             renderAjaxRequests: renderAjaxRequests,
  343.             getSfwdt: function(token) {
  344.                 if (!this.sfwdt) {
  345.                     this.sfwdt = document.getElementById('sfwdt' + token);
  346.                 }
  347.                 return this.sfwdt;
  348.             },
  349.             load: function(selector, url, onSuccess, onError, options) {
  350.                 var el = document.getElementById(selector);
  351.                 if (el && el.getAttribute('data-sfurl') !== url) {
  352.                     request(
  353.                         url,
  354.                         function(xhr) {
  355.                             el.innerHTML = xhr.responseText;
  356.                             el.setAttribute('data-sfurl', url);
  357.                             removeClass(el, 'loading');
  358.                             var pending = pendingRequests;
  359.                             for (var i = 0; i < requestStack.length; i++) {
  360.                                 startAjaxRequest(i);
  361.                                 if (requestStack[i].duration) {
  362.                                     finishAjaxRequest(i);
  363.                                 }
  364.                             }
  365.                             /* Revert the pending state in case there was a start called without a finish above. */
  366.                             pendingRequests = pending;
  367.                             (onSuccess || noop)(xhr, el);
  368.                         },
  369.                         function(xhr) { (onError || noop)(xhr, el); },
  370.                         '',
  371.                         options
  372.                     );
  373.                 }
  374.                 return this;
  375.             },
  376.             showToolbar: function(token) {
  377.                 var sfwdt = this.getSfwdt(token);
  378.                 removeClass(sfwdt, 'sf-display-none');
  379.                 if (getPreference('toolbar/displayState') == 'none') {
  380.                     document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  381.                     document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  382.                     document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  383.                 } else {
  384.                     document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  385.                     document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  386.                     document.getElementById('sfMiniToolbar-' + token).style.display = 'none';
  387.                 }
  388.             },
  389.             hideToolbar: function(token) {
  390.                 var sfwdt = this.getSfwdt(token);
  391.                 addClass(sfwdt, 'sf-display-none');
  392.             },
  393.             initToolbar: function(token) {
  394.                 this.showToolbar(token);
  395.                 var hideButton = document.getElementById('sfToolbarHideButton-' + token);
  396.                 var hideButtonSvg = hideButton.querySelector('svg');
  397.                 hideButtonSvg.setAttribute('aria-hidden', 'true');
  398.                 hideButtonSvg.setAttribute('focusable', 'false');
  399.                 addEventListener(hideButton, 'click', function (event) {
  400.                     event.preventDefault();
  401.                     var p = this.parentNode;
  402.                     p.style.display = 'none';
  403.                     (p.previousElementSibling || p.previousSibling).style.display = 'none';
  404.                     document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  405.                     setPreference('toolbar/displayState', 'none');
  406.                 });
  407.                 var showButton = document.getElementById('sfToolbarMiniToggler-' + token);
  408.                 var showButtonSvg = showButton.querySelector('svg');
  409.                 showButtonSvg.setAttribute('aria-hidden', 'true');
  410.                 showButtonSvg.setAttribute('focusable', 'false');
  411.                 addEventListener(showButton, 'click', function (event) {
  412.                     event.preventDefault();
  413.                     var elem = this.parentNode;
  414.                     if (elem.style.display == 'none') {
  415.                         document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  416.                         document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  417.                         elem.style.display = 'block';
  418.                     } else {
  419.                         document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  420.                         document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  421.                         elem.style.display = 'none'
  422.                     }
  423.                     setPreference('toolbar/displayState', 'block');
  424.                 });
  425.             },
  426.             loadToolbar: function(token, newToken) {
  427.                 var that = this;
  428.                 var triesCounter = document.getElementById('sfLoadCounter-' + token);
  429.                 var options = {
  430.                     retry: true,
  431.                     onSend: function (count) {
  432.                         if (count === 3) {
  433.                             that.initToolbar(token);
  434.                         }
  435.                         if (triesCounter) {
  436.                             triesCounter.textContent = count;
  437.                         }
  438.                     },
  439.                 };
  440.                 var cancelButton = document.getElementById('sfLoadCancel-' + token);
  441.                 if (cancelButton) {
  442.                     addEventListener(cancelButton, 'click', function (event) {
  443.                         event.preventDefault();
  444.                         options.stop = true;
  445.                         that.hideToolbar(token);
  446.                     });
  447.                 }
  448.                 newToken = (newToken || token);
  449.                 this.load(
  450.                     'sfwdt' + token,
  451.                     '{{ url("_wdt", { "token": "xxxxxx" })|escape('js') }}'.replace(/xxxxxx/, newToken),
  452.                     function(xhr, el) {
  453.                         /* Do nothing in the edge case where the toolbar has already been replaced with a new one */
  454.                         if (!document.getElementById('sfToolbarMainContent-' + newToken)) {
  455.                             return;
  456.                         }
  457.                         /* Evaluate in global scope scripts embedded inside the toolbar */
  458.                         var i, scripts = [].slice.call(el.querySelectorAll('script'));
  459.                         for (i = 0; i < scripts.length; ++i) {
  460.                             eval.call({}, scripts[i].firstChild.nodeValue);
  461.                         }
  462.                         el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
  463.                         if (el.style.display == 'none') {
  464.                             return;
  465.                         }
  466.                         that.initToolbar(newToken);
  467.                         /* Handle toolbar-info position */
  468.                         var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
  469.                         for (i = 0; i < toolbarBlocks.length; ++i) {
  470.                             toolbarBlocks[i].onmouseover = function () {
  471.                                 var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
  472.                                 var pageWidth = document.body.clientWidth;
  473.                                 var elementWidth = toolbarInfo.offsetWidth;
  474.                                 var leftValue = (elementWidth + this.offsetLeft) - pageWidth;
  475.                                 var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth;
  476.                                 /* Reset right and left value, useful on window resize */
  477.                                 toolbarInfo.style.right = '';
  478.                                 toolbarInfo.style.left = '';
  479.                                 if (elementWidth > pageWidth) {
  480.                                     toolbarInfo.style.left = 0;
  481.                                 }
  482.                                 else if (leftValue > 0 && rightValue > 0) {
  483.                                     toolbarInfo.style.right = (rightValue * -1) + 'px';
  484.                                 } else if (leftValue < 0) {
  485.                                     toolbarInfo.style.left = 0;
  486.                                 } else {
  487.                                     toolbarInfo.style.right = '0px';
  488.                                 }
  489.                             };
  490.                         }
  491.                         renderAjaxRequests();
  492.                         addEventListener(document.querySelector('.sf-toolbar-ajax-clear'), 'click', function() {
  493.                             requestStack = [];
  494.                             renderAjaxRequests();
  495.                             successStreak = 4;
  496.                             document.querySelector('.sf-toolbar-ajax-request-list').innerHTML = '';
  497.                         });
  498.                         addEventListener(document.querySelector('.sf-toolbar-block-ajax'), 'mouseenter', function (event) {
  499.                             var elem = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  500.                             elem.scrollTop = elem.scrollHeight;
  501.                         });
  502.                         addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) {
  503.                             event.preventDefault();
  504.                             toggleClass(this.parentNode, 'hover');
  505.                         });
  506.                         var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info');
  507.                         if (null !== dumpInfo) {
  508.                             addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () {
  509.                                 dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px';
  510.                             });
  511.                             addEventListener(dumpInfo, 'mouseleave', function () {
  512.                                 dumpInfo.style.minHeight = '';
  513.                             });
  514.                         }
  515.                     },
  516.                     function(xhr) {
  517.                         if (xhr.status !== 0 && !options.stop) {
  518.                             var sfwdt = that.getSfwdt(token);
  519.                             sfwdt.innerHTML = '\
  520.                                 <div class="sf-toolbarreset">\
  521.                                     <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 0 26 28" xml:space="preserve"><path fill="#FFFFFF" d="M13 0C5.8 0 0 5.8 0 13c0 7.2 5.8 13 13 13c7.2 0 13-5.8 13-13C26 5.8 20.2 0 13 0z M20 7.5 c-0.6 0-1-0.3-1-0.9c0-0.2 0-0.4 0.2-0.6c0.1-0.3 0.2-0.3 0.2-0.4c0-0.3-0.5-0.4-0.7-0.4c-2 0.1-2.5 2.7-2.9 4.8l-0.2 1.1 c1.1 0.2 1.9 0 2.4-0.3c0.6-0.4-0.2-0.8-0.1-1.3C18 9.2 18.4 9 18.7 8.9c0.5 0 0.8 0.5 0.8 1c0 0.8-1.1 2-3.3 1.9 c-0.3 0-0.5 0-0.7-0.1L15 14.1c-0.4 1.7-0.9 4.1-2.6 6.2c-1.5 1.8-3.1 2.1-3.8 2.1c-1.3 0-2.1-0.6-2.2-1.6c0-0.9 0.8-1.4 1.3-1.4 c0.7 0 1.2 0.5 1.2 1.1c0 0.5-0.2 0.6-0.4 0.7c-0.1 0.1-0.3 0.2-0.3 0.4c0 0.1 0.1 0.3 0.4 0.3c0.5 0 0.9-0.3 1.2-0.5 c1.3-1 1.7-2.9 2.4-6.2l0.1-0.8c0.2-1.1 0.5-2.3 0.8-3.5c-0.9-0.7-1.4-1.5-2.6-1.8c-0.8-0.2-1.3 0-1.7 0.4C8.4 10 8.6 10.7 9 11.1 l0.7 0.7c0.8 0.9 1.3 1.7 1.1 2.7c-0.3 1.6-2.1 2.8-4.3 2.1c-1.9-0.6-2.2-1.9-2-2.7c0.2-0.6 0.7-0.8 1.2-0.6 c0.5 0.2 0.7 0.8 0.6 1.3c0 0.1 0 0.1-0.1 0.3C6 15 5.9 15.2 5.9 15.3c-0.1 0.4 0.4 0.7 0.8 0.8c0.8 0.3 1.7-0.2 1.9-0.9 c0.2-0.6-0.2-1.1-0.4-1.2l-0.8-0.9c-0.4-0.4-1.2-1.5-0.8-2.8c0.2-0.5 0.5-1 0.9-1.4c1-0.7 2-0.8 3-0.6c1.3 0.4 1.9 1.2 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>\
  522.                                     An error occurred while loading the web debug toolbar. <a href="{{ url("_profiler_home")|escape('js') }}' + newToken + '>Open the web profiler.</a>\
  523.                                 </div>\
  524.                             ';
  525.                             sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');
  526.                         }
  527.                     },
  528.                     options
  529.                 );
  530.                 return this;
  531.             },
  532.             toggle: function(selector, elOn, elOff) {
  533.                 var tmp = elOn.style.display,
  534.                     el = document.getElementById(selector);
  535.                 elOn.style.display = elOff.style.display;
  536.                 elOff.style.display = tmp;
  537.                 if (el) {
  538.                     el.style.display = 'none' === tmp ? 'none' : 'block';
  539.                 }
  540.                 return this;
  541.             },
  542.             createTabs: function() {
  543.                 var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
  544.                 /* create the tab navigation for each group of tabs */
  545.                 for (var i = 0; i < tabGroups.length; i++) {
  546.                     var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
  547.                     var tabNavigation = document.createElement('ul');
  548.                     tabNavigation.className = 'tab-navigation';
  549.                     var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
  550.                     for (var j = 0; j < tabs.length; j++) {
  551.                         var tabId = 'tab-' + i + '-' + j;
  552.                         var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
  553.                         var tabNavigationItem = document.createElement('li');
  554.                         tabNavigationItem.setAttribute('data-tab-id', tabId);
  555.                         if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
  556.                         if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
  557.                         tabNavigationItem.innerHTML = tabTitle;
  558.                         tabNavigation.appendChild(tabNavigationItem);
  559.                         var tabContent = tabs[j].querySelector('.tab-content');
  560.                         tabContent.parentElement.setAttribute('id', tabId);
  561.                     }
  562.                     tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
  563.                     addClass(document.querySelector('[data-tab-id="' + selectedTabId + '"]'), 'active');
  564.                 }
  565.                 /* display the active tab and add the 'click' event listeners */
  566.                 for (i = 0; i < tabGroups.length; i++) {
  567.                     tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation li');
  568.                     for (j = 0; j < tabNavigation.length; j++) {
  569.                         tabId = tabNavigation[j].getAttribute('data-tab-id');
  570.                         document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';
  571.                         if (hasClass(tabNavigation[j], 'active')) {
  572.                             document.getElementById(tabId).className = 'block';
  573.                         } else {
  574.                             document.getElementById(tabId).className = 'hidden';
  575.                         }
  576.                         tabNavigation[j].addEventListener('click', function(e) {
  577.                             var activeTab = e.target || e.srcElement;
  578.                             /* needed because when the tab contains HTML contents, user can click */
  579.                             /* on any of those elements instead of their parent '<li>' element */
  580.                             while (activeTab.tagName.toLowerCase() !== 'li') {
  581.                                 activeTab = activeTab.parentNode;
  582.                             }
  583.                             /* get the full list of tabs through the parent of the active tab element */
  584.                             var tabNavigation = activeTab.parentNode.children;
  585.                             for (var k = 0; k < tabNavigation.length; k++) {
  586.                                 var tabId = tabNavigation[k].getAttribute('data-tab-id');
  587.                                 document.getElementById(tabId).className = 'hidden';
  588.                                 removeClass(tabNavigation[k], 'active');
  589.                             }
  590.                             addClass(activeTab, 'active');
  591.                             var activeTabId = activeTab.getAttribute('data-tab-id');
  592.                             document.getElementById(activeTabId).className = 'block';
  593.                         });
  594.                     }
  595.                     tabGroups[i].setAttribute('data-processed', 'true');
  596.                 }
  597.             },
  598.             createToggles: function() {
  599.                 var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
  600.                 for (var i = 0; i < toggles.length; i++) {
  601.                     var elementSelector = toggles[i].getAttribute('data-toggle-selector');
  602.                     var element = document.querySelector(elementSelector);
  603.                     addClass(element, 'sf-toggle-content');
  604.                     if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
  605.                         addClass(toggles[i], 'sf-toggle-on');
  606.                         addClass(element, 'sf-toggle-visible');
  607.                     } else {
  608.                         addClass(toggles[i], 'sf-toggle-off');
  609.                         addClass(element, 'sf-toggle-hidden');
  610.                     }
  611.                     addEventListener(toggles[i], 'click', function(e) {
  612.                         e.preventDefault();
  613.                         if ('' !== window.getSelection().toString()) {
  614.                             /* Don't do anything on text selection */
  615.                             return;
  616.                         }
  617.                         var toggle = e.target || e.srcElement;
  618.                         /* needed because when the toggle contains HTML contents, user can click */
  619.                         /* on any of those elements instead of their parent '.sf-toggle' element */
  620.                         while (!hasClass(toggle, 'sf-toggle')) {
  621.                             toggle = toggle.parentNode;
  622.                         }
  623.                         var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
  624.                         toggleClass(toggle, 'sf-toggle-on');
  625.                         toggleClass(toggle, 'sf-toggle-off');
  626.                         toggleClass(element, 'sf-toggle-hidden');
  627.                         toggleClass(element, 'sf-toggle-visible');
  628.                         /* the toggle doesn't change its contents when clicking on it */
  629.                         if (!toggle.hasAttribute('data-toggle-alt-content')) {
  630.                             return;
  631.                         }
  632.                         if (!toggle.hasAttribute('data-toggle-original-content')) {
  633.                             toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
  634.                         }
  635.                         var currentContent = toggle.innerHTML;
  636.                         var originalContent = toggle.getAttribute('data-toggle-original-content');
  637.                         var altContent = toggle.getAttribute('data-toggle-alt-content');
  638.                         toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
  639.                     });
  640.                     /* Prevents from disallowing clicks on links inside toggles */
  641.                     var toggleLinks = toggles[i].querySelectorAll('a');
  642.                     for (var j = 0; j < toggleLinks.length; j++) {
  643.                         addEventListener(toggleLinks[j], 'click', function(e) {
  644.                             e.stopPropagation();
  645.                         });
  646.                     }
  647.                     /* Prevents from disallowing clicks on "copy to clipboard" elements inside toggles */
  648.                     var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]');
  649.                     for (var k = 0; k < copyToClipboardElements.length; k++) {
  650.                         addEventListener(copyToClipboardElements[k], 'click', function(e) {
  651.                             e.stopPropagation();
  652.                         });
  653.                     }
  654.                     toggles[i].setAttribute('data-processed', 'true');
  655.                 }
  656.             },
  657.             initializeLogsTable: function() {
  658.                 Sfjs.updateLogsTable();
  659.                 document.querySelectorAll('.log-filter input').forEach((input) => {
  660.                     input.addEventListener('change', () => { Sfjs.updateLogsTable(); });
  661.                 });
  662.                 document.querySelectorAll('.filter-select-all-or-none button').forEach((link) => {
  663.                     link.addEventListener('click', () => {
  664.                         const selectAll = link.classList.contains('select-all');
  665.                         link.closest('.log-filter-content').querySelectorAll('input').forEach((input) => {
  666.                             input.checked = selectAll;
  667.                         });
  668.                         Sfjs.updateLogsTable();
  669.                     });
  670.                 });
  671.                 document.body.addEventListener('click', (event) => {
  672.                     document.querySelectorAll('details.log-filter').forEach((filterElement) => {
  673.                         if (!filterElement.contains(event.target) && filterElement.open) {
  674.                             filterElement.open = false;
  675.                         }
  676.                     });
  677.                 });
  678.             },
  679.             updateLogsTable: function() {
  680.                 const selectedType = document.querySelector('#log-filter-type input:checked').value;
  681.                 const priorities = document.querySelectorAll('#log-filter-priority input');
  682.                 const allPriorities = Array.from(priorities).map((input) => input.value);
  683.                 const selectedPriorities = Array.from(priorities).filter((input) => input.checked).map((input) => input.value);
  684.                 const channels = document.querySelectorAll('#log-filter-channel input');
  685.                 const selectedChannels = Array.from(channels).filter((input) => input.checked).map((input) => input.value);
  686.                 const logs = document.querySelector('table.logs');
  687.                 if (null === logs) {
  688.                     return;
  689.                 }
  690.                 /* hide rows that don't match the current filters */
  691.                 let numVisibleRows = 0;
  692.                 logs.querySelectorAll('tbody tr').forEach((row) => {
  693.                     if ('all' !== selectedType && selectedType !== row.getAttribute('data-type')) {
  694.                         row.style.display = 'none';
  695.                         return;
  696.                     }
  697.                     const priority = row.getAttribute('data-priority');
  698.                     if (false === selectedPriorities.includes(priority) && true === allPriorities.includes(priority)) {
  699.                         row.style.display = 'none';
  700.                         return;
  701.                     }
  702.                     if ('' !== row.getAttribute('data-channel') && false === selectedChannels.includes(row.getAttribute('data-channel'))) {
  703.                         row.style.display = 'none';
  704.                         return;
  705.                     }
  706.                     row.style.display = 'table-row';
  707.                     numVisibleRows++;
  708.                 });
  709.                 document.querySelector('table.logs').style.display = 0 === numVisibleRows ? 'none' : 'table';
  710.                 document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none';
  711.                 /* update the selected totals of all filters */
  712.                 document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length;
  713.                 document.querySelector('#log-filter-channel .filter-active-num').innerText = (channels.length === selectedChannels.length) ? 'All' : selectedChannels.length;
  714.                 /* update the currently selected "log type" tab */
  715.                 document.querySelectorAll('#log-filter-type li').forEach((tab) => tab.classList.remove('active'));
  716.                 document.querySelector(`#log-filter-type input[value="${selectedType}"]`).parentElement.classList.add('active');
  717.             },
  718.         };
  719.     })();
  720.     Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
  721.         Sfjs.createTabs();
  722.         Sfjs.createToggles();
  723.     });
  724. }
  725. /*]]>*/</script>