User:Majr/scriptLoader.js

( function( mcw ) { 'use strict';

if ( !mcw.scriptLoaderPages ) { return; }

var options = [ $( ' ' ).text( 'Select script' ).css( 'display', 'none' ) ]; $.each( mcw.scriptLoaderPages, function {	options.push( $( ' ' ).text( this ) ); } );

var loading; $( '.t-netbar-userInfo' ).prepend(	$( ' ' ).addClass( 't-netbar-section script-loader' ).on( 'change', function { var $select = $( this ); var page = $select.val; if ( page.match( /^\// ) ) { page = 'User:' + mw.config.get( 'wgUserName' ) + page; }		var url = mw.config.get( 'wgScript' ) + '?' + $.param( {			title: page,			action: 'raw',			ctype: 'text/javascript'		} ); $.when( loading ).done( function {			loading = $.getScript( url ).done( function { $select.val( 'Select script' ); } );		} );	} ).append( options ) );

}( window.mcw || {} ) );