From c889314105b7aae901ab557bb9e2f906e8bcc355 Mon Sep 17 00:00:00 2001
From: Aymeric Augustin {% trans 'None' %}');
- if (endStat) {
- // Render a start through end bar
- $row.html(' ' + stat.replace('Start', '') + ' ' +
- ' ' +
- '' + (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ') ');
- } else {
- // Render a point in time
- $row.html('' + stat + ' ' +
- ' ' +
- '' + (perf.timing[stat] - timingOffset) + ' ');
- }
- $('#djDebugBrowserTimingTableBody').append($row);
- }
-
- // This is a reasonably complete and ordered set of timing periods (2 params) and events (1 param)
- addRow('domainLookupStart', 'domainLookupEnd');
- addRow('connectStart', 'connectEnd');
- addRow('requestStart', 'responseEnd'); // There is no requestEnd
- addRow('responseStart', 'responseEnd');
- addRow('domLoading', 'domComplete'); // Spans the events below
- addRow('domInteractive');
- addRow('domContentLoadedEventStart', 'domContentLoadedEventEnd');
- addRow('loadEventStart', 'loadEventEnd');
- $('#djDebugBrowserTiming').css("display", "block");
- }
- }
-
- $(window).bind('load', function() {
- setTimeout(renderPerf, 0);
- });
- $(document).ready(function() {
- djdt.init();
- });
-
+ $(document).ready(djdt.init);
return djdt;
}));
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js
new file mode 100644
index 000000000..172c2a6a4
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.profiling.js
@@ -0,0 +1,27 @@
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'], factory);
+ } else {
+ factory(jQuery);
+ }
+}(function ($) {
+ function getSubcalls(row) {
+ var id = row.attr('id');
+ return $('.djDebugProfileRow[id^="'+id+'_"]');
+ }
+ function getDirectSubcalls(row) {
+ var subcalls = getSubcalls(row);
+ var depth = parseInt(row.attr('depth'), 10) + 1;
+ return subcalls.filter('[depth='+depth+']');
+ }
+ $('.djDebugProfileRow .djDebugProfileToggle').on('click', function(){
+ var row = $(this).closest('.djDebugProfileRow');
+ var subcalls = getSubcalls(row);
+ if (subcalls.css('display') == 'none') {
+ getDirectSubcalls(row).show();
+ } else {
+ subcalls.hide();
+ }
+ });
+
+}));
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.template.js b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js
new file mode 100644
index 000000000..38307c1fa
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.template.js
@@ -0,0 +1,17 @@
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'], factory);
+ } else {
+ factory(jQuery);
+ }
+}(function ($) {
+ var uarr = String.fromCharCode(0x25b6),
+ darr = String.fromCharCode(0x25bc);
+
+ $('#djDebugTemplatePanel a.djTemplateShowContext').on('click', function() {
+ var arrow = $(this).children('.toggleArrow');
+ arrow.html(arrow.html() == uarr ? darr : uarr);
+ $(this).parent().next().toggle();
+ return false;
+ });
+}));
diff --git a/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
new file mode 100644
index 000000000..514fda7ef
--- /dev/null
+++ b/debug_toolbar/static/debug_toolbar/js/toolbar.timer.js
@@ -0,0 +1,54 @@
+(function (factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'], factory);
+ } else {
+ factory(jQuery);
+ }
+}(function ($) {
+ // Browser timing remains hidden unless we can successfully access the performance object
+ var perf = window.performance || window.msPerformance ||
+ window.webkitPerformance || window.mozPerformance;
+ if (!perf)
+ return;
+
+ var rowCount = 0,
+ timingOffset = perf.timing.navigationStart,
+ timingEnd = perf.timing.loadEventEnd,
+ totalTime = timingEnd - timingOffset;
+ function getLeft(stat) {
+ return ((perf.timing[stat] - timingOffset) / (totalTime)) * 100.0;
+ }
+ function getCSSWidth(stat, endStat) {
+ var width = ((perf.timing[endStat] - perf.timing[stat]) / (totalTime)) * 100.0;
+ // Calculate relative percent (same as sql panel logic)
+ width = 100.0 * width / (100.0 - getLeft(stat));
+ return (width < 1) ? "2px" : width + "%";
+ }
+ function addRow(stat, endStat) {
+ rowCount++;
+ var $row = $('');
+ if (endStat) {
+ // Render a start through end bar
+ $row.html(' ' + stat.replace('Start', '') + ' ' +
+ ' ' +
+ '' + (perf.timing[stat] - timingOffset) + ' (+' + (perf.timing[endStat] - perf.timing[stat]) + ') ');
+ } else {
+ // Render a point in time
+ $row.html('' + stat + ' ' +
+ ' ' +
+ '' + (perf.timing[stat] - timingOffset) + ' ');
+ }
+ $('#djDebugBrowserTimingTableBody').append($row);
+ }
+
+ // This is a reasonably complete and ordered set of timing periods (2 params) and events (1 param)
+ addRow('domainLookupStart', 'domainLookupEnd');
+ addRow('connectStart', 'connectEnd');
+ addRow('requestStart', 'responseEnd'); // There is no requestEnd
+ addRow('responseStart', 'responseEnd');
+ addRow('domLoading', 'domComplete'); // Spans the events below
+ addRow('domInteractive');
+ addRow('domContentLoadedEventStart', 'domContentLoadedEventEnd');
+ addRow('loadEventStart', 'loadEventEnd');
+ $('#djDebugBrowserTiming').css("display", "block");
+}));
diff --git a/debug_toolbar/templates/debug_toolbar/panels/profiling.html b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
index f2d43def9..34ecc8742 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/profiling.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/profiling.html
@@ -40,4 +40,6 @@
{% endif %}
{% endfor %}
-
\ No newline at end of file
+
+
+
diff --git a/debug_toolbar/templates/debug_toolbar/panels/templates.html b/debug_toolbar/templates/debug_toolbar/panels/templates.html
index 5cbb7425b..dbe93f81a 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/templates.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/templates.html
@@ -42,3 +42,5 @@ {% blocktrans count context_processors|length as context_processors_count %}
{% else %}
{% trans 'Resource Usage' %}
-
+
+