Some initial work on external storage recompression. Committing now in case I acciden...
[lhc/web/wiklou.git] / skins / common / block.js
1 addOnloadHook(considerChangingExpiryFocus);
2
3 function considerChangingExpiryFocus() {
4 if (!document.getElementById) {
5 return;
6 }
7 var drop = document.getElementById('wpBlockExpiry');
8 if (!drop) {
9 return;
10 }
11 var field = document.getElementById('wpBlockOther');
12 if (!field) {
13 return;
14 }
15 var opt = drop.value;
16 if (opt == 'other') {
17 field.style.display = '';
18 } else {
19 field.style.display = 'none';
20 }
21 }
22
23 function updateBlockOptions() {
24 if (!document.getElementById)
25 return;
26
27 var target = document.getElementById('mw-bi-target');
28 if (!target)
29 return;
30
31 var addy = target.value;
32 var isEmpty = addy.match(/^\s*$/);
33 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+)?$/);
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 emailblockRow = document.getElementById('wpEnableEmailBan');
46 if( emailblockRow ) {
47 emailblockRow.style.display = isIp && !isEmpty ? 'none' : '';
48 }
49
50 var hideuserRow = document.getElementById('wpEnableHideUser');
51 if( hideuserRow ) {
52 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
53 }
54 }