var msg,
win = window,
ua = navigator.userAgent.toLowerCase(),
- onloadFuncts = [];
+ onloadFuncts = [],
+ loadedScripts = {};
/**
* User-agent sniffing.
/**
* Wikipage import methods
+ *
+ * See https://www.mediawiki.org/wiki/ResourceLoader/Legacy_JavaScript#wikibits.js
+ *
+ * @deprecated since 1.17 Use mw.loader instead. Warnings added in 1.26.
*/
- // included-scripts tracker
- win.loadedScripts = {};
-
- win.importScript = function ( page ) {
+ function importScript( page ) {
var uri = mw.config.get( 'wgScript' ) + '?title=' +
mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/javascript';
- return win.importScriptURI( uri );
- };
+ return importScriptURI( uri );
+ }
- win.importScriptURI = function ( url ) {
- if ( win.loadedScripts[url] ) {
+ function importScriptURI( url ) {
+ if ( loadedScripts[url] ) {
return null;
}
- win.loadedScripts[url] = true;
+ loadedScripts[url] = true;
var s = document.createElement( 'script' );
s.setAttribute( 'src', url );
s.setAttribute( 'type', 'text/javascript' );
document.getElementsByTagName( 'head' )[0].appendChild( s );
return s;
- };
+ }
- win.importStylesheet = function ( page ) {
+ function importStylesheet( page ) {
var uri = mw.config.get( 'wgScript' ) + '?title=' +
mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/css';
- return win.importStylesheetURI( uri );
- };
+ return importStylesheetURI( uri );
+ }
- win.importStylesheetURI = function ( url, media ) {
+ function importStylesheetURI( url, media ) {
var l = document.createElement( 'link' );
l.rel = 'stylesheet';
l.href = url;
}
document.getElementsByTagName( 'head' )[0].appendChild( l );
return l;
- };
+ }
+
+ msg = 'Use mw.loader instead.';
+ mw.log.deprecate( win, 'loadedScripts', loadedScripts, msg );
+ mw.log.deprecate( win, 'importScript', importScript, msg );
+ mw.log.deprecate( win, 'importScriptURI', importScriptURI, msg );
+ mw.log.deprecate( win, 'importStylesheet', importStylesheet, msg );
+ mw.log.deprecate( win, 'importStylesheetURI', importStylesheetURI, msg );
}( mediaWiki, jQuery ) );