Don't dupe/drop parts of searchindex on SQLite
[lhc/web/wiklou.git] / resources / mediawiki / mediawiki.log.js
1 /*
2 * Implementation for mediaWiki.log stub
3 */
4
5 (function ($) {
6
7 /**
8 * Log output to the console.
9 *
10 * In the case that the browser does not have a console available, one is created by appending a
11 * <div> element to the bottom of the body and then appending a <div> element to that for each
12 * message.
13 *
14 * @author Michael Dale <mdale@wikimedia.org>
15 * @author Trevor Parscal <tparscal@wikimedia.org>
16 * @param {string} string Message to output to console
17 */
18 mw.log = function( string ) {
19 // Allow log messages to use a configured prefix
20 if ( mw.config.exists( 'mw.log.prefix' ) ) {
21 string = mw.config.get( 'mw.log.prefix' ) + '> ' + string;
22 }
23 // Try to use an existing console
24 if ( typeof window.console !== 'undefined' && typeof window.console.log == 'function' ) {
25 console.log( string );
26 } else {
27 // Set timestamp
28 var d = new Date();
29 var time = ( d.getHours() < 10 ? '0' + d.getHours() : d.getHours() ) +
30 ':' + ( d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes() ) +
31 ':' + ( d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds() ) +
32 '.' + ( d.getMilliseconds() < 10 ? '00' + d.getMilliseconds() : ( d.getMilliseconds() < 100 ? '0' + d.getMilliseconds() : d.getMilliseconds() ) );
33 // Show a log box for console-less browsers
34 var $log = $( '#mw-log-console' );
35 if ( !$log.length ) {
36 $log = $( '<div id="mw-log-console"></div>' )
37 .css( {
38 'position': 'fixed',
39 'overflow': 'auto',
40 'z-index': 500,
41 'bottom': '0px',
42 'left': '0px',
43 'right': '0px',
44 'height': '150px',
45 'background-color': 'white',
46 'border-top': 'solid 2px #ADADAD'
47 } )
48 .appendTo( 'body' );
49 }
50 $log.append(
51 $( '<div></div>' )
52 .css( {
53 'border-bottom': 'solid 1px #DDDDDD',
54 'font-size': 'small',
55 'font-family': 'monospace',
56 'padding': '0.125em 0.25em'
57 } )
58 .text( string )
59 .append( '<span style="float:right">[' + time + ']</span>' )
60 );
61 }
62 };
63
64 })(jQuery);