Index: trunk/extensions/UploadWizard/resources/mw.Log.js |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * @param {String} string String to output to console |
10 | 10 | */ |
11 | 11 | mw.log = function( s, level ) { |
12 | | - |
| 12 | + |
13 | 13 | if ( typeof level === 'undefined' ) { |
14 | 14 | level = 30; |
15 | 15 | } |
— | — | @@ -22,60 +22,56 @@ |
23 | 23 | s = mw.log.preAppendLog + s; |
24 | 24 | } |
25 | 25 | |
26 | | - if ( window.console ) { |
| 26 | + if ( typeof window.console !== 'undefined' && typeof window.console.log === 'function' ) { |
27 | 27 | window.console.log( s ); |
28 | 28 | } 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' ); |
46 | 46 | } |
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 | + ); |
56 | 57 | } |
57 | 58 | }; |
58 | | - |
| 59 | + |
59 | 60 | mw.log.level = mw.log.NONE = 0; |
60 | 61 | mw.log.FATAL = 10; |
61 | 62 | mw.log.WARN = 20; |
62 | 63 | mw.log.INFO = 30; |
63 | 64 | mw.log.ALL = 100; |
64 | | - |
| 65 | + |
65 | 66 | mw.log.fatal = function( s ) { |
66 | 67 | mw.log( s, mw.log.FATAL ); |
67 | 68 | }; |
68 | | - |
69 | 69 | mw.log.warn = function( s ) { |
70 | 70 | mw.log( s, mw.log.WARN ); |
71 | 71 | }; |
72 | | - |
73 | 72 | mw.log.info = function( s ) { |
74 | 73 | mw.log( s, mw.log.INFO ); |
75 | 74 | }; |
76 | | - |
77 | 75 | mw.log.level = mw.log.ALL; |
78 | 76 | |
79 | | - mw.logBuffered = ""; |
| 77 | +} )( window.mediaWiki, jQuery ); |
80 | 78 | |
81 | | -} )( window.mw ); |
82 | | - |