var/cache/dev_h6fb3a85e4dfb80ee0331567510138d5f/twig/02/02d7ddd079bb49aab0c004e15d1665f8.php line 35

Open in your IDE?
  1. <?php
  2. use Twig\Environment;
  3. use function Shopware\Core\Framework\Adapter\Twig\sw_get_attribute;
  4. use function Shopware\Core\Framework\Adapter\Twig\sw_escape_filter;
  5. use Twig\Error\LoaderError;
  6. use Twig\Error\RuntimeError;
  7. use Twig\Extension\SandboxExtension;
  8. use Twig\Markup;
  9. use Twig\Sandbox\SecurityError;
  10. use Twig\Sandbox\SecurityNotAllowedTagError;
  11. use Twig\Sandbox\SecurityNotAllowedFilterError;
  12. use Twig\Sandbox\SecurityNotAllowedFunctionError;
  13. use Twig\Source;
  14. use Twig\Template;
  15. /* @WebProfiler/Profiler/base_js.html.twig */
  16. class __TwigTemplate_ba68d733383162599eb0947733451843 extends Template
  17. {
  18. private $source;
  19. private $macros = [];
  20. public function __construct(Environment $env)
  21. {
  22. parent::__construct($env);
  23. $this->source = $this->getSourceContext();
  24. $this->parent = false;
  25. $this->blocks = [
  26. ];
  27. }
  28. protected function doDisplay(array $context, array $blocks = [])
  29. {
  30. $macros = $this->macros;
  31. $__internal_5a27a8ba21ca79b61932376b2fa922d2 = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
  32. $__internal_5a27a8ba21ca79b61932376b2fa922d2->enter($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/base_js.html.twig"));
  33. $__internal_6f47bbe9983af81f1e7450e9a3e3768f = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
  34. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->enter($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "@WebProfiler/Profiler/base_js.html.twig"));
  35. // line 3
  36. echo "<script";
  37. if ((array_key_exists("csp_script_nonce", $context) && ($context["csp_script_nonce"] ?? null))) {
  38. echo " nonce=\"";
  39. echo sw_escape_filter($this->env, ($context["csp_script_nonce"] ?? null), "html", null, true);
  40. echo "\"";
  41. }
  42. echo ">/*<![CDATA[*/
  43. ";
  44. // line 7
  45. echo "
  46. if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
  47. Sfjs = (function() {
  48. \"use strict\";
  49. if ('classList' in document.documentElement) {
  50. var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
  51. var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
  52. var addClass = function(el, cssClass) { el.classList.add(cssClass); };
  53. var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
  54. } else {
  55. var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\\\b' + cssClass + '\\\\b')); };
  56. var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\\\b' + cssClass + '\\\\b'), ' '); };
  57. var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += \" \" + cssClass; } };
  58. var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
  59. }
  60. var noop = function() {};
  61. var profilerStorageKey = 'symfony/profiler/';
  62. var addEventListener;
  63. var el = document.createElement('div');
  64. if (!('addEventListener' in el)) {
  65. addEventListener = function (element, eventName, callback) {
  66. element.attachEvent('on' + eventName, callback);
  67. };
  68. } else {
  69. addEventListener = function (element, eventName, callback) {
  70. element.addEventListener(eventName, callback, false);
  71. };
  72. }
  73. if (navigator.clipboard) {
  74. document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
  75. removeClass(element, 'hidden');
  76. element.addEventListener('click', function() {
  77. navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
  78. })
  79. });
  80. }
  81. var request = function(url, onSuccess, onError, payload, options, tries) {
  82. var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  83. options = options || {};
  84. options.retry = options.retry || false;
  85. tries = tries || 1;
  86. /* this delays for 125, 375, 625, 875, and 1000, ... */
  87. var delay = tries < 5 ? (tries - 0.5) * 250 : 1000;
  88. xhr.open(options.method || 'GET', url, true);
  89. xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  90. xhr.onreadystatechange = function(state) {
  91. if (4 !== xhr.readyState) {
  92. return null;
  93. }
  94. if (xhr.status == 404 && options.retry && !options.stop) {
  95. setTimeout(function() {
  96. if (options.stop) {
  97. return;
  98. }
  99. request(url, onSuccess, onError, payload, options, tries + 1);
  100. }, delay);
  101. return null;
  102. }
  103. if (200 === xhr.status) {
  104. (onSuccess || noop)(xhr);
  105. } else {
  106. (onError || noop)(xhr);
  107. }
  108. };
  109. if (options.onSend) {
  110. options.onSend(tries);
  111. }
  112. xhr.send(payload || '');
  113. };
  114. var getPreference = function(name) {
  115. if (!window.localStorage) {
  116. return null;
  117. }
  118. return localStorage.getItem(profilerStorageKey + name);
  119. };
  120. var setPreference = function(name, value) {
  121. if (!window.localStorage) {
  122. return null;
  123. }
  124. localStorage.setItem(profilerStorageKey + name, value);
  125. };
  126. var requestStack = [];
  127. var extractHeaders = function(xhr, stackElement) {
  128. /* Here we avoid to call xhr.getResponseHeader in order to */
  129. /* prevent polluting the console with CORS security errors */
  130. var allHeaders = xhr.getAllResponseHeaders();
  131. var ret;
  132. if (ret = allHeaders.match(/^x-debug-token:\\s+(.*)\$/im)) {
  133. stackElement.profile = ret[1];
  134. }
  135. if (ret = allHeaders.match(/^x-debug-token-link:\\s+(.*)\$/im)) {
  136. stackElement.profilerUrl = ret[1];
  137. }
  138. if (ret = allHeaders.match(/^Symfony-Debug-Toolbar-Replace:\\s+(.*)\$/im)) {
  139. stackElement.toolbarReplaceFinished = false;
  140. stackElement.toolbarReplace = '1' === ret[1];
  141. }
  142. };
  143. var successStreak = 4;
  144. var pendingRequests = 0;
  145. var renderAjaxRequests = function() {
  146. var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter');
  147. if (!requestCounter) {
  148. return;
  149. }
  150. requestCounter.textContent = requestStack.length;
  151. var infoSpan = document.querySelector(\".sf-toolbar-ajax-info\");
  152. if (infoSpan) {
  153. infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : '');
  154. }
  155. var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');
  156. if (requestStack.length) {
  157. ajaxToolbarPanel.style.display = 'block';
  158. } else {
  159. ajaxToolbarPanel.style.display = 'none';
  160. }
  161. if (pendingRequests > 0) {
  162. addClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  163. } else if (successStreak < 4) {
  164. addClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  165. removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  166. } else {
  167. removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  168. removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  169. }
  170. };
  171. var startAjaxRequest = function(index) {
  172. var tbody = document.querySelector('.sf-toolbar-ajax-request-list');
  173. if (!tbody) {
  174. return;
  175. }
  176. var nbOfAjaxRequest = tbody.rows.length;
  177. if (nbOfAjaxRequest >= 100) {
  178. tbody.deleteRow(0);
  179. }
  180. var request = requestStack[index];
  181. pendingRequests++;
  182. var row = document.createElement('tr');
  183. request.DOMNode = row;
  184. var requestNumberCell = document.createElement('td');
  185. requestNumberCell.textContent = index + 1;
  186. row.appendChild(requestNumberCell);
  187. var profilerCell = document.createElement('td');
  188. profilerCell.textContent = 'n/a';
  189. row.appendChild(profilerCell);
  190. var methodCell = document.createElement('td');
  191. methodCell.textContent = request.method;
  192. row.appendChild(methodCell);
  193. var typeCell = document.createElement('td');
  194. typeCell.textContent = request.type;
  195. row.appendChild(typeCell);
  196. var statusCodeCell = document.createElement('td');
  197. var statusCode = document.createElement('span');
  198. statusCode.textContent = 'n/a';
  199. statusCodeCell.appendChild(statusCode);
  200. row.appendChild(statusCodeCell);
  201. var pathCell = document.createElement('td');
  202. pathCell.className = 'sf-ajax-request-url';
  203. if ('GET' === request.method) {
  204. var pathLink = document.createElement('a');
  205. pathLink.setAttribute('href', request.url);
  206. pathLink.textContent = request.url;
  207. pathCell.appendChild(pathLink);
  208. } else {
  209. pathCell.textContent = request.url;
  210. }
  211. pathCell.setAttribute('title', request.url);
  212. row.appendChild(pathCell);
  213. var durationCell = document.createElement('td');
  214. durationCell.className = 'sf-ajax-request-duration';
  215. durationCell.textContent = 'n/a';
  216. row.appendChild(durationCell);
  217. request.liveDurationHandle = setInterval(function() {
  218. durationCell.textContent = (new Date() - request.start) + ' ms';
  219. }, 100);
  220. row.className = 'sf-ajax-request sf-ajax-request-loading';
  221. tbody.insertBefore(row, null);
  222. var toolbarInfo = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  223. toolbarInfo.scrollTop = toolbarInfo.scrollHeight;
  224. renderAjaxRequests();
  225. };
  226. var finishAjaxRequest = function(index) {
  227. var request = requestStack[index];
  228. clearInterval(request.liveDurationHandle);
  229. if (!request.DOMNode) {
  230. return;
  231. }
  232. if (request.toolbarReplace && !request.toolbarReplaceFinished && request.profile) {
  233. /* Flag as complete because finishAjaxRequest can be called multiple times. */
  234. request.toolbarReplaceFinished = true;
  235. /* Search up through the DOM to find the toolbar's container ID. */
  236. for (var elem = request.DOMNode; elem && elem !== document; elem = elem.parentNode) {
  237. if (elem.id.match(/^sfwdt/)) {
  238. Sfjs.loadToolbar(elem.id.replace(/^sfwdt/, ''), request.profile);
  239. break;
  240. }
  241. }
  242. }
  243. pendingRequests--;
  244. var row = request.DOMNode;
  245. /* Unpack the children from the row */
  246. var profilerCell = row.children[1];
  247. var methodCell = row.children[2];
  248. var statusCodeCell = row.children[4];
  249. var statusCodeElem = statusCodeCell.children[0];
  250. var durationCell = row.children[6];
  251. if (request.error) {
  252. row.className = 'sf-ajax-request sf-ajax-request-error';
  253. methodCell.className = 'sf-ajax-request-error';
  254. successStreak = 0;
  255. } else {
  256. row.className = 'sf-ajax-request sf-ajax-request-ok';
  257. successStreak++;
  258. }
  259. if (request.statusCode) {
  260. if (request.statusCode < 300) {
  261. statusCodeElem.setAttribute('class', 'sf-toolbar-status');
  262. } else if (request.statusCode < 400) {
  263. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
  264. } else {
  265. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  266. }
  267. statusCodeElem.textContent = request.statusCode;
  268. } else {
  269. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  270. }
  271. if (request.duration) {
  272. durationCell.textContent = request.duration + ' ms';
  273. }
  274. if (request.profilerUrl) {
  275. profilerCell.textContent = '';
  276. var profilerLink = document.createElement('a');
  277. profilerLink.setAttribute('href', request.profilerUrl);
  278. profilerLink.textContent = request.profile;
  279. profilerCell.appendChild(profilerLink);
  280. }
  281. renderAjaxRequests();
  282. };
  283. ";
  284. // line 292
  285. if (array_key_exists("excluded_ajax_paths", $context)) {
  286. // line 293
  287. echo " if (window.fetch && window.fetch.polyfill === undefined) {
  288. var oldFetch = window.fetch;
  289. window.fetch = function () {
  290. var promise = oldFetch.apply(this, arguments);
  291. var url = arguments[0];
  292. var params = arguments[1];
  293. var paramType = Object.prototype.toString.call(arguments[0]);
  294. if (paramType === '[object Request]') {
  295. url = arguments[0].url;
  296. params = {
  297. method: arguments[0].method,
  298. credentials: arguments[0].credentials,
  299. headers: arguments[0].headers,
  300. mode: arguments[0].mode,
  301. redirect: arguments[0].redirect
  302. };
  303. } else {
  304. url = String(url);
  305. }
  306. if (!url.match(new RegExp(";
  307. // line 312
  308. echo $this->env->getFilter('json_encode')->getCallable()(($context["excluded_ajax_paths"] ?? null));
  309. echo "))) {
  310. var method = 'GET';
  311. if (params && params.method !== undefined) {
  312. method = params.method;
  313. }
  314. var stackElement = {
  315. error: false,
  316. url: url,
  317. method: method,
  318. type: 'fetch',
  319. start: new Date()
  320. };
  321. var idx = requestStack.push(stackElement) - 1;
  322. promise.then(function (r) {
  323. stackElement.duration = new Date() - stackElement.start;
  324. stackElement.error = r.status < 200 || r.status >= 400;
  325. stackElement.statusCode = r.status;
  326. stackElement.profile = r.headers.get('x-debug-token');
  327. stackElement.profilerUrl = r.headers.get('x-debug-token-link');
  328. stackElement.toolbarReplaceFinished = false;
  329. stackElement.toolbarReplace = '1' === r.headers.get('Symfony-Debug-Toolbar-Replace');
  330. finishAjaxRequest(idx);
  331. }, function (e){
  332. stackElement.error = true;
  333. finishAjaxRequest(idx);
  334. });
  335. startAjaxRequest(idx);
  336. }
  337. return promise;
  338. };
  339. }
  340. if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
  341. var proxied = XMLHttpRequest.prototype.open;
  342. XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
  343. var self = this;
  344. /* prevent logging AJAX calls to static and inline files, like templates */
  345. var path = url;
  346. if (url.slice(0, 1) === '/') {
  347. if (0 === url.indexOf('";
  348. // line 355
  349. echo sw_escape_filter($this->env, sw_escape_filter($this->env, sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "basePath", [], "any", false, false, false, 355), "js"), "html", null, true);
  350. echo "')) {
  351. path = url.slice(";
  352. // line 356
  353. echo sw_escape_filter($this->env, twig_length_filter($this->env, sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "basePath", [], "any", false, false, false, 356)), "html", null, true);
  354. echo ");
  355. }
  356. }
  357. else if (0 === url.indexOf('";
  358. // line 359
  359. echo sw_escape_filter($this->env, sw_escape_filter($this->env, (sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "schemeAndHttpHost", [], "any", false, false, false, 359) . sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "basePath", [], "any", false, false, false, 359)), "js"), "html", null, true);
  360. echo "')) {
  361. path = url.slice(";
  362. // line 360
  363. echo sw_escape_filter($this->env, twig_length_filter($this->env, (sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "schemeAndHttpHost", [], "any", false, false, false, 360) . sw_get_attribute($this->env, $this->source, ($context["request"] ?? null), "basePath", [], "any", false, false, false, 360))), "html", null, true);
  364. echo ");
  365. }
  366. if (!path.match(new RegExp(";
  367. // line 363
  368. echo $this->env->getFilter('json_encode')->getCallable()(($context["excluded_ajax_paths"] ?? null));
  369. echo "))) {
  370. var stackElement = {
  371. error: false,
  372. url: url,
  373. method: method,
  374. type: 'xhr',
  375. start: new Date()
  376. };
  377. var idx = requestStack.push(stackElement) - 1;
  378. this.addEventListener('readystatechange', function() {
  379. if (self.readyState == 4) {
  380. stackElement.duration = new Date() - stackElement.start;
  381. stackElement.error = self.status < 200 || self.status >= 400;
  382. stackElement.statusCode = self.status;
  383. extractHeaders(self, stackElement);
  384. finishAjaxRequest(idx);
  385. }
  386. }, false);
  387. startAjaxRequest(idx);
  388. }
  389. proxied.apply(this, Array.prototype.slice.call(arguments));
  390. };
  391. }
  392. ";
  393. }
  394. // line 392
  395. echo "
  396. return {
  397. hasClass: hasClass,
  398. removeClass: removeClass,
  399. addClass: addClass,
  400. toggleClass: toggleClass,
  401. getPreference: getPreference,
  402. setPreference: setPreference,
  403. addEventListener: addEventListener,
  404. request: request,
  405. renderAjaxRequests: renderAjaxRequests,
  406. getSfwdt: function(token) {
  407. if (!this.sfwdt) {
  408. this.sfwdt = document.getElementById('sfwdt' + token);
  409. }
  410. return this.sfwdt;
  411. },
  412. load: function(selector, url, onSuccess, onError, options) {
  413. var el = document.getElementById(selector);
  414. if (el && el.getAttribute('data-sfurl') !== url) {
  415. request(
  416. url,
  417. function(xhr) {
  418. el.innerHTML = xhr.responseText;
  419. el.setAttribute('data-sfurl', url);
  420. removeClass(el, 'loading');
  421. var pending = pendingRequests;
  422. for (var i = 0; i < requestStack.length; i++) {
  423. startAjaxRequest(i);
  424. if (requestStack[i].duration) {
  425. finishAjaxRequest(i);
  426. }
  427. }
  428. /* Revert the pending state in case there was a start called without a finish above. */
  429. pendingRequests = pending;
  430. (onSuccess || noop)(xhr, el);
  431. },
  432. function(xhr) { (onError || noop)(xhr, el); },
  433. '',
  434. options
  435. );
  436. }
  437. return this;
  438. },
  439. showToolbar: function(token) {
  440. var sfwdt = this.getSfwdt(token);
  441. removeClass(sfwdt, 'sf-display-none');
  442. if (getPreference('toolbar/displayState') == 'none') {
  443. document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  444. document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  445. document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  446. } else {
  447. document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  448. document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  449. document.getElementById('sfMiniToolbar-' + token).style.display = 'none';
  450. }
  451. },
  452. hideToolbar: function(token) {
  453. var sfwdt = this.getSfwdt(token);
  454. addClass(sfwdt, 'sf-display-none');
  455. },
  456. initToolbar: function(token) {
  457. this.showToolbar(token);
  458. var hideButton = document.getElementById('sfToolbarHideButton-' + token);
  459. var hideButtonSvg = hideButton.querySelector('svg');
  460. hideButtonSvg.setAttribute('aria-hidden', 'true');
  461. hideButtonSvg.setAttribute('focusable', 'false');
  462. addEventListener(hideButton, 'click', function (event) {
  463. event.preventDefault();
  464. var p = this.parentNode;
  465. p.style.display = 'none';
  466. (p.previousElementSibling || p.previousSibling).style.display = 'none';
  467. document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  468. setPreference('toolbar/displayState', 'none');
  469. });
  470. var showButton = document.getElementById('sfToolbarMiniToggler-' + token);
  471. var showButtonSvg = showButton.querySelector('svg');
  472. showButtonSvg.setAttribute('aria-hidden', 'true');
  473. showButtonSvg.setAttribute('focusable', 'false');
  474. addEventListener(showButton, 'click', function (event) {
  475. event.preventDefault();
  476. var elem = this.parentNode;
  477. if (elem.style.display == 'none') {
  478. document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  479. document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  480. elem.style.display = 'block';
  481. } else {
  482. document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  483. document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  484. elem.style.display = 'none'
  485. }
  486. setPreference('toolbar/displayState', 'block');
  487. });
  488. },
  489. loadToolbar: function(token, newToken) {
  490. var that = this;
  491. var triesCounter = document.getElementById('sfLoadCounter-' + token);
  492. var options = {
  493. retry: true,
  494. onSend: function (count) {
  495. if (count === 3) {
  496. that.initToolbar(token);
  497. }
  498. if (triesCounter) {
  499. triesCounter.textContent = count;
  500. }
  501. },
  502. };
  503. var cancelButton = document.getElementById('sfLoadCancel-' + token);
  504. if (cancelButton) {
  505. addEventListener(cancelButton, 'click', function (event) {
  506. event.preventDefault();
  507. options.stop = true;
  508. that.hideToolbar(token);
  509. });
  510. }
  511. newToken = (newToken || token);
  512. this.load(
  513. 'sfwdt' + token,
  514. '";
  515. // line 540
  516. echo sw_escape_filter($this->env, sw_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getUrl("_wdt", ["token" => "xxxxxx"]), "js"), "html", null, true);
  517. echo "'.replace(/xxxxxx/, newToken),
  518. function(xhr, el) {
  519. /* Do nothing in the edge case where the toolbar has already been replaced with a new one */
  520. if (!document.getElementById('sfToolbarMainContent-' + newToken)) {
  521. return;
  522. }
  523. /* Evaluate in global scope scripts embedded inside the toolbar */
  524. var i, scripts = [].slice.call(el.querySelectorAll('script'));
  525. for (i = 0; i < scripts.length; ++i) {
  526. if (scripts[i].firstChild) {
  527. eval.call({}, scripts[i].firstChild.nodeValue);
  528. }
  529. }
  530. el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
  531. if (el.style.display == 'none') {
  532. return;
  533. }
  534. that.initToolbar(newToken);
  535. /* Handle toolbar-info position */
  536. var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
  537. for (i = 0; i < toolbarBlocks.length; ++i) {
  538. toolbarBlocks[i].onmouseover = function () {
  539. var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
  540. var pageWidth = document.body.clientWidth;
  541. var elementWidth = toolbarInfo.offsetWidth;
  542. var leftValue = (elementWidth + this.offsetLeft) - pageWidth;
  543. var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth;
  544. /* Reset right and left value, useful on window resize */
  545. toolbarInfo.style.right = '';
  546. toolbarInfo.style.left = '';
  547. if (elementWidth > pageWidth) {
  548. toolbarInfo.style.left = 0;
  549. }
  550. else if (leftValue > 0 && rightValue > 0) {
  551. toolbarInfo.style.right = (rightValue * -1) + 'px';
  552. } else if (leftValue < 0) {
  553. toolbarInfo.style.left = 0;
  554. } else {
  555. toolbarInfo.style.right = '0px';
  556. }
  557. };
  558. }
  559. renderAjaxRequests();
  560. addEventListener(document.querySelector('.sf-toolbar-ajax-clear'), 'click', function() {
  561. requestStack = [];
  562. renderAjaxRequests();
  563. successStreak = 4;
  564. document.querySelector('.sf-toolbar-ajax-request-list').innerHTML = '';
  565. });
  566. addEventListener(document.querySelector('.sf-toolbar-block-ajax'), 'mouseenter', function (event) {
  567. var elem = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  568. elem.scrollTop = elem.scrollHeight;
  569. });
  570. addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) {
  571. event.preventDefault();
  572. toggleClass(this.parentNode, 'hover');
  573. });
  574. var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info');
  575. if (null !== dumpInfo) {
  576. addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () {
  577. dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px';
  578. });
  579. addEventListener(dumpInfo, 'mouseleave', function () {
  580. dumpInfo.style.minHeight = '';
  581. });
  582. }
  583. },
  584. function(xhr) {
  585. if (xhr.status !== 0 && !options.stop) {
  586. var sfwdt = that.getSfwdt(token);
  587. sfwdt.innerHTML = '\\
  588. <div class=\"sf-toolbarreset\">\\
  589. <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>\\
  590. An error occurred while loading the web debug toolbar. <a href=\"";
  591. // line 623
  592. echo sw_escape_filter($this->env, sw_escape_filter($this->env, $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getUrl("_profiler_home"), "js"), "html", null, true);
  593. echo "' + newToken + '\">Open the web profiler.</a>\\
  594. </div>\\
  595. ';
  596. sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');
  597. }
  598. },
  599. options
  600. );
  601. return this;
  602. },
  603. toggle: function(selector, elOn, elOff) {
  604. var tmp = elOn.style.display,
  605. el = document.getElementById(selector);
  606. elOn.style.display = elOff.style.display;
  607. elOff.style.display = tmp;
  608. if (el) {
  609. el.style.display = 'none' === tmp ? 'none' : 'block';
  610. }
  611. return this;
  612. },
  613. createTabs: function() {
  614. var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
  615. /* create the tab navigation for each group of tabs */
  616. for (var i = 0; i < tabGroups.length; i++) {
  617. var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
  618. var tabNavigation = document.createElement('ul');
  619. tabNavigation.className = 'tab-navigation';
  620. var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
  621. for (var j = 0; j < tabs.length; j++) {
  622. var tabId = 'tab-' + i + '-' + j;
  623. var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
  624. var tabNavigationItem = document.createElement('li');
  625. tabNavigationItem.setAttribute('data-tab-id', tabId);
  626. if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
  627. if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
  628. tabNavigationItem.innerHTML = tabTitle;
  629. tabNavigation.appendChild(tabNavigationItem);
  630. var tabContent = tabs[j].querySelector('.tab-content');
  631. tabContent.parentElement.setAttribute('id', tabId);
  632. }
  633. tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
  634. addClass(document.querySelector('[data-tab-id=\"' + selectedTabId + '\"]'), 'active');
  635. }
  636. /* display the active tab and add the 'click' event listeners */
  637. for (i = 0; i < tabGroups.length; i++) {
  638. tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation li');
  639. for (j = 0; j < tabNavigation.length; j++) {
  640. tabId = tabNavigation[j].getAttribute('data-tab-id');
  641. document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';
  642. if (hasClass(tabNavigation[j], 'active')) {
  643. document.getElementById(tabId).className = 'block';
  644. } else {
  645. document.getElementById(tabId).className = 'hidden';
  646. }
  647. tabNavigation[j].addEventListener('click', function(e) {
  648. var activeTab = e.target || e.srcElement;
  649. /* needed because when the tab contains HTML contents, user can click */
  650. /* on any of those elements instead of their parent '<li>' element */
  651. while (activeTab.tagName.toLowerCase() !== 'li') {
  652. activeTab = activeTab.parentNode;
  653. }
  654. /* get the full list of tabs through the parent of the active tab element */
  655. var tabNavigation = activeTab.parentNode.children;
  656. for (var k = 0; k < tabNavigation.length; k++) {
  657. var tabId = tabNavigation[k].getAttribute('data-tab-id');
  658. document.getElementById(tabId).className = 'hidden';
  659. removeClass(tabNavigation[k], 'active');
  660. }
  661. addClass(activeTab, 'active');
  662. var activeTabId = activeTab.getAttribute('data-tab-id');
  663. document.getElementById(activeTabId).className = 'block';
  664. });
  665. }
  666. tabGroups[i].setAttribute('data-processed', 'true');
  667. }
  668. },
  669. createToggles: function() {
  670. var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
  671. for (var i = 0; i < toggles.length; i++) {
  672. var elementSelector = toggles[i].getAttribute('data-toggle-selector');
  673. var element = document.querySelector(elementSelector);
  674. addClass(element, 'sf-toggle-content');
  675. if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
  676. addClass(toggles[i], 'sf-toggle-on');
  677. addClass(element, 'sf-toggle-visible');
  678. } else {
  679. addClass(toggles[i], 'sf-toggle-off');
  680. addClass(element, 'sf-toggle-hidden');
  681. }
  682. addEventListener(toggles[i], 'click', function(e) {
  683. e.preventDefault();
  684. if ('' !== window.getSelection().toString()) {
  685. /* Don't do anything on text selection */
  686. return;
  687. }
  688. var toggle = e.target || e.srcElement;
  689. /* needed because when the toggle contains HTML contents, user can click */
  690. /* on any of those elements instead of their parent '.sf-toggle' element */
  691. while (!hasClass(toggle, 'sf-toggle')) {
  692. toggle = toggle.parentNode;
  693. }
  694. var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
  695. toggleClass(toggle, 'sf-toggle-on');
  696. toggleClass(toggle, 'sf-toggle-off');
  697. toggleClass(element, 'sf-toggle-hidden');
  698. toggleClass(element, 'sf-toggle-visible');
  699. /* the toggle doesn't change its contents when clicking on it */
  700. if (!toggle.hasAttribute('data-toggle-alt-content')) {
  701. return;
  702. }
  703. if (!toggle.hasAttribute('data-toggle-original-content')) {
  704. toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
  705. }
  706. var currentContent = toggle.innerHTML;
  707. var originalContent = toggle.getAttribute('data-toggle-original-content');
  708. var altContent = toggle.getAttribute('data-toggle-alt-content');
  709. toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
  710. });
  711. /* Prevents from disallowing clicks on links inside toggles */
  712. var toggleLinks = toggles[i].querySelectorAll('a');
  713. for (var j = 0; j < toggleLinks.length; j++) {
  714. addEventListener(toggleLinks[j], 'click', function(e) {
  715. e.stopPropagation();
  716. });
  717. }
  718. /* Prevents from disallowing clicks on \"copy to clipboard\" elements inside toggles */
  719. var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]');
  720. for (var k = 0; k < copyToClipboardElements.length; k++) {
  721. addEventListener(copyToClipboardElements[k], 'click', function(e) {
  722. e.stopPropagation();
  723. });
  724. }
  725. toggles[i].setAttribute('data-processed', 'true');
  726. }
  727. },
  728. initializeLogsTable: function() {
  729. Sfjs.updateLogsTable();
  730. document.querySelectorAll('.log-filter input').forEach((input) => {
  731. input.addEventListener('change', () => { Sfjs.updateLogsTable(); });
  732. });
  733. document.querySelectorAll('.filter-select-all-or-none button').forEach((link) => {
  734. link.addEventListener('click', () => {
  735. const selectAll = link.classList.contains('select-all');
  736. link.closest('.log-filter-content').querySelectorAll('input').forEach((input) => {
  737. input.checked = selectAll;
  738. });
  739. Sfjs.updateLogsTable();
  740. });
  741. });
  742. document.body.addEventListener('click', (event) => {
  743. document.querySelectorAll('details.log-filter').forEach((filterElement) => {
  744. if (!filterElement.contains(event.target) && filterElement.open) {
  745. filterElement.open = false;
  746. }
  747. });
  748. });
  749. },
  750. updateLogsTable: function() {
  751. const selectedType = document.querySelector('#log-filter-type input:checked').value;
  752. const priorities = document.querySelectorAll('#log-filter-priority input');
  753. const allPriorities = Array.from(priorities).map((input) => input.value);
  754. const selectedPriorities = Array.from(priorities).filter((input) => input.checked).map((input) => input.value);
  755. const channels = document.querySelectorAll('#log-filter-channel input');
  756. const selectedChannels = Array.from(channels).filter((input) => input.checked).map((input) => input.value);
  757. const logs = document.querySelector('table.logs');
  758. if (null === logs) {
  759. return;
  760. }
  761. /* hide rows that don't match the current filters */
  762. let numVisibleRows = 0;
  763. logs.querySelectorAll('tbody tr').forEach((row) => {
  764. if ('all' !== selectedType && selectedType !== row.getAttribute('data-type')) {
  765. row.style.display = 'none';
  766. return;
  767. }
  768. const priority = row.getAttribute('data-priority');
  769. if (false === selectedPriorities.includes(priority) && true === allPriorities.includes(priority)) {
  770. row.style.display = 'none';
  771. return;
  772. }
  773. if ('' !== row.getAttribute('data-channel') && false === selectedChannels.includes(row.getAttribute('data-channel'))) {
  774. row.style.display = 'none';
  775. return;
  776. }
  777. row.style.display = 'table-row';
  778. numVisibleRows++;
  779. });
  780. document.querySelector('table.logs').style.display = 0 === numVisibleRows ? 'none' : 'table';
  781. document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none';
  782. /* update the selected totals of all filters */
  783. document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length;
  784. document.querySelector('#log-filter-channel .filter-active-num').innerText = (channels.length === selectedChannels.length) ? 'All' : selectedChannels.length;
  785. /* update the currently selected \"log type\" tab */
  786. document.querySelectorAll('#log-filter-type li').forEach((tab) => tab.classList.remove('active'));
  787. document.querySelector(`#log-filter-type input[value=\"\${selectedType}\"]`).parentElement.classList.add('active');
  788. },
  789. };
  790. })();
  791. Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
  792. Sfjs.createTabs();
  793. Sfjs.createToggles();
  794. });
  795. }
  796. /*]]>*/</script>
  797. ";
  798. $__internal_5a27a8ba21ca79b61932376b2fa922d2->leave($__internal_5a27a8ba21ca79b61932376b2fa922d2_prof);
  799. $__internal_6f47bbe9983af81f1e7450e9a3e3768f->leave($__internal_6f47bbe9983af81f1e7450e9a3e3768f_prof);
  800. }
  801. public function getTemplateName()
  802. {
  803. return "@WebProfiler/Profiler/base_js.html.twig";
  804. }
  805. public function isTraitable()
  806. {
  807. return false;
  808. }
  809. public function getDebugInfo()
  810. {
  811. return array ( 696 => 623, 610 => 540, 460 => 392, 428 => 363, 422 => 360, 418 => 359, 412 => 356, 408 => 355, 362 => 312, 341 => 293, 339 => 292, 52 => 7, 43 => 3,);
  812. }
  813. public function getSourceContext()
  814. {
  815. return new Source("{# This file is partially duplicated in src/Symfony/Component/ErrorHandler/Resources/assets/js/exception.js.
  816. If you make any change in this file, verify the same change is needed in the other file. #}
  817. <script{% if csp_script_nonce is defined and csp_script_nonce %} nonce=\"{{ csp_script_nonce }}\"{% endif %}>/*<![CDATA[*/
  818. {# Caution: the contents of this file are processed by Twig before loading
  819. them as JavaScript source code. Always use '/*' comments instead
  820. of '//' comments to avoid impossible-to-debug side-effects #}
  821. if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
  822. Sfjs = (function() {
  823. \"use strict\";
  824. if ('classList' in document.documentElement) {
  825. var hasClass = function (el, cssClass) { return el.classList.contains(cssClass); };
  826. var removeClass = function(el, cssClass) { el.classList.remove(cssClass); };
  827. var addClass = function(el, cssClass) { el.classList.add(cssClass); };
  828. var toggleClass = function(el, cssClass) { el.classList.toggle(cssClass); };
  829. } else {
  830. var hasClass = function (el, cssClass) { return el.className.match(new RegExp('\\\\b' + cssClass + '\\\\b')); };
  831. var removeClass = function(el, cssClass) { el.className = el.className.replace(new RegExp('\\\\b' + cssClass + '\\\\b'), ' '); };
  832. var addClass = function(el, cssClass) { if (!hasClass(el, cssClass)) { el.className += \" \" + cssClass; } };
  833. var toggleClass = function(el, cssClass) { hasClass(el, cssClass) ? removeClass(el, cssClass) : addClass(el, cssClass); };
  834. }
  835. var noop = function() {};
  836. var profilerStorageKey = 'symfony/profiler/';
  837. var addEventListener;
  838. var el = document.createElement('div');
  839. if (!('addEventListener' in el)) {
  840. addEventListener = function (element, eventName, callback) {
  841. element.attachEvent('on' + eventName, callback);
  842. };
  843. } else {
  844. addEventListener = function (element, eventName, callback) {
  845. element.addEventListener(eventName, callback, false);
  846. };
  847. }
  848. if (navigator.clipboard) {
  849. document.querySelectorAll('[data-clipboard-text]').forEach(function(element) {
  850. removeClass(element, 'hidden');
  851. element.addEventListener('click', function() {
  852. navigator.clipboard.writeText(element.getAttribute('data-clipboard-text'));
  853. })
  854. });
  855. }
  856. var request = function(url, onSuccess, onError, payload, options, tries) {
  857. var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
  858. options = options || {};
  859. options.retry = options.retry || false;
  860. tries = tries || 1;
  861. /* this delays for 125, 375, 625, 875, and 1000, ... */
  862. var delay = tries < 5 ? (tries - 0.5) * 250 : 1000;
  863. xhr.open(options.method || 'GET', url, true);
  864. xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
  865. xhr.onreadystatechange = function(state) {
  866. if (4 !== xhr.readyState) {
  867. return null;
  868. }
  869. if (xhr.status == 404 && options.retry && !options.stop) {
  870. setTimeout(function() {
  871. if (options.stop) {
  872. return;
  873. }
  874. request(url, onSuccess, onError, payload, options, tries + 1);
  875. }, delay);
  876. return null;
  877. }
  878. if (200 === xhr.status) {
  879. (onSuccess || noop)(xhr);
  880. } else {
  881. (onError || noop)(xhr);
  882. }
  883. };
  884. if (options.onSend) {
  885. options.onSend(tries);
  886. }
  887. xhr.send(payload || '');
  888. };
  889. var getPreference = function(name) {
  890. if (!window.localStorage) {
  891. return null;
  892. }
  893. return localStorage.getItem(profilerStorageKey + name);
  894. };
  895. var setPreference = function(name, value) {
  896. if (!window.localStorage) {
  897. return null;
  898. }
  899. localStorage.setItem(profilerStorageKey + name, value);
  900. };
  901. var requestStack = [];
  902. var extractHeaders = function(xhr, stackElement) {
  903. /* Here we avoid to call xhr.getResponseHeader in order to */
  904. /* prevent polluting the console with CORS security errors */
  905. var allHeaders = xhr.getAllResponseHeaders();
  906. var ret;
  907. if (ret = allHeaders.match(/^x-debug-token:\\s+(.*)\$/im)) {
  908. stackElement.profile = ret[1];
  909. }
  910. if (ret = allHeaders.match(/^x-debug-token-link:\\s+(.*)\$/im)) {
  911. stackElement.profilerUrl = ret[1];
  912. }
  913. if (ret = allHeaders.match(/^Symfony-Debug-Toolbar-Replace:\\s+(.*)\$/im)) {
  914. stackElement.toolbarReplaceFinished = false;
  915. stackElement.toolbarReplace = '1' === ret[1];
  916. }
  917. };
  918. var successStreak = 4;
  919. var pendingRequests = 0;
  920. var renderAjaxRequests = function() {
  921. var requestCounter = document.querySelector('.sf-toolbar-ajax-request-counter');
  922. if (!requestCounter) {
  923. return;
  924. }
  925. requestCounter.textContent = requestStack.length;
  926. var infoSpan = document.querySelector(\".sf-toolbar-ajax-info\");
  927. if (infoSpan) {
  928. infoSpan.textContent = requestStack.length + ' AJAX request' + (requestStack.length !== 1 ? 's' : '');
  929. }
  930. var ajaxToolbarPanel = document.querySelector('.sf-toolbar-block-ajax');
  931. if (requestStack.length) {
  932. ajaxToolbarPanel.style.display = 'block';
  933. } else {
  934. ajaxToolbarPanel.style.display = 'none';
  935. }
  936. if (pendingRequests > 0) {
  937. addClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  938. } else if (successStreak < 4) {
  939. addClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  940. removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  941. } else {
  942. removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
  943. removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
  944. }
  945. };
  946. var startAjaxRequest = function(index) {
  947. var tbody = document.querySelector('.sf-toolbar-ajax-request-list');
  948. if (!tbody) {
  949. return;
  950. }
  951. var nbOfAjaxRequest = tbody.rows.length;
  952. if (nbOfAjaxRequest >= 100) {
  953. tbody.deleteRow(0);
  954. }
  955. var request = requestStack[index];
  956. pendingRequests++;
  957. var row = document.createElement('tr');
  958. request.DOMNode = row;
  959. var requestNumberCell = document.createElement('td');
  960. requestNumberCell.textContent = index + 1;
  961. row.appendChild(requestNumberCell);
  962. var profilerCell = document.createElement('td');
  963. profilerCell.textContent = 'n/a';
  964. row.appendChild(profilerCell);
  965. var methodCell = document.createElement('td');
  966. methodCell.textContent = request.method;
  967. row.appendChild(methodCell);
  968. var typeCell = document.createElement('td');
  969. typeCell.textContent = request.type;
  970. row.appendChild(typeCell);
  971. var statusCodeCell = document.createElement('td');
  972. var statusCode = document.createElement('span');
  973. statusCode.textContent = 'n/a';
  974. statusCodeCell.appendChild(statusCode);
  975. row.appendChild(statusCodeCell);
  976. var pathCell = document.createElement('td');
  977. pathCell.className = 'sf-ajax-request-url';
  978. if ('GET' === request.method) {
  979. var pathLink = document.createElement('a');
  980. pathLink.setAttribute('href', request.url);
  981. pathLink.textContent = request.url;
  982. pathCell.appendChild(pathLink);
  983. } else {
  984. pathCell.textContent = request.url;
  985. }
  986. pathCell.setAttribute('title', request.url);
  987. row.appendChild(pathCell);
  988. var durationCell = document.createElement('td');
  989. durationCell.className = 'sf-ajax-request-duration';
  990. durationCell.textContent = 'n/a';
  991. row.appendChild(durationCell);
  992. request.liveDurationHandle = setInterval(function() {
  993. durationCell.textContent = (new Date() - request.start) + ' ms';
  994. }, 100);
  995. row.className = 'sf-ajax-request sf-ajax-request-loading';
  996. tbody.insertBefore(row, null);
  997. var toolbarInfo = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  998. toolbarInfo.scrollTop = toolbarInfo.scrollHeight;
  999. renderAjaxRequests();
  1000. };
  1001. var finishAjaxRequest = function(index) {
  1002. var request = requestStack[index];
  1003. clearInterval(request.liveDurationHandle);
  1004. if (!request.DOMNode) {
  1005. return;
  1006. }
  1007. if (request.toolbarReplace && !request.toolbarReplaceFinished && request.profile) {
  1008. /* Flag as complete because finishAjaxRequest can be called multiple times. */
  1009. request.toolbarReplaceFinished = true;
  1010. /* Search up through the DOM to find the toolbar's container ID. */
  1011. for (var elem = request.DOMNode; elem && elem !== document; elem = elem.parentNode) {
  1012. if (elem.id.match(/^sfwdt/)) {
  1013. Sfjs.loadToolbar(elem.id.replace(/^sfwdt/, ''), request.profile);
  1014. break;
  1015. }
  1016. }
  1017. }
  1018. pendingRequests--;
  1019. var row = request.DOMNode;
  1020. /* Unpack the children from the row */
  1021. var profilerCell = row.children[1];
  1022. var methodCell = row.children[2];
  1023. var statusCodeCell = row.children[4];
  1024. var statusCodeElem = statusCodeCell.children[0];
  1025. var durationCell = row.children[6];
  1026. if (request.error) {
  1027. row.className = 'sf-ajax-request sf-ajax-request-error';
  1028. methodCell.className = 'sf-ajax-request-error';
  1029. successStreak = 0;
  1030. } else {
  1031. row.className = 'sf-ajax-request sf-ajax-request-ok';
  1032. successStreak++;
  1033. }
  1034. if (request.statusCode) {
  1035. if (request.statusCode < 300) {
  1036. statusCodeElem.setAttribute('class', 'sf-toolbar-status');
  1037. } else if (request.statusCode < 400) {
  1038. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-yellow');
  1039. } else {
  1040. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  1041. }
  1042. statusCodeElem.textContent = request.statusCode;
  1043. } else {
  1044. statusCodeElem.setAttribute('class', 'sf-toolbar-status sf-toolbar-status-red');
  1045. }
  1046. if (request.duration) {
  1047. durationCell.textContent = request.duration + ' ms';
  1048. }
  1049. if (request.profilerUrl) {
  1050. profilerCell.textContent = '';
  1051. var profilerLink = document.createElement('a');
  1052. profilerLink.setAttribute('href', request.profilerUrl);
  1053. profilerLink.textContent = request.profile;
  1054. profilerCell.appendChild(profilerLink);
  1055. }
  1056. renderAjaxRequests();
  1057. };
  1058. {% if excluded_ajax_paths is defined %}
  1059. if (window.fetch && window.fetch.polyfill === undefined) {
  1060. var oldFetch = window.fetch;
  1061. window.fetch = function () {
  1062. var promise = oldFetch.apply(this, arguments);
  1063. var url = arguments[0];
  1064. var params = arguments[1];
  1065. var paramType = Object.prototype.toString.call(arguments[0]);
  1066. if (paramType === '[object Request]') {
  1067. url = arguments[0].url;
  1068. params = {
  1069. method: arguments[0].method,
  1070. credentials: arguments[0].credentials,
  1071. headers: arguments[0].headers,
  1072. mode: arguments[0].mode,
  1073. redirect: arguments[0].redirect
  1074. };
  1075. } else {
  1076. url = String(url);
  1077. }
  1078. if (!url.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  1079. var method = 'GET';
  1080. if (params && params.method !== undefined) {
  1081. method = params.method;
  1082. }
  1083. var stackElement = {
  1084. error: false,
  1085. url: url,
  1086. method: method,
  1087. type: 'fetch',
  1088. start: new Date()
  1089. };
  1090. var idx = requestStack.push(stackElement) - 1;
  1091. promise.then(function (r) {
  1092. stackElement.duration = new Date() - stackElement.start;
  1093. stackElement.error = r.status < 200 || r.status >= 400;
  1094. stackElement.statusCode = r.status;
  1095. stackElement.profile = r.headers.get('x-debug-token');
  1096. stackElement.profilerUrl = r.headers.get('x-debug-token-link');
  1097. stackElement.toolbarReplaceFinished = false;
  1098. stackElement.toolbarReplace = '1' === r.headers.get('Symfony-Debug-Toolbar-Replace');
  1099. finishAjaxRequest(idx);
  1100. }, function (e){
  1101. stackElement.error = true;
  1102. finishAjaxRequest(idx);
  1103. });
  1104. startAjaxRequest(idx);
  1105. }
  1106. return promise;
  1107. };
  1108. }
  1109. if (window.XMLHttpRequest && XMLHttpRequest.prototype.addEventListener) {
  1110. var proxied = XMLHttpRequest.prototype.open;
  1111. XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
  1112. var self = this;
  1113. /* prevent logging AJAX calls to static and inline files, like templates */
  1114. var path = url;
  1115. if (url.slice(0, 1) === '/') {
  1116. if (0 === url.indexOf('{{ request.basePath|e('js') }}')) {
  1117. path = url.slice({{ request.basePath|length }});
  1118. }
  1119. }
  1120. else if (0 === url.indexOf('{{ (request.schemeAndHttpHost ~ request.basePath)|e('js') }}')) {
  1121. path = url.slice({{ (request.schemeAndHttpHost ~ request.basePath)|length }});
  1122. }
  1123. if (!path.match(new RegExp({{ excluded_ajax_paths|json_encode|raw }}))) {
  1124. var stackElement = {
  1125. error: false,
  1126. url: url,
  1127. method: method,
  1128. type: 'xhr',
  1129. start: new Date()
  1130. };
  1131. var idx = requestStack.push(stackElement) - 1;
  1132. this.addEventListener('readystatechange', function() {
  1133. if (self.readyState == 4) {
  1134. stackElement.duration = new Date() - stackElement.start;
  1135. stackElement.error = self.status < 200 || self.status >= 400;
  1136. stackElement.statusCode = self.status;
  1137. extractHeaders(self, stackElement);
  1138. finishAjaxRequest(idx);
  1139. }
  1140. }, false);
  1141. startAjaxRequest(idx);
  1142. }
  1143. proxied.apply(this, Array.prototype.slice.call(arguments));
  1144. };
  1145. }
  1146. {% endif %}
  1147. return {
  1148. hasClass: hasClass,
  1149. removeClass: removeClass,
  1150. addClass: addClass,
  1151. toggleClass: toggleClass,
  1152. getPreference: getPreference,
  1153. setPreference: setPreference,
  1154. addEventListener: addEventListener,
  1155. request: request,
  1156. renderAjaxRequests: renderAjaxRequests,
  1157. getSfwdt: function(token) {
  1158. if (!this.sfwdt) {
  1159. this.sfwdt = document.getElementById('sfwdt' + token);
  1160. }
  1161. return this.sfwdt;
  1162. },
  1163. load: function(selector, url, onSuccess, onError, options) {
  1164. var el = document.getElementById(selector);
  1165. if (el && el.getAttribute('data-sfurl') !== url) {
  1166. request(
  1167. url,
  1168. function(xhr) {
  1169. el.innerHTML = xhr.responseText;
  1170. el.setAttribute('data-sfurl', url);
  1171. removeClass(el, 'loading');
  1172. var pending = pendingRequests;
  1173. for (var i = 0; i < requestStack.length; i++) {
  1174. startAjaxRequest(i);
  1175. if (requestStack[i].duration) {
  1176. finishAjaxRequest(i);
  1177. }
  1178. }
  1179. /* Revert the pending state in case there was a start called without a finish above. */
  1180. pendingRequests = pending;
  1181. (onSuccess || noop)(xhr, el);
  1182. },
  1183. function(xhr) { (onError || noop)(xhr, el); },
  1184. '',
  1185. options
  1186. );
  1187. }
  1188. return this;
  1189. },
  1190. showToolbar: function(token) {
  1191. var sfwdt = this.getSfwdt(token);
  1192. removeClass(sfwdt, 'sf-display-none');
  1193. if (getPreference('toolbar/displayState') == 'none') {
  1194. document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  1195. document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  1196. document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  1197. } else {
  1198. document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  1199. document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  1200. document.getElementById('sfMiniToolbar-' + token).style.display = 'none';
  1201. }
  1202. },
  1203. hideToolbar: function(token) {
  1204. var sfwdt = this.getSfwdt(token);
  1205. addClass(sfwdt, 'sf-display-none');
  1206. },
  1207. initToolbar: function(token) {
  1208. this.showToolbar(token);
  1209. var hideButton = document.getElementById('sfToolbarHideButton-' + token);
  1210. var hideButtonSvg = hideButton.querySelector('svg');
  1211. hideButtonSvg.setAttribute('aria-hidden', 'true');
  1212. hideButtonSvg.setAttribute('focusable', 'false');
  1213. addEventListener(hideButton, 'click', function (event) {
  1214. event.preventDefault();
  1215. var p = this.parentNode;
  1216. p.style.display = 'none';
  1217. (p.previousElementSibling || p.previousSibling).style.display = 'none';
  1218. document.getElementById('sfMiniToolbar-' + token).style.display = 'block';
  1219. setPreference('toolbar/displayState', 'none');
  1220. });
  1221. var showButton = document.getElementById('sfToolbarMiniToggler-' + token);
  1222. var showButtonSvg = showButton.querySelector('svg');
  1223. showButtonSvg.setAttribute('aria-hidden', 'true');
  1224. showButtonSvg.setAttribute('focusable', 'false');
  1225. addEventListener(showButton, 'click', function (event) {
  1226. event.preventDefault();
  1227. var elem = this.parentNode;
  1228. if (elem.style.display == 'none') {
  1229. document.getElementById('sfToolbarMainContent-' + token).style.display = 'none';
  1230. document.getElementById('sfToolbarClearer-' + token).style.display = 'none';
  1231. elem.style.display = 'block';
  1232. } else {
  1233. document.getElementById('sfToolbarMainContent-' + token).style.display = 'block';
  1234. document.getElementById('sfToolbarClearer-' + token).style.display = 'block';
  1235. elem.style.display = 'none'
  1236. }
  1237. setPreference('toolbar/displayState', 'block');
  1238. });
  1239. },
  1240. loadToolbar: function(token, newToken) {
  1241. var that = this;
  1242. var triesCounter = document.getElementById('sfLoadCounter-' + token);
  1243. var options = {
  1244. retry: true,
  1245. onSend: function (count) {
  1246. if (count === 3) {
  1247. that.initToolbar(token);
  1248. }
  1249. if (triesCounter) {
  1250. triesCounter.textContent = count;
  1251. }
  1252. },
  1253. };
  1254. var cancelButton = document.getElementById('sfLoadCancel-' + token);
  1255. if (cancelButton) {
  1256. addEventListener(cancelButton, 'click', function (event) {
  1257. event.preventDefault();
  1258. options.stop = true;
  1259. that.hideToolbar(token);
  1260. });
  1261. }
  1262. newToken = (newToken || token);
  1263. this.load(
  1264. 'sfwdt' + token,
  1265. '{{ url(\"_wdt\", { \"token\": \"xxxxxx\" })|escape('js') }}'.replace(/xxxxxx/, newToken),
  1266. function(xhr, el) {
  1267. /* Do nothing in the edge case where the toolbar has already been replaced with a new one */
  1268. if (!document.getElementById('sfToolbarMainContent-' + newToken)) {
  1269. return;
  1270. }
  1271. /* Evaluate in global scope scripts embedded inside the toolbar */
  1272. var i, scripts = [].slice.call(el.querySelectorAll('script'));
  1273. for (i = 0; i < scripts.length; ++i) {
  1274. if (scripts[i].firstChild) {
  1275. eval.call({}, scripts[i].firstChild.nodeValue);
  1276. }
  1277. }
  1278. el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
  1279. if (el.style.display == 'none') {
  1280. return;
  1281. }
  1282. that.initToolbar(newToken);
  1283. /* Handle toolbar-info position */
  1284. var toolbarBlocks = [].slice.call(el.querySelectorAll('.sf-toolbar-block'));
  1285. for (i = 0; i < toolbarBlocks.length; ++i) {
  1286. toolbarBlocks[i].onmouseover = function () {
  1287. var toolbarInfo = this.querySelectorAll('.sf-toolbar-info')[0];
  1288. var pageWidth = document.body.clientWidth;
  1289. var elementWidth = toolbarInfo.offsetWidth;
  1290. var leftValue = (elementWidth + this.offsetLeft) - pageWidth;
  1291. var rightValue = (elementWidth + (pageWidth - this.offsetLeft)) - pageWidth;
  1292. /* Reset right and left value, useful on window resize */
  1293. toolbarInfo.style.right = '';
  1294. toolbarInfo.style.left = '';
  1295. if (elementWidth > pageWidth) {
  1296. toolbarInfo.style.left = 0;
  1297. }
  1298. else if (leftValue > 0 && rightValue > 0) {
  1299. toolbarInfo.style.right = (rightValue * -1) + 'px';
  1300. } else if (leftValue < 0) {
  1301. toolbarInfo.style.left = 0;
  1302. } else {
  1303. toolbarInfo.style.right = '0px';
  1304. }
  1305. };
  1306. }
  1307. renderAjaxRequests();
  1308. addEventListener(document.querySelector('.sf-toolbar-ajax-clear'), 'click', function() {
  1309. requestStack = [];
  1310. renderAjaxRequests();
  1311. successStreak = 4;
  1312. document.querySelector('.sf-toolbar-ajax-request-list').innerHTML = '';
  1313. });
  1314. addEventListener(document.querySelector('.sf-toolbar-block-ajax'), 'mouseenter', function (event) {
  1315. var elem = document.querySelector('.sf-toolbar-block-ajax .sf-toolbar-info');
  1316. elem.scrollTop = elem.scrollHeight;
  1317. });
  1318. addEventListener(document.querySelector('.sf-toolbar-block-ajax > .sf-toolbar-icon'), 'click', function (event) {
  1319. event.preventDefault();
  1320. toggleClass(this.parentNode, 'hover');
  1321. });
  1322. var dumpInfo = document.querySelector('.sf-toolbar-block-dump .sf-toolbar-info');
  1323. if (null !== dumpInfo) {
  1324. addEventListener(dumpInfo, 'sfbeforedumpcollapse', function () {
  1325. dumpInfo.style.minHeight = dumpInfo.getBoundingClientRect().height+'px';
  1326. });
  1327. addEventListener(dumpInfo, 'mouseleave', function () {
  1328. dumpInfo.style.minHeight = '';
  1329. });
  1330. }
  1331. },
  1332. function(xhr) {
  1333. if (xhr.status !== 0 && !options.stop) {
  1334. var sfwdt = that.getSfwdt(token);
  1335. sfwdt.innerHTML = '\\
  1336. <div class=\"sf-toolbarreset\">\\
  1337. <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>\\
  1338. An error occurred while loading the web debug toolbar. <a href=\"{{ url(\"_profiler_home\")|escape('js') }}' + newToken + '\">Open the web profiler.</a>\\
  1339. </div>\\
  1340. ';
  1341. sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');
  1342. }
  1343. },
  1344. options
  1345. );
  1346. return this;
  1347. },
  1348. toggle: function(selector, elOn, elOff) {
  1349. var tmp = elOn.style.display,
  1350. el = document.getElementById(selector);
  1351. elOn.style.display = elOff.style.display;
  1352. elOff.style.display = tmp;
  1353. if (el) {
  1354. el.style.display = 'none' === tmp ? 'none' : 'block';
  1355. }
  1356. return this;
  1357. },
  1358. createTabs: function() {
  1359. var tabGroups = document.querySelectorAll('.sf-tabs:not([data-processed=true])');
  1360. /* create the tab navigation for each group of tabs */
  1361. for (var i = 0; i < tabGroups.length; i++) {
  1362. var tabs = tabGroups[i].querySelectorAll(':scope > .tab');
  1363. var tabNavigation = document.createElement('ul');
  1364. tabNavigation.className = 'tab-navigation';
  1365. var selectedTabId = 'tab-' + i + '-0'; /* select the first tab by default */
  1366. for (var j = 0; j < tabs.length; j++) {
  1367. var tabId = 'tab-' + i + '-' + j;
  1368. var tabTitle = tabs[j].querySelector('.tab-title').innerHTML;
  1369. var tabNavigationItem = document.createElement('li');
  1370. tabNavigationItem.setAttribute('data-tab-id', tabId);
  1371. if (hasClass(tabs[j], 'active')) { selectedTabId = tabId; }
  1372. if (hasClass(tabs[j], 'disabled')) { addClass(tabNavigationItem, 'disabled'); }
  1373. tabNavigationItem.innerHTML = tabTitle;
  1374. tabNavigation.appendChild(tabNavigationItem);
  1375. var tabContent = tabs[j].querySelector('.tab-content');
  1376. tabContent.parentElement.setAttribute('id', tabId);
  1377. }
  1378. tabGroups[i].insertBefore(tabNavigation, tabGroups[i].firstChild);
  1379. addClass(document.querySelector('[data-tab-id=\"' + selectedTabId + '\"]'), 'active');
  1380. }
  1381. /* display the active tab and add the 'click' event listeners */
  1382. for (i = 0; i < tabGroups.length; i++) {
  1383. tabNavigation = tabGroups[i].querySelectorAll(':scope > .tab-navigation li');
  1384. for (j = 0; j < tabNavigation.length; j++) {
  1385. tabId = tabNavigation[j].getAttribute('data-tab-id');
  1386. document.getElementById(tabId).querySelector('.tab-title').className = 'hidden';
  1387. if (hasClass(tabNavigation[j], 'active')) {
  1388. document.getElementById(tabId).className = 'block';
  1389. } else {
  1390. document.getElementById(tabId).className = 'hidden';
  1391. }
  1392. tabNavigation[j].addEventListener('click', function(e) {
  1393. var activeTab = e.target || e.srcElement;
  1394. /* needed because when the tab contains HTML contents, user can click */
  1395. /* on any of those elements instead of their parent '<li>' element */
  1396. while (activeTab.tagName.toLowerCase() !== 'li') {
  1397. activeTab = activeTab.parentNode;
  1398. }
  1399. /* get the full list of tabs through the parent of the active tab element */
  1400. var tabNavigation = activeTab.parentNode.children;
  1401. for (var k = 0; k < tabNavigation.length; k++) {
  1402. var tabId = tabNavigation[k].getAttribute('data-tab-id');
  1403. document.getElementById(tabId).className = 'hidden';
  1404. removeClass(tabNavigation[k], 'active');
  1405. }
  1406. addClass(activeTab, 'active');
  1407. var activeTabId = activeTab.getAttribute('data-tab-id');
  1408. document.getElementById(activeTabId).className = 'block';
  1409. });
  1410. }
  1411. tabGroups[i].setAttribute('data-processed', 'true');
  1412. }
  1413. },
  1414. createToggles: function() {
  1415. var toggles = document.querySelectorAll('.sf-toggle:not([data-processed=true])');
  1416. for (var i = 0; i < toggles.length; i++) {
  1417. var elementSelector = toggles[i].getAttribute('data-toggle-selector');
  1418. var element = document.querySelector(elementSelector);
  1419. addClass(element, 'sf-toggle-content');
  1420. if (toggles[i].hasAttribute('data-toggle-initial') && toggles[i].getAttribute('data-toggle-initial') == 'display') {
  1421. addClass(toggles[i], 'sf-toggle-on');
  1422. addClass(element, 'sf-toggle-visible');
  1423. } else {
  1424. addClass(toggles[i], 'sf-toggle-off');
  1425. addClass(element, 'sf-toggle-hidden');
  1426. }
  1427. addEventListener(toggles[i], 'click', function(e) {
  1428. e.preventDefault();
  1429. if ('' !== window.getSelection().toString()) {
  1430. /* Don't do anything on text selection */
  1431. return;
  1432. }
  1433. var toggle = e.target || e.srcElement;
  1434. /* needed because when the toggle contains HTML contents, user can click */
  1435. /* on any of those elements instead of their parent '.sf-toggle' element */
  1436. while (!hasClass(toggle, 'sf-toggle')) {
  1437. toggle = toggle.parentNode;
  1438. }
  1439. var element = document.querySelector(toggle.getAttribute('data-toggle-selector'));
  1440. toggleClass(toggle, 'sf-toggle-on');
  1441. toggleClass(toggle, 'sf-toggle-off');
  1442. toggleClass(element, 'sf-toggle-hidden');
  1443. toggleClass(element, 'sf-toggle-visible');
  1444. /* the toggle doesn't change its contents when clicking on it */
  1445. if (!toggle.hasAttribute('data-toggle-alt-content')) {
  1446. return;
  1447. }
  1448. if (!toggle.hasAttribute('data-toggle-original-content')) {
  1449. toggle.setAttribute('data-toggle-original-content', toggle.innerHTML);
  1450. }
  1451. var currentContent = toggle.innerHTML;
  1452. var originalContent = toggle.getAttribute('data-toggle-original-content');
  1453. var altContent = toggle.getAttribute('data-toggle-alt-content');
  1454. toggle.innerHTML = currentContent !== altContent ? altContent : originalContent;
  1455. });
  1456. /* Prevents from disallowing clicks on links inside toggles */
  1457. var toggleLinks = toggles[i].querySelectorAll('a');
  1458. for (var j = 0; j < toggleLinks.length; j++) {
  1459. addEventListener(toggleLinks[j], 'click', function(e) {
  1460. e.stopPropagation();
  1461. });
  1462. }
  1463. /* Prevents from disallowing clicks on \"copy to clipboard\" elements inside toggles */
  1464. var copyToClipboardElements = toggles[i].querySelectorAll('span[data-clipboard-text]');
  1465. for (var k = 0; k < copyToClipboardElements.length; k++) {
  1466. addEventListener(copyToClipboardElements[k], 'click', function(e) {
  1467. e.stopPropagation();
  1468. });
  1469. }
  1470. toggles[i].setAttribute('data-processed', 'true');
  1471. }
  1472. },
  1473. initializeLogsTable: function() {
  1474. Sfjs.updateLogsTable();
  1475. document.querySelectorAll('.log-filter input').forEach((input) => {
  1476. input.addEventListener('change', () => { Sfjs.updateLogsTable(); });
  1477. });
  1478. document.querySelectorAll('.filter-select-all-or-none button').forEach((link) => {
  1479. link.addEventListener('click', () => {
  1480. const selectAll = link.classList.contains('select-all');
  1481. link.closest('.log-filter-content').querySelectorAll('input').forEach((input) => {
  1482. input.checked = selectAll;
  1483. });
  1484. Sfjs.updateLogsTable();
  1485. });
  1486. });
  1487. document.body.addEventListener('click', (event) => {
  1488. document.querySelectorAll('details.log-filter').forEach((filterElement) => {
  1489. if (!filterElement.contains(event.target) && filterElement.open) {
  1490. filterElement.open = false;
  1491. }
  1492. });
  1493. });
  1494. },
  1495. updateLogsTable: function() {
  1496. const selectedType = document.querySelector('#log-filter-type input:checked').value;
  1497. const priorities = document.querySelectorAll('#log-filter-priority input');
  1498. const allPriorities = Array.from(priorities).map((input) => input.value);
  1499. const selectedPriorities = Array.from(priorities).filter((input) => input.checked).map((input) => input.value);
  1500. const channels = document.querySelectorAll('#log-filter-channel input');
  1501. const selectedChannels = Array.from(channels).filter((input) => input.checked).map((input) => input.value);
  1502. const logs = document.querySelector('table.logs');
  1503. if (null === logs) {
  1504. return;
  1505. }
  1506. /* hide rows that don't match the current filters */
  1507. let numVisibleRows = 0;
  1508. logs.querySelectorAll('tbody tr').forEach((row) => {
  1509. if ('all' !== selectedType && selectedType !== row.getAttribute('data-type')) {
  1510. row.style.display = 'none';
  1511. return;
  1512. }
  1513. const priority = row.getAttribute('data-priority');
  1514. if (false === selectedPriorities.includes(priority) && true === allPriorities.includes(priority)) {
  1515. row.style.display = 'none';
  1516. return;
  1517. }
  1518. if ('' !== row.getAttribute('data-channel') && false === selectedChannels.includes(row.getAttribute('data-channel'))) {
  1519. row.style.display = 'none';
  1520. return;
  1521. }
  1522. row.style.display = 'table-row';
  1523. numVisibleRows++;
  1524. });
  1525. document.querySelector('table.logs').style.display = 0 === numVisibleRows ? 'none' : 'table';
  1526. document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none';
  1527. /* update the selected totals of all filters */
  1528. document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length;
  1529. document.querySelector('#log-filter-channel .filter-active-num').innerText = (channels.length === selectedChannels.length) ? 'All' : selectedChannels.length;
  1530. /* update the currently selected \"log type\" tab */
  1531. document.querySelectorAll('#log-filter-type li').forEach((tab) => tab.classList.remove('active'));
  1532. document.querySelector(`#log-filter-type input[value=\"\${selectedType}\"]`).parentElement.classList.add('active');
  1533. },
  1534. };
  1535. })();
  1536. Sfjs.addEventListener(document, 'DOMContentLoaded', function() {
  1537. Sfjs.createTabs();
  1538. Sfjs.createToggles();
  1539. });
  1540. }
  1541. /*]]>*/</script>
  1542. ", "@WebProfiler/Profiler/base_js.html.twig", "/var/www/share/dev.m-medientechnik.de/shopware/vendor/symfony/web-profiler-bundle/Resources/views/Profiler/base_js.html.twig");
  1543. }
  1544. }