Merging resourceloader branch into trunk. Full documentation is at http://www.mediawi...
[lhc/web/wiklou.git] / skins / common / block.js
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 }
19 }
20 window.updateBlockOptions = function() {
21 if ( !document.getElementById ) {
22 return;
23 }
24
25 var target = document.getElementById( 'mw-bi-target' );
26 if ( !target ) {
27 return;
28 }
29
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+$/);
34
35 var anonymousRow = document.getElementById( 'wpAnonOnlyRow' );
36 if( anonymousRow ) {
37 anonymousRow.style.display = ( !isIp && !isEmpty ) ? 'none' : '';
38 }
39
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 }
49
50 var watchuserRow = document.getElementById( 'wpEnableWatchUser' );
51 if( watchuserRow ) {
52 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
53 }
54 }
55
56 addOnloadHook( considerChangingExpiryFocus );