* (bug 13234) Do not show grey category box for pages with only hidden categories
[lhc/web/wiklou.git] / skins / common / block.js
1 function considerChangingExpiryFocus() {
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
21 function updateBlockOptions() {
22 if (!document.getElementById)
23 return;
24
25 var target = document.getElementById('mw-bi-target');
26 if (!target)
27 return;
28
29 var addy = target.value;
30 var isEmpty = addy.match(/^\s*$/);
31 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+)?$/);
32
33 var anonymousRow = document.getElementById('wpAnonOnlyRow');
34 if( anonymousRow ) {
35 anonymousRow.style.display = (!isIp && !isEmpty) ? 'none' : '';
36 }
37
38 var autoblockRow = document.getElementById('wpEnableAutoblockRow');
39 if( autoblockRow ) {
40 autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
41 }
42
43 var emailblockRow = document.getElementById('wpEnableEmailBan');
44 if( emailblockRow ) {
45 emailblockRow.style.display = isIp && !isEmpty ? 'none' : '';
46 }
47
48 var hideuserRow = document.getElementById('wpEnableHideUser');
49 if( hideuserRow ) {
50 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
51 }
52 }