Index: branches/wmf/1.18wmf1/resources/mediawiki/mediawiki.debug.css |
— | — | @@ -0,0 +1,111 @@ |
| 2 | +.mw-debug { |
| 3 | + width: 100%; |
| 4 | + text-align: left; |
| 5 | + position: fixed; |
| 6 | + bottom: 0; |
| 7 | + background-color: #eee; |
| 8 | + border-top: 1px solid #ccc; |
| 9 | +} |
| 10 | + |
| 11 | +.mw-debug pre { |
| 12 | + font-family: Monaco, "Consolas", "Lucida Console", "Courier New", monospace; |
| 13 | + font-size: 11px; |
| 14 | + padding: 0; |
| 15 | + margin: 0; |
| 16 | + background: none; |
| 17 | + border: none; |
| 18 | +} |
| 19 | + |
| 20 | +.mw-debug ul { |
| 21 | + margin: 0; |
| 22 | + list-style: none; |
| 23 | + box-sizing: border-box; |
| 24 | +} |
| 25 | + |
| 26 | +.mw-debug li { |
| 27 | + padding: 2px 5px; |
| 28 | + width: 100%; |
| 29 | + display: table; |
| 30 | +} |
| 31 | + |
| 32 | +.mw-debug-bit { |
| 33 | + min-height: 25px; |
| 34 | + display: inline-block; |
| 35 | + padding: 5px; |
| 36 | + border-right: 1px solid #ccc; |
| 37 | + font-size: 13px; |
| 38 | +} |
| 39 | + |
| 40 | +.mw-debug-pane { |
| 41 | + max-height: 300px; |
| 42 | + overflow: scroll; |
| 43 | + border-top: 2px solid #ccc; |
| 44 | + display: none; |
| 45 | + font-size: 11px; |
| 46 | + background-color: #e1eff2; |
| 47 | + box-sizing: border-box; |
| 48 | +} |
| 49 | + |
| 50 | +.mw-debug-right { |
| 51 | + float: right; |
| 52 | +} |
| 53 | + |
| 54 | +#mw-debug-querylist tr { |
| 55 | + |
| 56 | +} |
| 57 | + |
| 58 | +#mw-debug-querylist td { |
| 59 | + padding: 2px 5px; |
| 60 | + border-bottom: 1px solid #ccc; |
| 61 | +} |
| 62 | + |
| 63 | +.mw-debug-query-time { |
| 64 | + color: #808080; |
| 65 | +} |
| 66 | + |
| 67 | +#mw-debug-pane-request { |
| 68 | + padding: 20px; |
| 69 | +} |
| 70 | + |
| 71 | +#mw-debug-pane-request table { |
| 72 | + width: 100%; |
| 73 | + margin: 10px 0 30px; |
| 74 | +} |
| 75 | + |
| 76 | +#mw-debug-pane-request tr, |
| 77 | +#mw-debug-pane-request th, |
| 78 | +#mw-debug-pane-request td, |
| 79 | +#mw-debug-pane-request table { |
| 80 | + border: 1px solid #D0DBB3; |
| 81 | + border-collapse: collapse; |
| 82 | + margin: 0; |
| 83 | +} |
| 84 | + |
| 85 | +#mw-debug-pane-request th, |
| 86 | +#mw-debug-pane-request td { |
| 87 | + font-size: 12px; |
| 88 | + padding: 8px 10px; |
| 89 | +} |
| 90 | + |
| 91 | +#mw-debug-pane-request th { |
| 92 | + background-color: #F1F7E2; |
| 93 | + font-weight: bold; |
| 94 | +} |
| 95 | + |
| 96 | +#mw-debug-pane-request td { |
| 97 | + background-color: white; |
| 98 | +} |
| 99 | + |
| 100 | +#mw-debug-pane-querylist table { |
| 101 | + border-spacing: 0; |
| 102 | +} |
| 103 | + |
| 104 | +#mw-debug-pane-includes li, |
| 105 | +#mw-debug-pane-querylist tr td { |
| 106 | + background-color: #ccc; |
| 107 | +} |
| 108 | + |
| 109 | +#mw-debug-pane-includes li:nth-child(odd), |
| 110 | +#mw-debug-pane-querylist tr:nth-child(odd) td { |
| 111 | + background-color: #ddd; |
| 112 | +} |
Property changes on: branches/wmf/1.18wmf1/resources/mediawiki/mediawiki.debug.css |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 113 | + native |
Index: branches/wmf/1.18wmf1/resources/mediawiki/mediawiki.debug.js |
— | — | @@ -0,0 +1,257 @@ |
| 2 | +/** |
| 3 | + * Javascript for the new debug toolbar, enabled with $wgDebugToolbar |
| 4 | + * |
| 5 | + * @author John Du Hart |
| 6 | + * @since 1.19 |
| 7 | + */ |
| 8 | + |
| 9 | +( function( $ ) { |
| 10 | + |
| 11 | + var debug = mw.Debug = { |
| 12 | + /** |
| 13 | + * Toolbar container element |
| 14 | + * |
| 15 | + * @var {jQuery} |
| 16 | + */ |
| 17 | + $container: null, |
| 18 | + |
| 19 | + /** |
| 20 | + * Array containing data for the debug toolbar |
| 21 | + * |
| 22 | + * @var {Array} |
| 23 | + */ |
| 24 | + data: {}, |
| 25 | + |
| 26 | + /** |
| 27 | + * Initializes the debugging pane |
| 28 | + * |
| 29 | + * @param {Array} data |
| 30 | + */ |
| 31 | + init: function( data ) { |
| 32 | + this.data = data; |
| 33 | + this.buildHtml(); |
| 34 | + |
| 35 | + // Insert the container into the DOM |
| 36 | + $( 'body' ).append( this.$container ); |
| 37 | + |
| 38 | + $( '.mw-debug-panelink' ).click( this.switchPane ); |
| 39 | + }, |
| 40 | + |
| 41 | + /** |
| 42 | + * Switches between panes |
| 43 | + * |
| 44 | + * @todo Store cookie for last pane open |
| 45 | + * @context {Element} |
| 46 | + * @param {jQuery.Event} e |
| 47 | + */ |
| 48 | + switchPane: function( e ) { |
| 49 | + var currentPaneId = debug.$container.data( 'currentPane' ), |
| 50 | + requestedPaneId = $(this).parent().attr( 'id' ).substr( 9 ), |
| 51 | + $currentPane = $( '#mw-debug-pane-' + currentPaneId ), |
| 52 | + $requestedPane = $( '#mw-debug-pane-' + requestedPaneId ); |
| 53 | + e.preventDefault(); |
| 54 | + |
| 55 | + // Hide the current pane |
| 56 | + if ( requestedPaneId === currentPaneId ) { |
| 57 | + $currentPane.slideUp(); |
| 58 | + debug.$container.data( 'currentPane', null ); |
| 59 | + return; |
| 60 | + } |
| 61 | + |
| 62 | + debug.$container.data( 'currentPane', requestedPaneId ); |
| 63 | + |
| 64 | + if ( currentPaneId === undefined || currentPaneId === null ) { |
| 65 | + $requestedPane.slideDown(); |
| 66 | + } else { |
| 67 | + $currentPane.hide(); |
| 68 | + $requestedPane.show(); |
| 69 | + } |
| 70 | + }, |
| 71 | + |
| 72 | + /** |
| 73 | + * Constructs the HTML for the debugging toolbar |
| 74 | + */ |
| 75 | + buildHtml: function() { |
| 76 | + var $container = this.$container = $( '<div></div>' ) |
| 77 | + .attr({ |
| 78 | + id: 'mw-debug-container', |
| 79 | + class: 'mw-debug' |
| 80 | + }); |
| 81 | + |
| 82 | + /** |
| 83 | + * Returns a jQuery element for a debug-bit div |
| 84 | + * |
| 85 | + * @param id |
| 86 | + * @return {jQuery} |
| 87 | + */ |
| 88 | + var bitDiv = function( id ) { |
| 89 | + return $( '<div></div>' ).attr({ |
| 90 | + id: 'mw-debug-' + id, |
| 91 | + class: 'mw-debug-bit' |
| 92 | + }); |
| 93 | + }; |
| 94 | + /** |
| 95 | + * Returns a jQuery element for a pane link |
| 96 | + * |
| 97 | + * @param id |
| 98 | + * @param text |
| 99 | + * @return {jQuery} |
| 100 | + */ |
| 101 | + var paneLink = function( id, text ) { |
| 102 | + return $( '<a></a>' ) |
| 103 | + .attr({ |
| 104 | + href: '#', |
| 105 | + class: 'mw-debug-panelink', |
| 106 | + id: 'mw-debug-' + id + '-link' |
| 107 | + }) |
| 108 | + .text( text ); |
| 109 | + } |
| 110 | + |
| 111 | + bitDiv( 'mwversion' ) |
| 112 | + .append( $( '<a href="https://www.mediawiki.org//www.mediawiki.org/">' ).text( 'MediaWiki' ) ) |
| 113 | + .append( ': ' + this.data.mwVersion ) |
| 114 | + .appendTo( $container ); |
| 115 | + |
| 116 | + bitDiv( 'phpversion' ) |
| 117 | + .append( $( '<a href="https://www.mediawiki.org//www.php.net/">' ).text( 'PHP' ) ) |
| 118 | + .append( ': ' + this.data.phpVersion ) |
| 119 | + .appendTo( $container ); |
| 120 | + |
| 121 | + bitDiv( 'time' ) |
| 122 | + .text( 'Time: ' + this.data.time.toFixed( 5 ) ) |
| 123 | + .appendTo( $container ); |
| 124 | + bitDiv( 'memory' ) |
| 125 | + .text( 'Memory: ' + this.data.memory ) |
| 126 | + .append( $( '<span title="Peak usage"></span>' ).text( ' (' + this.data.memoryPeak + ')' ) ) |
| 127 | + .appendTo( $container ); |
| 128 | + |
| 129 | + bitDiv( 'querylist' ) |
| 130 | + .append( paneLink( 'query', 'Queries: ' + this.data.queries.length ) ) |
| 131 | + .appendTo( $container ); |
| 132 | + |
| 133 | + bitDiv( 'debuglog' ) |
| 134 | + .append( paneLink( 'debuglog', 'Debug Log (' + this.data.debugLog.length + ' lines)' ) ) |
| 135 | + .appendTo( $container ); |
| 136 | + |
| 137 | + bitDiv( 'request' ) |
| 138 | + .append( paneLink( 'request', 'Request' ) ) |
| 139 | + .appendTo( $container ); |
| 140 | + |
| 141 | + bitDiv( 'includes' ) |
| 142 | + .append( paneLink( 'files-includes', this.data.includes.length + ' Files Included' ) ) |
| 143 | + .appendTo( $container ); |
| 144 | + |
| 145 | + var panes = { |
| 146 | + 'querylist': this.buildQueryTable(), |
| 147 | + 'debuglog': this.buildDebugLogTable(), |
| 148 | + 'request': this.buildRequestPane(), |
| 149 | + 'includes': this.buildIncludesPane() |
| 150 | + }; |
| 151 | + |
| 152 | + for ( var id in panes ) { |
| 153 | + if ( !panes.hasOwnProperty( id ) ) { |
| 154 | + continue; |
| 155 | + } |
| 156 | + |
| 157 | + $( '<div></div>' ) |
| 158 | + .attr({ |
| 159 | + class: 'mw-debug-pane', |
| 160 | + id: 'mw-debug-pane-' + id |
| 161 | + }) |
| 162 | + .append( panes[id] ) |
| 163 | + .appendTo( $container ); |
| 164 | + } |
| 165 | + }, |
| 166 | + |
| 167 | + /** |
| 168 | + * Query list pane |
| 169 | + */ |
| 170 | + buildQueryTable: function() { |
| 171 | + var $table = $( '<table id="mw-debug-querylist"></table>' ); |
| 172 | + |
| 173 | + for ( var i = 0, length = this.data.queries.length; i < length; i++ ) { |
| 174 | + var query = this.data.queries[i]; |
| 175 | + |
| 176 | + $( '<tr>' ) |
| 177 | + .append( $( '<td>' ).text( i + 1 ) ) |
| 178 | + .append( $( '<td>' ).text( query.sql ) ) |
| 179 | + .append( $( '<td>' ) |
| 180 | + .append( $( '<span class="mw-debug-query-time">' ).text( '(' + query.time.toFixed( 4 ) + 'ms) ' ) ) |
| 181 | + .append( query['function'] ) |
| 182 | + ) |
| 183 | + .appendTo( $table ); |
| 184 | + } |
| 185 | + |
| 186 | + return $table; |
| 187 | + }, |
| 188 | + |
| 189 | + /** |
| 190 | + * Legacy debug log pane |
| 191 | + */ |
| 192 | + buildDebugLogTable: function() { |
| 193 | + var $list = $( '<ul>' ); |
| 194 | + |
| 195 | + for ( var i = 0, length = this.data.debugLog.length; i < length; i++ ) { |
| 196 | + var line = this.data.debugLog[i]; |
| 197 | + $( '<li>' ) |
| 198 | + .html( mw.html.escape( line ).replace( /\n/g, "<br />\n" ) ) |
| 199 | + .appendTo( $list ); |
| 200 | + } |
| 201 | + |
| 202 | + return $list; |
| 203 | + }, |
| 204 | + |
| 205 | + /** |
| 206 | + * Request information pane |
| 207 | + */ |
| 208 | + buildRequestPane: function() { |
| 209 | + var buildTable = function( title, data ) { |
| 210 | + var $unit = $( '<div></div>' ) |
| 211 | + .append( $( '<h2>' ).text( title ) ); |
| 212 | + |
| 213 | + var $table = $( '<table>' ).appendTo( $unit ); |
| 214 | + |
| 215 | + $( '<tr>' ) |
| 216 | + .html( '<th>Key</th> <th>Value</th>' ) |
| 217 | + .appendTo( $table ); |
| 218 | + |
| 219 | + for ( var key in data ) { |
| 220 | + if ( !data.hasOwnProperty( key ) ) { |
| 221 | + continue; |
| 222 | + } |
| 223 | + |
| 224 | + $( '<tr>' ) |
| 225 | + .append( $( '<th>' ).text( key ) ) |
| 226 | + .append( $( '<td>' ).text( data[key] ) ) |
| 227 | + .appendTo( $table ); |
| 228 | + } |
| 229 | + |
| 230 | + return $unit; |
| 231 | + }; |
| 232 | + |
| 233 | + var $pane = $( '<div>' ) |
| 234 | + .text( this.data.request.method + ' ' + this.data.request.url ) |
| 235 | + .append( buildTable( 'Headers', this.data.request.headers ) ) |
| 236 | + .append( buildTable( 'Parameters', this.data.request.params ) ); |
| 237 | + return $pane; |
| 238 | + }, |
| 239 | + |
| 240 | + /** |
| 241 | + * Included files pane |
| 242 | + */ |
| 243 | + buildIncludesPane: function() { |
| 244 | + var $list = $( '<ul>' ) |
| 245 | + |
| 246 | + for ( var i = 0, l = this.data.includes.length; i < l; i++ ) { |
| 247 | + var file = this.data.includes[i]; |
| 248 | + $( '<li>' ) |
| 249 | + .text( file.name ) |
| 250 | + .prepend( $( '<span class="mw-debug-right">' ).text( file.size ) ) |
| 251 | + .appendTo( $list ); |
| 252 | + } |
| 253 | + |
| 254 | + return $list; |
| 255 | + } |
| 256 | + }; |
| 257 | + |
| 258 | +} )( jQuery ); |
\ No newline at end of file |
Property changes on: branches/wmf/1.18wmf1/resources/mediawiki/mediawiki.debug.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 259 | + native |