changing mw.uti functionnames to follow convention + loading $.client as dependency...
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.log.js
1 /*
2 * Implementation for mediaWiki.log stub
3 */
4
5 /**
6 * Log output to the console.
7 *
8 * In the case that the browser does not have a console available, one is created by appending a
9 * <div> element to the bottom of the body and then appending a <div> element to that for each
10 * message.
11 *
12 * @author Michael Dale <mdale@wikimedia.org>
13 * @author Trevor Parscal <tparscal@wikimedia.org>
14 * @param {string} string Message to output to console
15 */
16 mediaWiki.log = function( string ) {
17 // Allow log messages to use a configured prefix
18 if ( mw.config.exists( 'mw.log.prefix' ) ) {
19 string = mw.config.get( 'mw.log.prefix' ) + string;
20 }
21 // Try to use an existing console
22 if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) {
23 window.console.log( string );
24 } else {
25 // Show a log box for console-less browsers
26 var $log = jQuery( '#mw_log_console' );
27 if ( !$log.length ) {
28 $log = jQuery( '<div id="mw_log_console"></div>' )
29 .css( {
30 'position': 'absolute',
31 'overflow': 'auto',
32 'z-index': 500,
33 'bottom': '0px',
34 'left': '0px',
35 'right': '0px',
36 'height': '150px',
37 'background-color': 'white',
38 'border-top': 'solid 1px #DDDDDD'
39 } )
40 .appendTo( jQuery( 'body' ) );
41 }
42 $log.append(
43 jQuery( '<div></div>' )
44 .text( string )
45 .css( {
46 'border-bottom': 'solid 1px #DDDDDD',
47 'font-size': 'small',
48 'font-family': 'monospace',
49 'padding': '0.125em 0.25em'
50 } )
51 );
52 }
53 };