@@ -232,7 +232,7 @@ window.djdt = (function(window, document, jQuery) {
232
232
} ( window , document , $djdtjq ) ) ;
233
233
234
234
235
- ( function ( window , document ) {
235
+ ( function ( window , document , $ ) {
236
236
function _renderPerf ( ) {
237
237
// Browser timing remains hidden unless we can successfully access the performance object
238
238
var perf = window . performance || window . msPerformance ||
@@ -253,46 +253,38 @@ window.djdt = (function(window, document, jQuery) {
253
253
}
254
254
function addRow ( stat , endStat ) {
255
255
rowCount ++ ;
256
- var row = document . createElement ( 'tr' ) ,
257
- keyCell = document . createElement ( 'td' ) ,
258
- timelineCell = document . createElement ( 'td' ) ,
259
- valueCell = document . createElement ( 'td' ) ;
260
- row . className = ( rowCount % 2 ) ? 'djDebugOdd' : 'djDebugEven' ;
261
- timelineCell . className = 'timeline' ;
256
+ var $row = $ ( '<tr class="' + ( ( rowCount % 2 ) ? 'djDebugOdd' : 'djDebugEven' ) + '"></tr>' ) ;
262
257
if ( endStat ) {
263
258
// Render a start through end bar
264
- keyCell . innerHTML = stat . replace ( 'Start' , '' ) ; ;
265
- timelineCell . innerHTML = '< div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft ( stat ) + '%;"><strong style="width:' + getCSSWidth ( stat , endStat ) + ';"> </strong></div></div>' ;
266
- valueCell . innerHTML = ( perf . timing [ stat ] - timingOffset ) + ' (+' + ( perf . timing [ endStat ] - perf . timing [ stat ] ) + ')' ;
259
+ $row . html ( '<td>' + stat . replace ( 'Start' , '' ) + '</td>' +
260
+ '<td class="timeline">< div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft ( stat ) + '%;"><strong style="width:' + getCSSWidth ( stat , endStat ) + ';"> </strong></div></div></td>' +
261
+ '<td>' + ( perf . timing [ stat ] - timingOffset ) + ' (+' + ( perf . timing [ endStat ] - perf . timing [ stat ] ) + ')</td>' ) ;
267
262
} else {
268
263
// Render a point in time
269
- keyCell . innerHTML = stat ;
270
- timelineCell . innerHTML = '< div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft ( stat ) + '%;"><strong style="width:2px;"> </strong></div></div>' ;
271
- valueCell . innerHTML = ( perf . timing [ stat ] - timingOffset ) ;
264
+ $row . html ( '<td>' + stat + '</td>' +
265
+ '<td class="timeline">< div class="djDebugTimeline"><div class="djDebugLineChart" style="left:' + getLeft ( stat ) + '%;"><strong style="width:2px;"> </strong></div></div></td>' +
266
+ '<td>' + ( perf . timing [ stat ] - timingOffset ) + '</td>' ) ;
272
267
}
273
- row . appendChild ( keyCell ) ;
274
- row . appendChild ( timelineCell ) ;
275
- row . appendChild ( valueCell ) ;
276
- document . getElementById ( 'djDebugBrowserTimingTableBody' ) . appendChild ( row ) ;
268
+ $ ( '#djDebugBrowserTimingTableBody' ) . append ( $row ) ;
277
269
}
278
270
279
271
// This is a reasonably complete and ordered set of timing periods (2 params) and events (1 param)
280
272
addRow ( 'domainLookupStart' , 'domainLookupEnd' ) ;
281
273
addRow ( 'connectStart' , 'connectEnd' ) ;
282
- addRow ( 'requestStart' , 'responseEnd' ) // There is no requestStart
274
+ addRow ( 'requestStart' , 'responseEnd' ) // There is no requestEnd
283
275
addRow ( 'responseStart' , 'responseEnd' ) ;
284
276
addRow ( 'domLoading' , 'domComplete' ) ; // Spans the events below
285
277
addRow ( 'domInteractive' ) ;
286
278
addRow ( 'domContentLoadedEventStart' , 'domContentLoadedEventEnd' ) ;
287
279
addRow ( 'loadEventStart' , 'loadEventEnd' ) ;
288
- document . getElementById ( ' djDebugBrowserTiming') . style . display = "block" ;
280
+ $ ( '# djDebugBrowserTiming') . css ( " display" , "block" ) ;
289
281
}
290
282
}
291
283
292
284
function renderPerf ( ) {
293
285
setTimeout ( _renderPerf , 1000 ) ;
294
286
}
295
287
296
- if ( window . addEventListener ) { window . addEventListener ( " load" , renderPerf , false ) ; }
297
- else if ( window . attachEvent ) { window . attachEvent ( "onload" , renderPerf ) ; }
288
+ $ ( window ) . bind ( ' load' , renderPerf ) ;
289
+
298
290
} ( window , document , $djdtjq ) ) ;
0 commit comments