Skip to content

Commit 0d4d7e0

Browse files
committed
[WebProfilerBundle] Make the toolbar use the common JS
1 parent a440279 commit 0d4d7e0

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed
Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
<div id="sfwdt{{ token }}" class="sf-toolbar" style="display: none"></div>
2+
{% include 'WebProfilerBundle:Profiler:base_js.html.twig' %}
23
<script type="text/javascript">/*<![CDATA[*/
34
(function () {
4-
var wdt, xhr;
5-
wdt = document.getElementById('sfwdt{{ token }}');
6-
if (window.XMLHttpRequest) {
7-
xhr = new XMLHttpRequest();
8-
} else {
9-
xhr = new ActiveXObject('Microsoft.XMLHTTP');
10-
}
11-
xhr.open('GET', '{{ path("_wdt", { "token": token }) }}', true);
12-
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
13-
xhr.onreadystatechange = function(state) {
14-
if (4 === xhr.readyState && 200 === xhr.status && -1 !== xhr.responseText.indexOf('sf-toolbarreset')) {
15-
wdt.innerHTML = xhr.responseText;
16-
wdt.style.display = 'block';
17-
} else if (4 === xhr.readyState && xhr.status != 200) {
18-
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}');
5+
Sfjs.load(
6+
'#sfwdt{{ token }}',
7+
'{{ path("_wdt", { "token": token }) }}',
8+
function(xhr, el) {
9+
el.style.display = -1 !== xhr.responseText.indexOf('sf-toolbarreset') ? 'block' : 'none';
10+
},
11+
function(xhr) {
12+
confirm('An error occurred while loading the web debug toolbar (' + xhr.status + ': ' + xhr.statusText + ').\n\nDo you want to open the profiler?') && (window.location = '{{ path("_profiler", { "token": token }) }}')
1913
}
20-
};
21-
xhr.send('');
14+
);
2215
})();
2316
/*]]>*/</script>

0 commit comments

Comments
 (0)