wiki.techinc.nl/resources/src/mediawiki.special/mediawiki.special.javaScriptTest.js
Timo Tijhof 27dd806c6c Omit 'window.' when accessing browsing location
The location object is a global, just like document.

Using it via 'window' needlessly adds complexity and, for example,
makes it harder to catch typos in static analysis.

Also standardise on location.href in place of the many different
variants, like:

 location =
 location.href =
 location.assign() =

And each with 'window', 'document' and without host object.

Change-Id: I77510294d8b5bd4b8a1b08e06817762a7839d43d
2014-11-19 00:13:51 +00:00

36 lines
1 KiB
JavaScript

/*!
* JavaScript for Special:JavaScriptTest
*/
( function ( mw, $ ) {
$( function () {
// Create useskin dropdown menu and reload onchange to the selected skin
// (only if a framework was found, not on error pages).
$( '#mw-javascripttest-summary.mw-javascripttest-frameworkfound' ).append( function () {
var $html = $( '<p><label for="useskin">'
+ mw.message( 'javascripttest-pagetext-skins' ).escaped()
+ ' '
+ '</label></p>' ),
select = '<select name="useskin" id="useskin">';
// Build <select> further
$.each( mw.config.get( 'wgAvailableSkins' ), function ( id ) {
select += '<option value="' + id + '"'
+ ( mw.config.get( 'skin' ) === id ? ' selected="selected"' : '' )
+ '>' + mw.message( 'skinname-' + id ).escaped() + '</option>';
} );
select += '</select>';
// Bind onchange event handler and append to form
$html.append(
$( select ).change( function () {
location.href = QUnit.url( { useskin: $( this ).val() } );
} )
);
return $html;
} );
} );
}( mediaWiki, jQuery ) );