2 * JavaScript for Special:Block
5 $( document ).ready( function () {
6 var $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 function updateBlockOptions( instant ) {
13 var blocktarget = $.trim( $blockTarget.val() ),
14 isEmpty = blocktarget === '',
15 isIp = mw.util.isIPv4Address( blocktarget, true ) || mw.util.isIPv6Address( blocktarget, true ),
16 isIpRange = isIp && blocktarget.match( /\/\d+$/ );
18 if ( isIp && !isEmpty ) {
19 $enableAutoblockRow.goOut( instant );
20 $hideUser.goOut( instant );
22 $enableAutoblockRow.goIn( instant );
23 $hideUser.goIn( instant );
25 if ( !isIp && !isEmpty ) {
26 $anonOnlyRow.goOut( instant );
28 $anonOnlyRow.goIn( instant );
30 if ( isIpRange && !isEmpty ) {
31 $watchUser.goOut( instant );
33 $watchUser.goIn( instant );
37 if ( $blockTarget.length ) {
38 // Bind functions so they're checked whenever stuff changes
39 $blockTarget.keyup( updateBlockOptions );
41 // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
42 updateBlockOptions( /* instant= */ true );
45 }( mediaWiki, jQuery ) );