2 * JavaScript for Special:Block
7 var $blockTarget
= $( '#mw-bi-target' ),
8 $anonOnlyRow
= $( '#mw-input-wpHardBlock' ).closest( 'tr' ),
9 $enableAutoblockRow
= $( '#mw-input-wpAutoBlock' ).closest( 'tr' ),
10 $hideUser
= $( '#mw-input-wpHideUser' ).closest( 'tr' ),
11 $watchUser
= $( '#mw-input-wpWatch' ).closest( 'tr' );
13 function updateBlockOptions( instant
) {
14 if ( !$blockTarget
.length
) {
18 var blocktarget
= $.trim( $blockTarget
.val() ),
19 isEmpty
= blocktarget
=== '',
20 isIp
= mw
.util
.isIPv4Address( blocktarget
, true ) || mw
.util
.isIPv6Address( blocktarget
, true ),
21 isIpRange
= isIp
&& blocktarget
.match( /\/\d+$/ );
23 if ( isIp
&& !isEmpty
) {
24 $enableAutoblockRow
.goOut( instant
);
25 $hideUser
.goOut( instant
);
27 $enableAutoblockRow
.goIn( instant
);
28 $hideUser
.goIn( instant
);
30 if ( !isIp
&& !isEmpty
) {
31 $anonOnlyRow
.goOut( instant
);
33 $anonOnlyRow
.goIn( instant
);
35 if ( isIpRange
&& !isEmpty
) {
36 $watchUser
.goOut( instant
);
38 $watchUser
.goIn( instant
);
42 // Bind functions so they're checked whenever stuff changes
43 $blockTarget
.keyup( updateBlockOptions
);
45 // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
46 updateBlockOptions( /* instant= */ true );
48 }( mediaWiki
, jQuery
) );