' )
.append( $( '' )
.text( entry.typeText )
.addClass( 'mw-debug-console-' + entry.type )
)
.append( $( ' | ' ).html( entry.msg ) )
.append( $( ' | ' ).text( entry.caller ) )
.appendTo( $table );
}
return $table;
},
/**
* Build query list pane.
*
* @return {jQuery}
*/
buildQueryTable: function () {
const $table = $( '' ).attr( 'id', 'mw-debug-querylist' );
const length = this.data.queries.length;
$( '' )
.append( $( '' ).attr( 'scope', 'col' ).text( '#' ).css( 'width', '4em' ) )
.append( $( ' | ' ).attr( 'scope', 'col' ).text( 'SQL' ) )
.append( $( ' | ' ).attr( 'scope', 'col' ).text( 'Time' ).css( 'width', '8em' ) )
.append( $( ' | ' ).attr( 'scope', 'col' ).text( 'Call' ).css( 'width', '18em' ) )
.appendTo( $table );
for ( let i = 0; i < length; i++ ) {
const query = this.data.queries[ i ];
$( ' | ' )
.append( $( '' ).text( i + 1 ) )
.append( $( ' | ' ).text( query.sql ) )
.append( $( ' | ' ).text( ( query.time * 1000 ).toFixed( 3 ) + 'ms' ).addClass( 'stats' ) )
.append( $( ' | ' ).text( query.function ) )
.appendTo( $table );
}
return $table;
},
/**
* Build legacy debug log pane.
*
* @return {jQuery}
*/
buildDebugLogTable: function () {
const $list = $( '' );
const length = this.data.debugLog.length;
for ( let i = 0; i < length; i++ ) {
const line = this.data.debugLog[ i ];
$( '- ' )
.html( mw.html.escape( line ).replace( /\n/g, '
\n' ) )
.appendTo( $list );
}
return $list;
},
/**
* Build request information pane.
*
* @return {jQuery}
*/
buildRequestPane: function () {
function buildTable( title, data ) {
const $unit = $( '' ).append( $( ' ' ).text( title ) );
const $table = $( '' ).appendTo( $unit );
$( '' )
.append(
$( '' ).attr( 'scope', 'col' ).text( 'Key' ),
$( ' | ' ).attr( 'scope', 'col' ).text( 'Value' )
)
.appendTo( $table );
for ( const key in data ) {
$( ' | ' )
.append( $( '' ).attr( 'scope', 'row' ).text( key ) )
.append( $( ' | ' ).text( data[ key ] ) )
.appendTo( $table );
}
return $unit;
}
return $( '' )
.text( this.data.request.method + ' ' + this.data.request.url )
.append( buildTable( 'Headers', this.data.request.headers ) )
.append( buildTable( 'Parameters', this.data.request.params ) );
},
/**
* Build included files pane.
*
* @return {jQuery}
*/
buildIncludesPane: function () {
const $table = $( ' ' );
const length = this.data.includes.length;
for ( let i = 0; i < length; i++ ) {
const file = this.data.includes[ i ];
$( '' )
.append( $( '' ).text( file.name ) )
.append( $( ' | ' ).text( file.size ).addClass( 'nr' ) )
.appendTo( $table );
}
return $table;
}
};
$( () => {
debug.init();
} );
}() );
| | | |