1 function protectInitialize(tableId
, labelText
) {
2 if (document
.createTextNode
) {
3 var box
= document
.getElementById(tableId
);
7 var tbody
= box
.getElementsByTagName('tbody')[0];
8 var row
= document
.createElement('tr');
9 tbody
.appendChild(row
);
11 row
.appendChild(document
.createElement('td'));
12 var col2
= document
.createElement('td');
13 row
.appendChild(col2
);
15 var check
= document
.createElement('input');
16 check
.id
= "mwProtectUnchained";
17 check
.type
= "checkbox";
18 check
.onclick
= protectChainUpdate
;
19 col2
.appendChild(check
);
21 var space
= document
.createTextNode(" ");
22 col2
.appendChild(space
);
24 var label
= document
.createElement('label');
25 label
.setAttribute("for", "mwProtectUnchained");
26 label
.appendChild(document
.createTextNode(labelText
));
27 col2
.appendChild(label
);
29 if (protectAllMatch()) {
30 check
.checked
= false;
42 function protectLevelsUpdate(source
) {
43 if (!protectUnchained()) {
44 protectUpdateAll(source
.selectedIndex
);
48 function protectChainUpdate() {
49 if (protectUnchained()) {
58 function protectAllMatch() {
59 var values
= new Array();
60 protectForSelectors(function(set) {
61 values
[values
.length
] = set.selectedIndex
;
63 for (var i
= 1; i
< values
.length
; i
++) {
64 if (values
[i
] != values
[0]) {
71 function protectUnchained() {
72 var unchain
= document
.getElementById("mwProtectUnchained");
74 alert("This shouldn't happen");
77 return unchain
.checked
;
80 function protectChain() {
81 // Find the highest-protected action and bump them all to this level
83 protectForSelectors(function(set) {
84 if (set.selectedIndex
> maxIndex
) {
85 maxIndex
= set.selectedIndex
;
88 protectUpdateAll(maxIndex
);
91 function protectUpdateAll(index
) {
92 protectForSelectors(function(set) {
93 if (set.selectedIndex
!= index
) {
94 set.selectedIndex
= index
;
99 function protectForSelectors(func
) {
100 var selectors
= protectSelectors();
101 for (var i
= 0; i
< selectors
.length
; i
++) {
106 function protectSelectors() {
107 var all
= document
.getElementsByTagName("select");
108 var ours
= new Array();
109 for (var i
= 0; i
< all
.length
; i
++) {
111 if (set.id
.match(/^mwProtect-level-/)) {
112 ours
[ours
.length
] = set;
118 function protectEnable(val
) {
121 protectForSelectors(function(set) {
126 set.style
.visible
= val
? "visible" : "hidden";