r77116 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77115‎ | r77116 | r77117 >
Date:23:09, 22 November 2010
Author:tparscal
Status:ok
Tags:
Comment:
Ported jQuery-based implementation of console fallback from phase3/resources/mediawiki/mediawiki.log.js - This resolved some IE6/7/8 bugs when the software was loaded in debug mode (enabling the mw.Log.js code).
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.Log.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.Log.js
@@ -8,7 +8,7 @@
99 * @param {String} string String to output to console
1010 */
1111 mw.log = function( s, level ) {
12 -
 12+
1313 if ( typeof level === 'undefined' ) {
1414 level = 30;
1515 }
@@ -22,60 +22,56 @@
2323 s = mw.log.preAppendLog + s;
2424 }
2525
26 - if ( window.console ) {
 26+ if ( typeof window.console !== 'undefined' && typeof window.console.log === 'function' ) {
2727 window.console.log( s );
2828 } else {
29 -
30 - /**
31 - * Old IE and non-Firebug debug
32 - */
33 - var log_elm = document.getElementById('mv_js_log');
34 -
35 - if ( ! log_elm ) {
36 - var body = document.getElementsByTagName("body")[0];
37 - if (body) {
38 - body.innerHTML = document.getElementsByTagName("body")[0].innerHTML +
39 - '<div style="position:absolute;z-index:500;bottom:0px;left:0px;right:0px;height:100px;">'+
40 - '<textarea id="mv_js_log" cols="120" rows="4"></textarea>'+
41 - '</div>';
42 - log_elm = document.getElementById('mv_js_log');
43 - } else {
44 - mw.logBuffered += s + "\n";
45 - }
 29+ // Show a log box for console-less browsers
 30+ var $log = $( '#mw-log-console' );
 31+ if ( !$log.length ) {
 32+ $log = $( '<div id="mw-log-console"></div>' )
 33+ .css( {
 34+ 'position': 'absolute',
 35+ 'overflow': 'auto',
 36+ 'z-index': 500,
 37+ 'bottom': '0px',
 38+ 'left': '0px',
 39+ 'right': '0px',
 40+ 'height': '100px',
 41+ 'width': '100%',
 42+ 'background-color': 'white',
 43+ 'border-top': 'solid 2px #ADADAD'
 44+ } )
 45+ .appendTo( 'body' );
4646 }
47 -
48 - if ( log_elm ) {
49 - if (mw.logBuffered.length) {
50 - log_elm.value += mw.logBuffered;
51 - mw.logBuffered = "";
52 - }
53 - log_elm.value += s + "\n";
54 - }
55 -
 47+ $log.append(
 48+ $( '<div></div>' )
 49+ .css( {
 50+ 'border-bottom': 'solid 1px #DDDDDD',
 51+ 'font-size': 'small',
 52+ 'font-family': 'monospace',
 53+ 'padding': '0.125em 0.25em'
 54+ } )
 55+ .text( s )
 56+ );
5657 }
5758 };
58 -
 59+
5960 mw.log.level = mw.log.NONE = 0;
6061 mw.log.FATAL = 10;
6162 mw.log.WARN = 20;
6263 mw.log.INFO = 30;
6364 mw.log.ALL = 100;
64 -
 65+
6566 mw.log.fatal = function( s ) {
6667 mw.log( s, mw.log.FATAL );
6768 };
68 -
6969 mw.log.warn = function( s ) {
7070 mw.log( s, mw.log.WARN );
7171 };
72 -
7372 mw.log.info = function( s ) {
7473 mw.log( s, mw.log.INFO );
7574 };
76 -
7775 mw.log.level = mw.log.ALL;
7876
79 - mw.logBuffered = "";
 77+} )( window.mediaWiki, jQuery );
8078
81 -} )( window.mw );
82 -

Status & tagging log