Follow up r78003, forgot to make MonoBook use the footericons code.
[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
33 // @TODO: get some core JS IP functions
34 // Match the first IP in each list (ignore other garbage)
35 var isIpV4 = addy.match(/^(\d+\.\d+\.\d+\.\d+)(\/\d+)?$/);
36 // Regexp has 3 cases: (starts with '::',ends with '::',neither)
37 var isIpV6 = !addy.match(/::.*::/) // not ambiguous
38 && addy.match(/^(:(:[0-9A-Fa-f]{1,4}){1,7}|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){0,6}::|[0-9A-Fa-f]{1,4}(::?[0-9A-Fa-f]{1,4}){1,7})(\/\d+)?$/);
39
40 var isIp = ( isIpV4 || isIpV6 );
41 var isIpRange = isIp && addy.match(/\/\d+$/);
42
43 var anonymousRow = document.getElementById( 'wpAnonOnlyRow' );
44 if( anonymousRow ) {
45 anonymousRow.style.display = ( !isIp && !isEmpty ) ? 'none' : '';
46 }
47
48 var autoblockRow = document.getElementById( 'wpEnableAutoblockRow' );
49 if( autoblockRow ) {
50 autoblockRow.style.display = isIp && !isEmpty ? 'none' : '';
51 }
52
53 var hideuserRow = document.getElementById( 'wpEnableHideUser' );
54 if( hideuserRow ) {
55 hideuserRow.style.display = isIp && !isEmpty ? 'none' : '';
56 }
57
58 var watchuserRow = document.getElementById( 'wpEnableWatchUser' );
59 if( watchuserRow ) {
60 watchuserRow.style.display = isIpRange && !isEmpty ? 'none' : '';
61 }
62 };
63
64 addOnloadHook( considerChangingExpiryFocus );