X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.log.js;h=a3f3c682ebbfd4d2a086a971b963e848fba5c566;hb=2ab15ab41f9efa0a043751915737f0007a2ec63d;hp=969e872d119d340f1aed95135453cce4e2bc5f79;hpb=d568a12d7fbfa5db4db3f7445ff8bf77e9d02f76;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.log.js b/resources/src/mediawiki/mediawiki.log.js index 969e872d11..a3f3c682eb 100644 --- a/resources/src/mediawiki/mediawiki.log.js +++ b/resources/src/mediawiki/mediawiki.log.js @@ -1,74 +1,25 @@ /*! - * Logger for MediaWiki javascript. - * Implements the stub left by the main 'mediawiki' module. + * This file is concatenated to mediawiki.js in debug mode. + * + * See Resources.php. * * @author Michael Dale * @author Trevor Parscal */ - -( function ( mw, $ ) { - - // Keep reference to the dummy placeholder from mediawiki.js - // The root is replaced below, but it has other methods that we need to restore. - var original = mw.log, - slice = Array.prototype.slice; - - mw.log = function () { - // Turn arguments into an array - var args = slice.call( arguments ), - // Allow log messages to use a configured prefix to identify the source window (ie. frame) - prefix = mw.config.exists( 'mw.log.prefix' ) ? mw.config.get( 'mw.log.prefix' ) + '> ' : ''; - - // Try to use an existing console - // Generally we can cache this, but in this case we want to re-evaluate this as a - // global property live so that things like Firebug Lite can take precedence. - if ( window.console && window.console.log && window.console.log.apply ) { - args.unshift( prefix ); - window.console.log.apply( window.console, args ); - return; - } - - // If there is no console, use our own log box - mw.loader.using( 'jquery.footHovzer', function () { - - var hovzer, - d = new Date(), - // Create HH:MM:SS.MIL timestamp - time = ( d.getHours() < 10 ? '0' + d.getHours() : d.getHours() ) + - ':' + ( d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes() ) + - ':' + ( d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds() ) + - '.' + ( d.getMilliseconds() < 10 ? '00' + d.getMilliseconds() : ( d.getMilliseconds() < 100 ? '0' + d.getMilliseconds() : d.getMilliseconds() ) ), - $log = $( '#mw-log-console' ); - - if ( !$log.length ) { - $log = $( '
' ).css( { - overflow: 'auto', - height: '150px', - backgroundColor: 'white', - borderTop: 'solid 2px #ADADAD' - } ); - hovzer = $.getFootHovzer(); - hovzer.$.append( $log ); - hovzer.update(); - } - $log.append( - $( '
' ) - .css( { - borderBottom: 'solid 1px #DDDDDD', - fontSize: 'small', - fontFamily: 'monospace', - whiteSpace: 'pre-wrap', - padding: '0.125em 0.25em' - } ) - .text( prefix + args.join( ', ' ) ) - .prepend( '[' + time + ']' ) - ); - } ); - }; - - // Restore original methods - mw.log.warn = original.warn; - mw.log.error = original.error; - mw.log.deprecate = original.deprecate; - -}( mediaWiki, jQuery ) ); +( function ( mw ) { + /* global console */ + /* eslint-disable no-console */ + var original = mw.log; + + // Replace the mw.log() no-op defined in mediawiki.js, with + // a function that logs to console.log (if available). + if ( window.console && console.log && console.log.apply ) { + mw.log = function () { + console.log.apply( console, arguments ); + }; + // Re-attach original sub methods + mw.log.warn = original.warn; + mw.log.error = original.error; + mw.log.deprecate = original.deprecate; + } +}( mediaWiki ) );