1 window
.considerChangingExpiryFocus = function() {
2 if ( !document
.getElementById
) {
5 var drop
= document
.getElementById( 'wpBlockExpiry' );
9 var field
= document
.getElementById( 'wpBlockOther' );
14 if ( opt
== 'other' ) {
15 field
.style
.display
= '';
17 field
.style
.display
= 'none';
20 window
.updateBlockOptions = function() {
21 if ( !document
.getElementById
) {
25 var target
= document
.getElementById( 'mw-bi-target' );
30 var addy
= target
.value
;
31 var isEmpty
= addy
.match(/^\s*$/);
33 // @TODO: get some core JS IP functions
34 // Match the first IP in each list (ignore other garbage)
35 var isIpV4
= addy
.match(/^(\d+\.\d+\.\d+\.\d+)(\/\d+)?$/);
36 // Regexp has 3 cases: (starts with '::',ends with '::',neither)
37 var isIpV6
= !addy
.match(/::.*::/) // not ambiguous
38 && addy
.match(/^(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){0,6}::|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){1,7})(\/\d+)?$/);
40 var isIp
= ( isIpV4
|| isIpV6
);
41 var isIpRange
= isIp
&& addy
.match(/\/\d+$/);
43 var anonymousRow
= document
.getElementById( 'wpAnonOnlyRow' );
45 anonymousRow
.style
.display
= ( !isIp
&& !isEmpty
) ? 'none' : '';
48 var autoblockRow
= document
.getElementById( 'wpEnableAutoblockRow' );
50 autoblockRow
.style
.display
= isIp
&& !isEmpty
? 'none' : '';
53 var hideuserRow
= document
.getElementById( 'wpEnableHideUser' );
55 hideuserRow
.style
.display
= isIp
&& !isEmpty
? 'none' : '';
58 var watchuserRow
= document
.getElementById( 'wpEnableWatchUser' );
60 watchuserRow
.style
.display
= isIpRange
&& !isEmpty
? 'none' : '';
64 addOnloadHook( considerChangingExpiryFocus
);