8000 [WebProfilerBundle] Add clear button to ajax tab · symfony/symfony@945955a · GitHub
[go: up one dir, main page]

Skip to content

Commit 945955a

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

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

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)
0