Skip to content

Commit 0c75396

Browse files
author
Matthew Smeets
committed
[WebProfilerBundle] Add clear button to ajax tab
1 parent d305581 commit 0c75396

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
CHANGELOG
22
=========
33

4+
4.4.0
5+
-----
6+
* Added button to clear the ajax request tab
7+
48
4.3.0
59
-----
610

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/ajax.html.twig

100644100755
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
{% set text %}
1010
<div class="sf-toolbar-info-piece">
11-
<b class="sf-toolbar-ajax-info"></b>
11+
<b class="sf-toolbar-header">
12+
<b class="sf-toolbar-ajax-info"></b>
13+
<b class="sf-toolbar-action"><a class="sf-toolbar-action-clear" href="javascript:void(0);">Clear</a></b>
14+
</b>
1215
</div>
1316
<div class="sf-toolbar-info-piece">
1417
<table class="sf-toolbar-ajax-requests">

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

100644100755
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424
2525
var profilerStorageKey = 'symfony/profiler/';
2626
27+
var addEventListener;
28+
29+
var el = document.createElement('div');
30+
if (!('addEventListener' in el)) {
31+
addEventListener = function (element, eventName, callback) {
32+
element.attachEvent('on' + eventName, callback);
33+
};
34+
} else {
35+
addEventListener = function (element, eventName, callback) {
36+
element.addEventListener(eventName, callback, false);
37+
};
38+
}
39+
2740
var request = function(url, onSuccess, onError, payload, options) {
2841
var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
2942
options = options || {};
@@ -118,6 +131,11 @@
118131
removeClass(ajaxToolbarPanel, 'sf-ajax-request-loading');
119132
removeClass(ajaxToolbarPanel, 'sf-toolbar-status-red');
120133
}
134+
135+
addEventListener(document.querySelector('.sf-toolbar-action-clear'), 'click', function() {
136+
requestStack = [];
137+
renderAjaxRequests();
138+
});
121139
};
122140
123141
var startAjaxRequest = function(index) {
@@ -255,19 +273,6 @@
255273
renderAjaxRequests();
256274
};
257275
258-
var addEventListener;
259-
260-
var el = document.createElement('div');
261-
if (!('addEventListener' in el)) {
262-
addEventListener = function (element, eventName, callback) {
263-
element.attachEvent('on' + eventName, callback);
264-
};
265-
} else {
266-
addEventListener = function (element, eventName, callback) {
267-
element.addEventListener(eventName, callback, false);
268-
};
269-
}
270-
271276
{% if excluded_ajax_paths is defined %}
272277
if (window.fetch && window.fetch.polyfill === undefined) {
273278
var oldFetch = window.fetch;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy