1 /* JavaScript for Special:Block */
3 jQuery( function( $ ) {
6 $blockTarget
= $( '#mw-bi-target' ),
7 $anonOnlyRow
= $( '#mw-input-wpHardBlock' ).closest( 'tr' ),
8 $enableAutoblockRow
= $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
9 $hideUser
= $( '#mw-input-wpHideUser' ).closest( 'tr' ),
10 $watchUser
= $( '#mw-input-wpWatch' ).closest( 'tr' );
12 var updateBlockOptions = function( instant
) {
13 if ( !$blockTarget
.length
) {
17 var blocktarget
= $.trim( $blockTarget
.val() );
18 var isEmpty
= ( blocktarget
=== '' );
19 var isIp
= mw
.util
.isIPv4Address( blocktarget
, true ) || mw
.util
.isIPv6Address( blocktarget
, true );
20 var isIpRange
= isIp
&& blocktarget
.match( /\/\d+$/ );
22 if ( isIp
&& !isEmpty
) {
23 $enableAutoblockRow
.goOut( instant
);
24 $hideUser
.goOut( instant
);
26 $enableAutoblockRow
.goIn( instant
);
27 $hideUser
.goIn( instant
);
29 if ( !isIp
&& !isEmpty
) {
30 $anonOnlyRow
.goOut( instant
);
32 $anonOnlyRow
.goIn( instant
);
34 if ( isIpRange
&& !isEmpty
) {
35 $watchUser
.goOut( instant
);
37 $watchUser
.goIn( instant
);
41 // Bind functions so they're checked whenever stuff changes
42 $blockTarget
.keyup( updateBlockOptions
);
44 // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
45 updateBlockOptions( DO_INSTANT
);