http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76326

Revision: 76326
Author:   krinkle
Date:     2010-11-08 19:30:53 +0000 (Mon, 08 Nov 2010)
Log Message:
-----------
* Following id-naming, underscore to dash 
* Wrapping mw.log in jQuery/mediaWiki
* Making mw-log-console fixed position instead of absolute (to no longer have 
it floating on top of the page after scrolling down)
* Added timestamp
* Changed inline styling to stylesheet

Modified Paths:
--------------
    trunk/phase3/resources/Resources.php
    trunk/phase3/resources/mediawiki/mediawiki.log.js

Modified: trunk/phase3/resources/Resources.php
===================================================================
--- trunk/phase3/resources/Resources.php        2010-11-08 18:45:57 UTC (rev 
76325)
+++ trunk/phase3/resources/Resources.php        2010-11-08 19:30:53 UTC (rev 
76326)
@@ -323,6 +323,11 @@
                'debugScripts' => 'resources/mediawiki/mediawiki.log.js',
                'debugRaw' => false
        ) ),
+       'mediawiki.util' => new ResourceLoaderFileModule( array(
+               'scripts' => 'resources/mediawiki.util/mediawiki.util.js',
+               'dependencies' => array( 'jquery.checkboxShiftClick', 
'jquery.client' ),
+               'debugScripts' => 
'resources/mediawiki.util/mediawiki.util.test.js',
+       ) ),
        'mediawiki.advanced.rightclickedit' => new ResourceLoaderFileModule( 
array(
                'scripts' => 
'resources/mediawiki.advanced/mediawiki.advanced.rightclickedit.js',
        ) ),
@@ -387,11 +392,6 @@
                        'wa' => 'resources/mediawiki.language/languages/wa.js',
                ),
        ) ),
-       'mediawiki.util' => new ResourceLoaderFileModule( array(
-               'scripts' => 'resources/mediawiki.util/mediawiki.util.js',
-               'dependencies' => array( 'jquery.checkboxShiftClick', 
'jquery.client' ),
-               'debugScripts' => 
'resources/mediawiki.util/mediawiki.util.test.js',
-       ) ),
        
        /* mediawiki Legacy */
        

Modified: trunk/phase3/resources/mediawiki/mediawiki.log.js
===================================================================
--- trunk/phase3/resources/mediawiki/mediawiki.log.js   2010-11-08 18:45:57 UTC 
(rev 76325)
+++ trunk/phase3/resources/mediawiki/mediawiki.log.js   2010-11-08 19:30:53 UTC 
(rev 76326)
@@ -2,52 +2,63 @@
  * Implementation for mediaWiki.log stub
  */
 
-/**
- * Log output to the console.
- * 
- * In the case that the browser does not have a console available, one is 
created by appending a
- * <div> element to the bottom of the body and then appending a <div> element 
to that for each
- * message.
- *
- * @author Michael Dale <[email protected]>
- * @author Trevor Parscal <[email protected]>
- * @param {string} string Message to output to console
- */
-mediaWiki.log = function( string ) {
-       // Allow log messages to use a configured prefix                
-       if ( mw.config.exists( 'mw.log.prefix' ) ) {
-               string = mw.config.get( 'mw.log.prefix' ) + string;             
-       }
-       // Try to use an existing console
-       if ( typeof window.console !== 'undefined' && typeof window.console.log 
== 'function' ) {
-               window.console.log( string );
-       } else {
-               // Show a log box for console-less browsers
-               var $log = jQuery( '#mw_log_console' );
-               if ( !$log.length ) {
-                       $log = jQuery( '<div id="mw_log_console"></div>' )
-                               .css( {
-                                       'position': 'absolute',
-                                       'overflow': 'auto',
-                                       'z-index': 500,
-                                       'bottom': '0px',
-                                       'left': '0px',
-                                       'right': '0px',
-                                       'height': '150px',
-                                       'background-color': 'white',
-                                       'border-top': 'solid 1px #DDDDDD'
-                               } )
-                               .appendTo( jQuery( 'body' ) );
+(function ($, mw) {
+
+       /**
+        * Log output to the console.
+        * 
+        * In the case that the browser does not have a console available, one 
is created by appending a
+        * <div> element to the bottom of the body and then appending a <div> 
element to that for each
+        * message.
+        *
+        * @author Michael Dale <[email protected]>
+        * @author Trevor Parscal <[email protected]>
+        * @param {string} string Message to output to console
+        */
+       mediaWiki.log = function( string ) {
+               // Allow log messages to use a configured prefix                
+               if ( mw.config.exists( 'mw.log.prefix' ) ) {
+                       string = mw.config.get( 'mw.log.prefix' ) + '> ' + 
string;              
                }
-               $log.append(
-                       jQuery( '<div></div>' )
-                               .text( string )
-                               .css( {
-                                       'border-bottom': 'solid 1px #DDDDDD',
-                                       'font-size': 'small',
-                                       'font-family': 'monospace',
-                                       'padding': '0.125em 0.25em'
-                               } )
-               );
-       }
-};
+               // Try to use an existing console
+               if ( typeof window.console !== 'undefined' && typeof 
window.console.log !== 'function' ) {
+                       window.console.log( string );
+               } else {
+                       // Set timestamp
+                       var d = new Date();
+                       var 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() < 100 ? '0' + 
d.getMilliseconds() : d.getMilliseconds() );
+                       // Show a log box for console-less browsers
+                       var $log = $( '#mw-log-console' );
+                       if ( !$log.length ) {
+                               $log = $( '<div id="mw-log-console"></div>' )
+                                       .css( {
+                                               'position': 'absolute',
+                                               'overflow': 'auto',
+                                               'z-index': 500,
+                                               'bottom': '0px',
+                                               'left': '0px',
+                                               'right': '0px',
+                                               'height': '150px',
+                                               'background-color': 'white',
+                                               'border-top': 'solid 2px 
#ADADAD'
+                                       } )
+                                       .appendTo( 'body' );
+                       }
+                       $log.append(
+                               $( '<div></div>' )
+                                       .css( {
+                                               'border-bottom': 'solid 1px 
#DDDDDD',
+                                               'font-size': 'small',
+                                               'font-family': 'monospace',
+                                               'padding': '0.125em 0.25em'
+                                       } )
+                                       .text( string )
+                                       .append( '<span style="float:right">[' 
+ time + ']</span>' )
+                       );
+               }
+       };
+
+})(jQuery, mediaWiki);


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to