Test for r67549 (bug 23797)
[mediawiki.git] / skins / common / block.js
blob73ed71e2df1110e18d03cf68a9890e0f510a0827
1 window.considerChangingExpiryFocus = function() {
2         if ( !document.getElementById ) {
3                 return;
4         }
5         var drop = document.getElementById( 'wpBlockExpiry' );
6         if ( !drop ) {
7                 return;
8         }
9         var field = document.getElementById( 'wpBlockOther' );
10         if ( !field ) {
11                 return;
12         }
13         var opt = drop.value;
14         if ( opt == 'other' ) {
15                 field.style.display = '';
16         } else {
17                 field.style.display = 'none';
18         }
20 window.updateBlockOptions = function() {
21         if ( !document.getElementById ) {
22                 return;
23         }
25         var target = document.getElementById( 'mw-bi-target' );
26         if ( !target ) {
27                 return;
28         }
30         var addy = target.value;
31         var isEmpty = addy.match(/^\s*$/);
32         var isIp = addy.match(/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(:{1,2}[0-9A-Fa-f]{1,4}|::$){1,7})(\/\d+)?$/);
33         var isIpRange = isIp && addy.match(/\/\d+$/);
35         var anonymousRow = document.getElementById( 'wpAnonOnlyRow' );
36         if( anonymousRow ) {
37                 anonymousRow.style.display = ( !isIp && !isEmpty ) ? 'none' : '';
38         }
40         var autoblockRow = document.getElementById( 'wpEnableAutoblockRow' );
41         if( autoblockRow ) {
42                 autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
43         }
44         
45         var hideuserRow = document.getElementById( 'wpEnableHideUser' );
46         if( hideuserRow ) {
47                 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
48         }
50         var watchuserRow = document.getElementById( 'wpEnableWatchUser' );
51         if( watchuserRow ) {
52                 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
53         }
56 addOnloadHook( considerChangingExpiryFocus );