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 ) {
33 }, 'Use jQuery instead
.' );
36 * Wikipage import methods
38 * See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js
42 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
44 * @return {HTMLElement} Script tag
46 function importScriptURI( url ) {
48 if ( loadedScripts[ url ] ) {
51 loadedScripts[ url ] = true;
52 s = document.createElement( 'script
' );
53 s.setAttribute( 'src
', url );
54 document.head.appendChild( s );
58 function importScript( page ) {
59 var uri = mw.config.get( 'wgScript
' ) + '?title
=' + wikiUrlencode( page ) +
60 '&action
=raw
&ctype
=text
/javascript
';
61 return importScriptURI( uri );
65 * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.25.
67 * @param {string} media
68 * @return {HTMLElement} Link tag
70 function importStylesheetURI( url, media ) {
71 var l = document.createElement( 'link
' );
77 document.head.appendChild( l );
81 function importStylesheet( page ) {
82 var uri = mw.config.get( 'wgScript
' ) + '?title
=' + wikiUrlencode( page ) +
83 '&action
=raw
&ctype
=text
/css
';
84 return importStylesheetURI( uri );
87 msg = 'Use mw
.loader instead
.';
88 mw.log.deprecate( window, 'loadedScripts
', loadedScripts, msg );
89 mw.log.deprecate( window, 'importScriptURI
', importScriptURI, msg );
90 mw.log.deprecate( window, 'importStylesheetURI
', importStylesheetURI, msg );
91 // Not quite deprecated yet.
92 window.importScript = importScript;
93 window.importStylesheet = importStylesheet;
96 * Replace document.write/writeln with basic html parsing that appends
97 * to the <body> to avoid blanking pages. Added JavaScript will not run.
99 * @deprecated since 1.26
101 [ 'write
', 'writeln
' ].forEach( function ( method ) {
102 mw.log.deprecate( document, method, function () {
103 $( 'body
' ).append( $.parseHTML( Array.prototype.join.call( arguments, '' ) ) );
104 }, 'Use jQuery or mw
.loader
.load instead
.', 'document
.' + method );