dbg toolbar: makes pane title consistent
authorAntoine Musso <hashar@users.mediawiki.org>
Tue, 17 Jan 2012 10:10:21 +0000 (10:10 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Tue, 17 Jan 2012 10:10:21 +0000 (10:10 +0000)
Example output:
Console (1) | Queries (45) | Debug Log (21) | Request | PHP includes (131)

A null / undefined / 0 value will skip the parentheses output.

resources/mediawiki/mediawiki.debug.js

index f25d249..39244ba 100644 (file)
                        /**
                         * Returns a jQuery element for a debug-bit div with a for a pane link
                         *
-                        * @param id
+                        * @param id CSS id snippet. Will be prefixed with 'mw-debug-'
+                        * @param text Text to show
+                        * @param count Optional count to show
                         * @return {jQuery}
                         */
-                       function paneTriggerBitDiv( id, text ) {
+                       function paneTriggerBitDiv( id, text, count ) {
+                               if( count ) {
+                                       text = text + ' (' + count + ')';
+                               }
                                return $( '<div>' ).attr({
                                        id: 'mw-debug-' + id,
                                        'class': 'mw-debug-bit mw-debug-panelink'
                                .appendTo( $bits );
                        }
 
-                       paneTriggerBitDiv( 'console', 'Console (' + this.data.log.length + ')' );
+                       paneTriggerBitDiv( 'console', 'Console', this.data.log.length );
 
-                       paneTriggerBitDiv( 'querylist', 'Queries: ' + this.data.queries.length );
+                       paneTriggerBitDiv( 'querylist', 'Queries', this.data.queries.length );
 
-                       paneTriggerBitDiv( 'debuglog', 'Debug Log (' + this.data.debugLog.length + ' lines)' );
+                       paneTriggerBitDiv( 'debuglog', 'Debug Log', this.data.debugLog.length );
 
                        paneTriggerBitDiv( 'request', 'Request' );
 
-                       paneTriggerBitDiv( 'includes', this.data.includes.length + ' Files Included' );
+                       paneTriggerBitDiv( 'includes', 'PHP includes', this.data.includes.length );
 
                        bitDiv( 'mwversion' )
                                .append( $( '<a href="//www.mediawiki.org/"></a>' ).text( 'MediaWiki' ) )