User:Emma/common.js: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
mNo edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Prefixindex' ) { | |||
var prefix = $( '#nsfrom' ).val(); | |||
var hideprefixVal = mw.util.getParamValue( 'hideprefix' ); | |||
// ^ Works only 1.17+ | |||
// Replace with a call to a similar function or create one if you're using 1.16 or lower | |||
var $hideprefixLabel = $( '<label/>', { | |||
'for': 'hideprefix', | |||
'text': 'Hide prefix:' | |||
} ); | |||
var $hideprefixInput = $( '<input/>', { | |||
'type': 'checkbox', | |||
'name': 'hideprefix', | |||
'id': 'hideprefix', | |||
'value': '1' | |||
} ); | |||
if ( hideprefixVal == '1' ) { | |||
$hideprefixInput.attr( 'checked', 'checked' ); | |||
} | } | ||
}; | var $hideprefixRow = $( '<tr/>' ) | ||
.append( $( '<td/>', { | |||
'class': 'mw-label', | |||
'html': $hideprefixLabel | |||
} ) ) | |||
.append( $( '<td/>', { | |||
'class': 'mw-input', | |||
'html': $hideprefixInput | |||
} ) ); | |||
// Add checkbox | |||
$( '#nsselect' ).find( ' > tbody:first' ).append( $hideprefixRow ); | |||
// Do it | |||
if ( prefix && hideprefixVal == '1' ) { | |||
$( '#mw-prefixindex-list-table td a' ).text( function( i, val ) { | |||
return val.replace( prefix, '' ); | |||
} ); | |||
} | |||
} |
Revision as of 18:14, November 4, 2011
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Prefixindex' ) { var prefix = $( '#nsfrom' ).val(); var hideprefixVal = mw.util.getParamValue( 'hideprefix' ); // ^ Works only 1.17+ // Replace with a call to a similar function or create one if you're using 1.16 or lower var $hideprefixLabel = $( '<label/>', { 'for': 'hideprefix', 'text': 'Hide prefix:' } ); var $hideprefixInput = $( '<input/>', { 'type': 'checkbox', 'name': 'hideprefix', 'id': 'hideprefix', 'value': '1' } ); if ( hideprefixVal == '1' ) { $hideprefixInput.attr( 'checked', 'checked' ); } var $hideprefixRow = $( '<tr/>' ) .append( $( '<td/>', { 'class': 'mw-label', 'html': $hideprefixLabel } ) ) .append( $( '<td/>', { 'class': 'mw-input', 'html': $hideprefixInput } ) ); // Add checkbox $( '#nsselect' ).find( ' > tbody:first' ).append( $hideprefixRow ); // Do it if ( prefix && hideprefixVal == '1' ) { $( '#mw-prefixindex-list-table td a' ).text( function( i, val ) { return val.replace( prefix, '' ); } ); } }