]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - skins/common/block.js
MediaWiki 1.15.0
[autoinstalls/mediawiki.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         var isIpRange = isIp && addy.match(/\/\d+$/);
35
36         var anonymousRow = document.getElementById('wpAnonOnlyRow');
37         if( anonymousRow ) {
38                 anonymousRow.style.display = (!isIp && !isEmpty) ? 'none' : '';
39         }
40
41         var autoblockRow = document.getElementById('wpEnableAutoblockRow');
42         if( autoblockRow ) {
43                 autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
44         }
45
46         var emailblockRow = document.getElementById('wpEnableEmailBan');
47         if( emailblockRow ) {
48                 emailblockRow.style.display = isIp && !isEmpty ? 'none' : '';
49         }
50         
51         var hideuserRow = document.getElementById('wpEnableHideUser');
52         if( hideuserRow ) {
53                 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
54         }
55
56         var watchuserRow = document.getElementById('wpEnableWatchUser');
57         if( watchuserRow ) {
58                 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
59         }
60 }