2 * MediaWiki legacy wikibits
8 function wikiUrlencode( page
) {
9 return encodeURIComponent( String( page
) )
10 .replace( /'/g, '%27' )
11 .replace( /%20/g, '_
' )
12 // wfUrlencode replacements
13 .replace( /%3B/g, ';' )
14 .replace( /%40/g, '@' )
15 .replace( /%24/g, '$' )
16 .replace( /%21/g, '!' )
17 .replace( /%2A/g, '*' )
18 .replace( /%28/g, '(' )
19 .replace( /%29/g, ')' )
20 .replace( /%2C/g, ',' )
21 .replace( /%2F/g, '/' )
22 .replace( /%7E/g, '~' )
23 .replace( /%3A/g, ':' );
27 * @deprecated since 1.17 Use jQuery instead
29 mw.log.deprecate( window, 'addOnloadHook
', function ( fn ) {
30 $( function () { fn(); } );
31 }, 'Use jQuery instead
.' );
34 * Wikipage import methods
36 * See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js
40 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
42 * @return {HTMLElement} Script tag
44 function importScriptURI( url ) {
46 if ( loadedScripts[ url ] ) {
49 loadedScripts[ url ] = true;
50 s = document.createElement( 'script
' );
51 s.setAttribute( 'src
', url );
52 document.head.appendChild( s );
56 function importScript( page ) {
57 var uri = mw.config.get( 'wgScript
' ) + '?title
=' + wikiUrlencode( page ) +
58 '&action
=raw
&ctype
=text
/javascript
';
59 return importScriptURI( uri );
63 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
65 * @param {string} media
66 * @return {HTMLElement} Link tag
68 function importStylesheetURI( url, media ) {
69 var l = document.createElement( 'link
' );
75 document.head.appendChild( l );
79 function importStylesheet( page ) {
80 var uri = mw.config.get( 'wgScript
' ) + '?title
=' + wikiUrlencode( page ) +
81 '&action
=raw
&ctype
=text
/css
';
82 return importStylesheetURI( uri );
85 msg = 'Use mw
.loader instead
.';
86 mw.log.deprecate( window, 'loadedScripts
', loadedScripts, msg );
87 mw.log.deprecate( window, 'importScriptURI
', importScriptURI, msg );
88 mw.log.deprecate( window, 'importStylesheetURI
', importStylesheetURI, msg );
89 // Not quite deprecated yet.
90 window.importScript = importScript;
91 window.importStylesheet = importStylesheet;
94 * Replace document.write/writeln with basic html parsing that appends
95 * to the <body> to avoid blanking pages. Added JavaScript will not run.
97 * @deprecated since 1.26
99 [ 'write
', 'writeln
' ].forEach( function ( method ) {
100 mw.log.deprecate( document, method, function () {
101 $( 'body
' ).append( $.parseHTML( Array.prototype.join.call( arguments, '' ) ) );
102 }, 'Use jQuery or mw
.loader
.load instead
.', 'document
.' + method );
105 }( mediaWiki, jQuery ) );