author | Dan |
Wed, 19 Sep 2007 13:26:42 -0400 | |
changeset 138 | 13561bde2e2c |
parent 76 | 608dee512bf0 |
child 150 | 824821224153 |
permissions | -rw-r--r-- |
1 | 1 |
// Javascript routines for the ACL editor |
2 |
||
3 |
var aclManagerID = 'enano_aclmanager_' + Math.floor(Math.random() * 1000000); |
|
4 |
var aclPermList = false; |
|
5 |
var aclDataCache = false; |
|
6 |
||
7 |
function ajaxOpenACLManager(page_id, namespace) |
|
8 |
{ |
|
9 |
if(IE) |
|
10 |
return true; |
|
11 |
if(!page_id || !namespace) |
|
12 |
{ |
|
13 |
var data = strToPageID(title); |
|
14 |
var page_id = data[0]; |
|
15 |
var namespace = data[1]; |
|
16 |
} |
|
17 |
var params = { |
|
18 |
'mode' : 'listgroups', |
|
19 |
'page_id' : page_id, |
|
20 |
'namespace' : namespace |
|
21 |
}; |
|
22 |
params = toJSONString(params); |
|
23 |
params = ajaxEscape(params); |
|
24 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
25 |
if(ajax.readyState == 4) |
|
26 |
{ |
|
27 |
__aclBuildWizardWindow(); |
|
28 |
groups = parseJSON(ajax.responseText); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
29 |
if ( groups.mode == 'error' ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
30 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
31 |
alert(groups.error); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
32 |
killACLManager(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
33 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
34 |
} |
1 | 35 |
aclDataCache = groups; |
36 |
__aclBuildSelector(groups); |
|
37 |
} |
|
38 |
}); |
|
39 |
return false; |
|
40 |
} |
|
41 |
||
42 |
function ajaxACLSwitchToSelector() |
|
43 |
{ |
|
44 |
params = { |
|
45 |
'mode' : 'listgroups' |
|
46 |
}; |
|
47 |
if ( aclDataCache.page_id && aclDataCache.namespace ) |
|
48 |
{ |
|
49 |
params.page_id = aclDataCache.page_id; |
|
50 |
params.namespace = aclDataCache.namespace; |
|
51 |
} |
|
52 |
params = toJSONString(params); |
|
53 |
params = ajaxEscape(params); |
|
54 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
55 |
if(ajax.readyState == 4) |
|
56 |
{ |
|
57 |
document.getElementById(aclManagerID+'_main').innerHTML = ''; |
|
58 |
document.getElementById(aclManagerID + '_back').style.display = 'none'; |
|
59 |
document.getElementById(aclManagerID + '_next').value = 'Next >'; |
|
60 |
groups = parseJSON(ajax.responseText); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
61 |
if ( groups.mode == 'error' ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
62 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
63 |
alert(groups.error); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
64 |
killACLManager(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
65 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
66 |
} |
1 | 67 |
aclDataCache = groups; |
68 |
thispage = strToPageID(title); |
|
69 |
groups.page_id = thispage[0]; |
|
70 |
groups.namespace = thispage[1]; |
|
71 |
__aclBuildSelector(groups); |
|
72 |
} |
|
73 |
}); |
|
74 |
} |
|
75 |
||
76 |
function __aclBuildSelector(groups) |
|
77 |
{ |
|
78 |
thispage = strToPageID(title); |
|
79 |
do_scopesel = ( thispage[0] == groups.page_id && thispage[1] == groups.namespace ); |
|
80 |
||
81 |
seed = Math.floor(Math.random() * 1000000); |
|
82 |
||
83 |
main = document.getElementById(aclManagerID + '_main'); |
|
84 |
main.style.padding = '10px'; |
|
85 |
||
86 |
selector = document.createElement('div'); |
|
87 |
||
88 |
grpsel = __aclBuildGroupsHTML(groups); |
|
89 |
grpsel.name = 'group_id'; |
|
90 |
||
91 |
span = document.createElement('div'); |
|
92 |
span.id = "enACL_grpbox_"+seed+""; |
|
93 |
||
94 |
// Build the selector |
|
95 |
grpb = document.createElement('input'); |
|
96 |
grpb.type = 'radio'; |
|
97 |
grpb.name = 'target_type'; |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
98 |
grpb.value = '1'; // ACL_TYPE_GROUP |
1 | 99 |
grpb.checked = 'checked'; |
100 |
grpb.className = seed; |
|
101 |
grpb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'block'; document.getElementById('enACL_usrbox_'+seed).style.display = 'none'; }; |
|
102 |
lbl = document.createElement('label'); |
|
103 |
lbl.appendChild(grpb); |
|
104 |
lbl.appendChild(document.createTextNode('A usergroup')); |
|
105 |
lbl.style.display = 'block'; |
|
106 |
span.appendChild(grpsel); |
|
107 |
||
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
108 |
anoninfo = document.createElement('div'); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
109 |
anoninfo.className = 'info-box-mini'; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
110 |
anoninfo.appendChild(document.createTextNode('To edit permissions for guests, select "a specific user", and enter Anonymous as the username.')); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
111 |
span.appendChild(document.createElement('br')); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
112 |
span.appendChild(anoninfo); |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
113 |
|
1 | 114 |
usrb = document.createElement('input'); |
115 |
usrb.type = 'radio'; |
|
116 |
usrb.name = 'target_type'; |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
117 |
usrb.value = '2'; // ACL_TYPE_USER |
1 | 118 |
usrb.className = seed; |
119 |
usrb.onclick = function() { seed = this.className; document.getElementById('enACL_grpbox_'+seed).style.display = 'none'; document.getElementById('enACL_usrbox_'+seed).style.display = 'block'; }; |
|
120 |
lbl2 = document.createElement('label'); |
|
121 |
lbl2.appendChild(usrb); |
|
122 |
lbl2.appendChild(document.createTextNode('A specific user')); |
|
123 |
lbl2.style.display = 'block'; |
|
124 |
||
125 |
usrsel = document.createElement('input'); |
|
126 |
usrsel.type = 'text'; |
|
127 |
usrsel.name = 'username'; |
|
128 |
usrsel.onkeyup = function() { ajaxUserNameComplete(this); }; |
|
129 |
usrsel.id = 'userfield_' + aclManagerID; |
|
130 |
try { |
|
131 |
usrsel.setAttribute("autocomplete","off"); |
|
132 |
} catch(e) {}; |
|
133 |
||
134 |
span2 = document.createElement('div'); |
|
135 |
span2.id = "enACL_usrbox_"+seed+""; |
|
136 |
span2.style.display = 'none'; |
|
137 |
span2.appendChild(usrsel); |
|
138 |
||
139 |
// Scope selector |
|
140 |
if(do_scopesel) |
|
141 |
{ |
|
142 |
scopediv1 = document.createElement('div'); |
|
143 |
scopediv2 = document.createElement('div'); |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
144 |
scopediv3 = document.createElement('div'); |
1 | 145 |
scopeRadioPage = document.createElement('input'); |
146 |
scopeRadioPage.type = 'radio'; |
|
147 |
scopeRadioPage.name = 'scope'; |
|
148 |
scopeRadioPage.value = 'page'; |
|
149 |
scopeRadioPage.checked = 'checked'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
150 |
scopeRadioPage.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
151 |
if ( groups.page_groups.length > 0 ) scopeRadioPage.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
1 | 152 |
scopeRadioGlobal = document.createElement('input'); |
153 |
scopeRadioGlobal.type = 'radio'; |
|
154 |
scopeRadioGlobal.name = 'scope'; |
|
155 |
scopeRadioGlobal.value = 'global'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
156 |
scopeRadioGlobal.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
157 |
if ( groups.page_groups.length > 0 ) scopeRadioGlobal.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'none'; }; |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
158 |
scopeRadioGroup = document.createElement('input'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
159 |
scopeRadioGroup.type = 'radio'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
160 |
scopeRadioGroup.name = 'scope'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
161 |
scopeRadioGroup.value = 'group'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
162 |
scopeRadioGroup.className = '1048576'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
163 |
if ( groups.page_groups.length > 0 ) scopeRadioGroup.onclick = function() { var id = 'enACL_pgsel_' + this.className; document.getElementById(id).style.display = 'block'; }; |
1 | 164 |
lblPage = document.createElement('label'); |
165 |
lblPage.style.display = 'block'; |
|
166 |
lblPage.appendChild(scopeRadioPage); |
|
167 |
lblPage.appendChild(document.createTextNode('Only this page')); |
|
168 |
lblGlobal = document.createElement('label'); |
|
169 |
lblGlobal.style.display = 'block'; |
|
170 |
lblGlobal.appendChild(scopeRadioGlobal); |
|
171 |
lblGlobal.appendChild(document.createTextNode('The entire website')); |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
172 |
lblGroup = document.createElement('label'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
173 |
lblGroup.style.display = 'block'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
174 |
lblGroup.appendChild(scopeRadioGroup); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
175 |
lblGroup.appendChild(document.createTextNode('A group of pages')); |
1 | 176 |
scopediv1.appendChild(lblPage); |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
177 |
scopediv2.appendChild(lblGroup); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
178 |
scopediv3.appendChild(lblGlobal); |
1 | 179 |
|
180 |
scopedesc = document.createElement('p'); |
|
181 |
scopedesc.appendChild(document.createTextNode('What should this access rule control?')); |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
182 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
183 |
scopePGrp = document.createElement('select'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
184 |
scopePGrp.style.marginLeft = '13px'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
185 |
scopePGrp.style.display = 'none'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
186 |
scopePGrp.id = "enACL_pgsel_1048576"; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
187 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
188 |
var opt; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
189 |
for ( var i = 0; i < groups.page_groups.length; i++ ) |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
190 |
{ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
191 |
opt = document.createElement('option'); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
192 |
opt.value = groups.page_groups[i].id; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
193 |
opt.appendChild(document.createTextNode(groups.page_groups[i].name)); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
194 |
scopePGrp.appendChild(opt); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
195 |
} |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
196 |
|
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
197 |
scopediv2.appendChild(scopePGrp); |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
198 |
|
1 | 199 |
} |
200 |
||
201 |
// Styles |
|
202 |
span.style.marginLeft = '13px'; |
|
203 |
span.style.padding = '5px 0'; |
|
204 |
span2.style.marginLeft = '13px'; |
|
205 |
span2.style.padding = '5px 0'; |
|
206 |
||
207 |
selector.appendChild(lbl); |
|
208 |
selector.appendChild(span); |
|
209 |
||
210 |
selector.appendChild(lbl2); |
|
211 |
selector.appendChild(span2); |
|
212 |
||
213 |
container = document.createElement('div'); |
|
214 |
container.style.margin = 'auto'; |
|
215 |
container.style.width = '360px'; |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
216 |
container.style.paddingTop = '50px'; |
1 | 217 |
|
218 |
head = document.createElement('h2'); |
|
219 |
head.appendChild(document.createTextNode('Manage page access')); |
|
220 |
||
221 |
desc = document.createElement('p'); |
|
222 |
desc.appendChild(document.createTextNode('Please select who should be affected by this access rule.')); |
|
223 |
||
224 |
container.appendChild(head); |
|
225 |
container.appendChild(desc); |
|
226 |
container.appendChild(selector); |
|
227 |
||
228 |
if(do_scopesel) |
|
229 |
{ |
|
230 |
container.appendChild(scopedesc); |
|
231 |
container.appendChild(scopediv1); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
232 |
if ( groups.page_groups.length > 0 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
233 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
234 |
container.appendChild(scopediv2); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
235 |
} |
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
236 |
container.appendChild(scopediv3); |
1 | 237 |
} |
238 |
||
239 |
main.appendChild(container); |
|
240 |
||
241 |
var mode = document.createElement('input'); |
|
242 |
mode.name = 'mode'; |
|
243 |
mode.type = 'hidden'; |
|
244 |
mode.id = aclManagerID + '_mode'; |
|
245 |
mode.value = 'seltarget'; |
|
246 |
||
247 |
var theform = document.getElementById(aclManagerID + '_formobj_id'); |
|
248 |
if ( !theform.mode ) |
|
249 |
{ |
|
250 |
theform.appendChild(mode); |
|
251 |
} |
|
252 |
else |
|
253 |
{ |
|
254 |
theform.removeChild(theform.mode); |
|
255 |
theform.appendChild(mode); |
|
256 |
} |
|
257 |
} |
|
258 |
||
259 |
var aclDebugWin = false; |
|
260 |
||
261 |
function aclDebug(text) |
|
262 |
{ |
|
263 |
if(!aclDebugWin) |
|
264 |
aclDebugWin = pseudoWindowOpen("data:text/html;plain,<html><head><title>debug win</title></head><body><h1>Debug window</h1></body></html>", "aclDebugWin"); |
|
265 |
setTimeout(function() { |
|
266 |
aclDebugWin.pre = aclDebugWin.document.createElement('pre'); |
|
267 |
aclDebugWin.pre.appendChild(aclDebugWin.document.createTextNode(text)); |
|
268 |
aclDebugWin.b = aclDebugWin.document.getElementsByTagName('body')[0]; |
|
269 |
aclDebugWin.b.appendChild(aclDebugWin.pre);}, 1000); |
|
270 |
} |
|
271 |
||
272 |
var pseudoWindows = new Object(); |
|
273 |
||
274 |
function pseudoWindowOpen(url, id) |
|
275 |
{ |
|
276 |
if(pseudoWindows[id]) |
|
277 |
{ |
|
278 |
document.getElementById('pseudowin_ifr_'+id).src = url; |
|
279 |
} |
|
280 |
else |
|
281 |
{ |
|
282 |
win = document.createElement('iframe'); |
|
283 |
win.style.position='fixed'; |
|
284 |
win.style.width = '640px'; |
|
285 |
win.style.height = '480px'; |
|
286 |
win.style.top = '0px'; |
|
287 |
win.style.left = '0px'; |
|
288 |
win.style.zIndex = getHighestZ() + 1; |
|
289 |
win.style.backgroundColor = '#FFFFFF'; |
|
290 |
win.name = 'pseudo_ifr_'+id; |
|
291 |
win.id = 'pseudowindow_ifr_'+id; |
|
292 |
win.src = url; |
|
293 |
body = document.getElementsByTagName('body')[0]; |
|
294 |
body.appendChild(win); |
|
295 |
} |
|
296 |
win_obj = eval("( pseudo_ifr_"+id+" )"); |
|
297 |
return win_obj; |
|
298 |
} |
|
299 |
||
300 |
function __aclJSONSubmitAjaxHandler(params) |
|
301 |
{ |
|
302 |
params = toJSONString(params); |
|
303 |
params = ajaxEscape(params); |
|
304 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
305 |
if(ajax.readyState == 4) |
|
306 |
{ |
|
307 |
try { |
|
308 |
data = parseJSON(ajax.responseText); |
|
309 |
} catch(e) { |
|
310 |
aclDebug(e+"\n\nResponse:\n"+ajax.responseText); |
|
311 |
} |
|
312 |
aclDataCache = data; |
|
313 |
switch(data.mode) |
|
314 |
{ |
|
315 |
case 'seltarget': |
|
316 |
||
317 |
// Build the ACL edit form |
|
318 |
// try { |
|
319 |
act_desc = ( data.type == 'new' ) ? 'Create access rule' : 'Editing permissions'; |
|
320 |
target_type_t = ( data.target_type == 1 ) ? 'group' : 'user'; |
|
321 |
target_name_t = data.target_name; |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
322 |
var scope_type = ( data.page_id == false && data.namespace == false ) ? 'this entire site' : ( data.namespace == '__PageGroup' ) ? 'this group of pages' : 'this page'; |
1 | 323 |
html = '<h2>'+act_desc+'</h2><p>This panel allows you to edit what the '+target_type_t+' "<b>'+target_name_t+'</b>" can do on <b>' + scope_type + '</b>. Unless you set a permission to "Deny", these permissions may be overridden by other rules.</p>'; |
324 |
parser = new templateParser(data.template.acl_field_begin); |
|
325 |
html += parser.run(); |
|
326 |
||
327 |
cls = 'row2'; |
|
328 |
for(var i in data.acl_types) |
|
329 |
{ |
|
330 |
if(typeof(data.acl_types[i]) == 'number') |
|
331 |
{ |
|
332 |
cls = ( cls == 'row1' ) ? 'row2' : 'row1'; |
|
333 |
p = new templateParser(data.template.acl_field_item); |
|
334 |
vars = new Object(); |
|
335 |
vars['FIELD_DESC'] = data.acl_descs[i]; |
|
336 |
vars['FIELD_DENY_CHECKED'] = ''; |
|
337 |
vars['FIELD_DISALLOW_CHECKED'] = ''; |
|
338 |
vars['FIELD_WIKIMODE_CHECKED'] = ''; |
|
339 |
vars['FIELD_ALLOW_CHECKED'] = ''; |
|
340 |
vars['FIELD_NAME'] = i; |
|
341 |
switch(data.current_perms[i]) |
|
342 |
{ |
|
343 |
case 1: |
|
344 |
vars['FIELD_DENY_CHECKED'] = 'checked="checked"'; |
|
345 |
break; |
|
346 |
case 2: |
|
347 |
default: |
|
348 |
vars['FIELD_DISALLOW_CHECKED'] = 'checked="checked"'; |
|
349 |
break; |
|
350 |
case 3: |
|
351 |
vars['FIELD_WIKIMODE_CHECKED'] = 'checked="checked"'; |
|
352 |
break; |
|
353 |
case 4: |
|
354 |
vars['FIELD_ALLOW_CHECKED'] = 'checked="checked"'; |
|
355 |
break; |
|
356 |
} |
|
357 |
vars['ROW_CLASS'] = cls; |
|
358 |
p.assign_vars(vars); |
|
359 |
html += p.run(); |
|
360 |
} |
|
361 |
} |
|
362 |
||
363 |
var parser = new templateParser(data.template.acl_field_end); |
|
364 |
html += parser.run(); |
|
365 |
||
366 |
if(data.type == 'edit') |
|
367 |
html += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'Do you really want to delete this rule?\')) __aclDeleteRule(); return false;" style="color: red;">Delete this rule</a></p>'; |
|
368 |
||
369 |
var main = document.getElementById(aclManagerID + '_main'); |
|
370 |
main.innerHTML = html; |
|
371 |
||
372 |
var form = document.getElementById(aclManagerID + '_formobj_id'); |
|
373 |
||
374 |
var modeobj = form_fetch_field(form, 'mode'); |
|
375 |
if ( modeobj ) |
|
376 |
modeobj.value = 'save_' + data.type; |
|
377 |
else |
|
378 |
alert('modeobj is invalid: '+modeobj); |
|
379 |
||
380 |
aclPermList = array_keys(data.acl_types); |
|
381 |
||
382 |
document.getElementById(aclManagerID + '_back').style.display = 'inline'; |
|
383 |
document.getElementById(aclManagerID + '_next').value = 'Save Changes'; |
|
384 |
||
385 |
// } catch(e) { alert(e); aclDebug(ajax.responseText); } |
|
386 |
||
387 |
break; |
|
388 |
case 'success': |
|
389 |
var note = document.createElement('div'); |
|
390 |
note.className = 'info-box'; |
|
391 |
note.style.marginLeft = '0'; |
|
392 |
var b = document.createElement('b'); |
|
393 |
b.appendChild(document.createTextNode('Permissions updated')); |
|
394 |
note.appendChild(b); |
|
395 |
note.appendChild(document.createElement('br')); |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
396 |
note.appendChild(document.createTextNode('The permissions for '+data.target_name+' on this page have been updated successfully. If you changed permissions that affect your user account, you may not see changes until you reload the page.')); |
1 | 397 |
note.appendChild(document.createElement('br')); |
398 |
var a = document.createElement('a'); |
|
399 |
a.href = 'javascript:void(0);'; |
|
400 |
a.onclick = function() { this.parentNode.parentNode.removeChild(this.parentNode); return false; }; |
|
401 |
a.appendChild(document.createTextNode('[ dismiss :')); |
|
402 |
note.appendChild(a); |
|
403 |
var a2 = document.createElement('a'); |
|
404 |
a2.href = 'javascript:void(0);'; |
|
405 |
a2.onclick = function() { killACLManager(); return false; }; |
|
406 |
a2.appendChild(document.createTextNode(': close manager ]')); |
|
407 |
note.appendChild(a2); |
|
408 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
409 |
if(!document.getElementById(aclManagerID+'_deletelnk')) |
|
410 |
document.getElementById(aclManagerID + '_main').innerHTML += '<p id="'+aclManagerID+'_deletelnk" style="text-align: right;"><a href="#delete_acl_rule" onclick="if(confirm(\'Do you really want to delete this rule?\')) __aclDeleteRule(); return false;" style="color: red;">Delete this rule</a></p>'; |
|
411 |
//fadeInfoBoxes(); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
412 |
document.getElementById(aclManagerID+'_main').scrollTop = 0; |
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
413 |
|
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
414 |
aclDataCache.mode = 'save_edit'; |
1 | 415 |
break; |
416 |
case 'delete': |
|
417 |
||
418 |
params = { |
|
419 |
'mode' : 'listgroups' |
|
420 |
}; |
|
421 |
params = toJSONString(params); |
|
422 |
params = ajaxEscape(params); |
|
423 |
ajaxPost(stdAjaxPrefix+'&_mode=acljson', 'acl_params='+params, function() { |
|
424 |
if(ajax.readyState == 4) |
|
425 |
{ |
|
426 |
document.getElementById(aclManagerID+'_main').innerHTML = ''; |
|
427 |
document.getElementById(aclManagerID + '_back').style.display = 'none'; |
|
428 |
document.getElementById(aclManagerID + '_next').value = 'Next >'; |
|
429 |
var thispage = strToPageID(title); |
|
430 |
groups.page_id = thispage[0]; |
|
431 |
groups.namespace = thispage[1]; |
|
432 |
__aclBuildSelector(groups); |
|
433 |
||
434 |
note = document.createElement('div'); |
|
435 |
note.className = 'info-box'; |
|
436 |
note.style.marginLeft = '0'; |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
437 |
note.style.position = 'absolute'; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
438 |
note.style.width = '558px'; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
439 |
note.id = 'aclSuccessNotice_' + Math.floor(Math.random() * 100000); |
1 | 440 |
b = document.createElement('b'); |
441 |
b.appendChild(document.createTextNode('Entry deleted')); |
|
442 |
note.appendChild(b); |
|
443 |
note.appendChild(document.createElement('br')); |
|
444 |
note.appendChild(document.createTextNode('The access rules for '+aclDataCache.target_name+' on this page have been deleted.')); |
|
445 |
note.appendChild(document.createElement('br')); |
|
446 |
a = document.createElement('a'); |
|
447 |
a.href = '#'; |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
448 |
a.onclick = function() { opacity(this.parentNode.id, 100, 0, 1000); setTimeout('var div = document.getElementById("' + this.parentNode.id + '"); div.parentNode.removeChild(div);', 1100); return false; }; |
1 | 449 |
a.appendChild(document.createTextNode('[ dismiss :')); |
450 |
note.appendChild(a); |
|
451 |
a = document.createElement('a'); |
|
452 |
a.href = '#'; |
|
453 |
a.onclick = function() { killACLManager(); return false; }; |
|
454 |
a.appendChild(document.createTextNode(': close manager ]')); |
|
455 |
note.appendChild(a); |
|
456 |
document.getElementById(aclManagerID + '_main').insertBefore(note, document.getElementById(aclManagerID + '_main').firstChild); |
|
457 |
//fadeInfoBoxes(); |
|
458 |
||
459 |
} |
|
460 |
}); |
|
461 |
||
462 |
break; |
|
463 |
case 'error': |
|
464 |
alert("Server side processing error:\n"+data.error); |
|
465 |
break; |
|
466 |
case 'debug': |
|
467 |
aclDebug(data.text); |
|
468 |
break; |
|
469 |
default: |
|
470 |
alert("Invalid JSON response from server\nMode: "+data.mode+"\nJSON string: "+ajax.responseText); |
|
471 |
break; |
|
472 |
} |
|
473 |
} |
|
474 |
}); |
|
475 |
} |
|
476 |
||
477 |
function __aclBuildGroupsHTML(groups) |
|
478 |
{ |
|
479 |
groups = groups.groups; |
|
480 |
select = document.createElement('select'); |
|
481 |
for(var i in groups) |
|
482 |
{ |
|
483 |
if(typeof(groups[i]['name']) == 'string' && i != 'toJSONString') |
|
484 |
{ |
|
485 |
o = document.createElement('option'); |
|
486 |
o.value = groups[i]['id']; |
|
487 |
t = document.createTextNode(groups[i]['name']); |
|
488 |
o.appendChild(t); |
|
489 |
select.appendChild(o); |
|
490 |
} |
|
491 |
} |
|
492 |
return select; |
|
493 |
} |
|
494 |
||
495 |
function __aclBuildWizardWindow() |
|
496 |
{ |
|
497 |
darken(); |
|
498 |
box = document.createElement('div'); |
|
499 |
box.style.width = '640px' |
|
500 |
box.style.height = '440px'; |
|
501 |
box.style.position = 'fixed'; |
|
502 |
width = getWidth(); |
|
503 |
height = getHeight(); |
|
504 |
box.style.left = ( width / 2 - 320 ) + 'px'; |
|
505 |
box.style.top = ( height / 2 - 250 ) + 'px'; |
|
506 |
box.style.backgroundColor = 'white'; |
|
507 |
box.style.zIndex = getHighestZ() + 1; |
|
508 |
box.id = aclManagerID; |
|
509 |
box.style.opacity = '0'; |
|
510 |
box.style.filter = 'alpha(opacity=0)'; |
|
511 |
box.style.display = 'none'; |
|
512 |
||
513 |
mainwin = document.createElement('div'); |
|
514 |
mainwin.id = aclManagerID + '_main'; |
|
515 |
mainwin.style.clip = 'rect(0px,640px,440px,0px)'; |
|
516 |
mainwin.style.overflow = 'auto'; |
|
517 |
mainwin.style.width = '620px'; |
|
518 |
mainwin.style.height = '420px'; |
|
519 |
||
520 |
panel = document.createElement('div'); |
|
521 |
panel.style.width = '620px'; |
|
522 |
panel.style.padding = '10px'; |
|
523 |
panel.style.lineHeight = '40px'; |
|
524 |
panel.style.textAlign = 'right'; |
|
525 |
panel.style.position = 'fixed'; |
|
526 |
panel.style.left = ( width / 2 - 320 ) + 'px'; |
|
527 |
panel.style.top = ( height / 2 + 190 ) + 'px'; |
|
528 |
panel.style.backgroundColor = '#D0D0D0'; |
|
529 |
panel.style.opacity = '0'; |
|
530 |
panel.style.filter = 'alpha(opacity=0)'; |
|
531 |
panel.id = aclManagerID + '_panel'; |
|
532 |
||
533 |
form = document.createElement('form'); |
|
534 |
form.method = 'post'; |
|
535 |
form.action = 'javascript:void(0)'; |
|
536 |
form.onsubmit = function() { if(this.username && !submitAuthorized) return false; __aclSubmitManager(this); return false; }; |
|
537 |
form.name = aclManagerID + '_formobj'; |
|
538 |
form.id = aclManagerID + '_formobj_id'; |
|
539 |
||
540 |
back = document.createElement('input'); |
|
541 |
back.type = 'button'; |
|
542 |
back.value = '< Back'; |
|
543 |
back.style.fontWeight = 'normal'; |
|
544 |
back.onclick = function() { ajaxACLSwitchToSelector(); return false; }; |
|
545 |
back.style.display = 'none'; |
|
546 |
back.id = aclManagerID + '_back'; |
|
547 |
||
548 |
saver = document.createElement('input'); |
|
549 |
saver.type = 'submit'; |
|
550 |
saver.value = 'Next >'; |
|
551 |
saver.style.fontWeight = 'bold'; |
|
552 |
saver.id = aclManagerID + '_next'; |
|
553 |
||
554 |
closer = document.createElement('input'); |
|
555 |
closer.type = 'button'; |
|
556 |
closer.value = 'Cancel Changes'; |
|
557 |
closer.onclick = function() { if(!confirm('Do you really want to close the ACL manager?')) return false; killACLManager(); return false; } |
|
558 |
||
559 |
spacer1 = document.createTextNode(' '); |
|
560 |
spacer2 = document.createTextNode(' '); |
|
561 |
||
562 |
panel.appendChild(back); |
|
563 |
panel.appendChild(spacer1); |
|
564 |
panel.appendChild(saver); |
|
565 |
panel.appendChild(spacer2); |
|
566 |
panel.appendChild(closer); |
|
567 |
form.appendChild(mainwin); |
|
568 |
form.appendChild(panel); |
|
569 |
box.appendChild(form); |
|
570 |
||
571 |
body = document.getElementsByTagName('body')[0]; |
|
572 |
body.appendChild(box); |
|
573 |
setTimeout("document.getElementById('"+aclManagerID+"').style.display = 'block'; opacity('"+aclManagerID+"', 0, 100, 500); opacity('"+aclManagerID + '_panel'+"', 0, 100, 500);", 1000); |
|
574 |
} |
|
575 |
||
576 |
function killACLManager() |
|
577 |
{ |
|
578 |
el = document.getElementById(aclManagerID); |
|
579 |
if(el) |
|
580 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
581 |
opacity(aclManagerID, 100, 0, 500); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
582 |
setTimeout('var el = document.getElementById(aclManagerID); el.parentNode.removeChild(el); enlighten();', 750); |
1 | 583 |
} |
584 |
} |
|
585 |
||
586 |
function __aclSubmitManager(form) |
|
587 |
{ |
|
588 |
var thefrm = document.forms[form.name]; |
|
589 |
var modeobj = form_fetch_field(thefrm, 'mode'); |
|
590 |
if ( typeof(modeobj) == 'object' ) |
|
591 |
{ |
|
592 |
var mode = (thefrm.mode.value) ? thefrm.mode.value : 'cant_get'; |
|
593 |
} |
|
594 |
else |
|
595 |
{ |
|
596 |
var mode = ''; |
|
597 |
} |
|
598 |
switch(mode) |
|
599 |
{ |
|
600 |
case 'cant_get': |
|
601 |
alert('BUG: can\'t get the state value from the form field.'); |
|
602 |
break; |
|
603 |
case 'seltarget': |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
604 |
var target_type = parseInt(getRadioState(thefrm, 'target_type', ['1', '2'])); |
1 | 605 |
if(isNaN(target_type)) |
606 |
{ |
|
607 |
alert('Please select a target type.'); |
|
608 |
return false; |
|
609 |
} |
|
610 |
target_id = ( target_type == 1 ) ? parseInt(thefrm.group_id.value) : thefrm.username.value; |
|
611 |
||
612 |
obj = { 'mode' : mode, 'target_type' : target_type, 'target_id' : target_id }; |
|
613 |
||
614 |
thispage = strToPageID(title); |
|
615 |
do_scopesel = ( thispage[0] == aclDataCache.page_id && thispage[1] == aclDataCache.namespace ); |
|
616 |
||
617 |
if(do_scopesel) |
|
618 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
619 |
scope = getRadioState(thefrm, 'scope', ['page', 'global']); |
1 | 620 |
if(scope == 'page') |
621 |
{ |
|
622 |
pageid = strToPageID(title); |
|
623 |
obj['page_id'] = pageid[0]; |
|
624 |
obj['namespace'] = pageid[1]; |
|
625 |
} |
|
626 |
else if(scope == 'global') |
|
627 |
{ |
|
628 |
obj['page_id'] = false; |
|
629 |
obj['namespace'] = false; |
|
630 |
} |
|
73
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
631 |
else if(scope == 'group') |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
632 |
{ |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
633 |
obj['page_id'] = document.getElementById('enACL_pgsel_1048576').value; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
634 |
obj['namespace'] = '__PageGroup'; |
0a74676a2f2f
Made the move to Loch Ness, and got some basic page grouping functionality working. TODO: fix some UI issues in Javascript ACL editor and change non-JS ACL editor to work with page groups too
Dan
parents:
42
diff
changeset
|
635 |
} |
1 | 636 |
else |
637 |
{ |
|
638 |
alert('Invalid scope'); |
|
639 |
return false; |
|
640 |
} |
|
641 |
} |
|
642 |
else |
|
643 |
{ |
|
644 |
obj['page_id'] = aclDataCache.page_id; |
|
645 |
obj['namespace'] = aclDataCache.namespace; |
|
646 |
} |
|
647 |
if(target_id == '') |
|
648 |
{ |
|
649 |
alert('Please enter a username.'); |
|
650 |
return false; |
|
651 |
} |
|
652 |
__aclJSONSubmitAjaxHandler(obj); |
|
653 |
break; |
|
654 |
case 'save_edit': |
|
655 |
case 'save_new': |
|
656 |
var form = document.forms[aclManagerID + '_formobj']; |
|
657 |
selections = new Object(); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
658 |
var dbg = ''; |
1 | 659 |
for(var i in aclPermList) |
660 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
661 |
selections[aclPermList[i]] = getRadioState(form, aclPermList[i], [1, 2, 3, 4]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
662 |
dbg += aclPermList[i] + ': ' + selections[aclPermList[i]] + "\n"; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
663 |
if(!selections[aclPermList[i]]) |
1 | 664 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
665 |
alert("Invalid return from getRadioState: "+i+": "+selections[i]+" ("+typeof(selections[i])+")"); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
666 |
return false; |
1 | 667 |
} |
668 |
} |
|
669 |
obj = new Object(); |
|
670 |
obj['perms'] = selections; |
|
671 |
obj['mode'] = mode; |
|
672 |
obj['target_type'] = aclDataCache.target_type; |
|
673 |
obj['target_id'] = aclDataCache.target_id; |
|
674 |
obj['target_name'] = aclDataCache.target_name; |
|
675 |
obj['page_id'] = aclDataCache.page_id; |
|
676 |
obj['namespace'] = aclDataCache.namespace; |
|
677 |
__aclJSONSubmitAjaxHandler(obj); |
|
678 |
break; |
|
679 |
default: |
|
680 |
alert("JSON form submit: invalid mode string "+mode+", stopping execution"); |
|
681 |
return false; |
|
682 |
break; |
|
683 |
} |
|
684 |
} |
|
685 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
686 |
function getRadioState(form, name, valArray) |
1 | 687 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
688 |
// Konqueror/Safari fix |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
689 |
if ( form[name] ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
690 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
691 |
var formitem = form[name]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
692 |
if ( String(formitem) == '[object DOMNamedNodesCollection]' || is_Safari ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
693 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
694 |
var i = 0; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
695 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
696 |
var radioids = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
697 |
while(true) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
698 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
699 |
var elem = formitem[i]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
700 |
if ( !elem ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
701 |
break; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
702 |
radios.push(elem); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
703 |
if ( !elem.id ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
704 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
705 |
elem.id = 'autoRadioBtn_' + Math.floor(Math.random() * 1000000); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
706 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
707 |
radioids.push(elem.id); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
708 |
i++; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
709 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
710 |
var cr; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
711 |
for ( var i = 0; i < radios.length; i++ ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
712 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
713 |
cr = document.getElementById(radioids[i]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
714 |
if ( cr.value == 'on' || cr.checked == true ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
715 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
716 |
try { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
717 |
return ( typeof ( valArray[i] ) != 'undefined' ) ? valArray[i] : false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
718 |
} catch(e) { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
719 |
// alert('Didn\'t get value for index: ' + i); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
720 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
721 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
722 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
723 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
724 |
return false; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
725 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
726 |
} |
1 | 727 |
inputs = form.getElementsByTagName('input'); |
728 |
radios = new Array(); |
|
729 |
for(var i in inputs) |
|
730 |
{ |
|
731 |
if(inputs[i]) if(inputs[i].type == 'radio') |
|
732 |
radios.push(inputs[i]); |
|
733 |
} |
|
734 |
for(var i in radios) |
|
735 |
{ |
|
736 |
if(radios[i].checked && radios[i].name == name) |
|
737 |
return radios[i].value; |
|
738 |
} |
|
739 |
return false; |
|
740 |
} |
|
741 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
742 |
function __aclSetAllRadios(val, valArray) |
1 | 743 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
744 |
val = String(val); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
745 |
var form = document.forms[aclManagerID + '_formobj']; |
1 | 746 |
if (!form) |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
747 |
{ |
1 | 748 |
return false; |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
749 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
750 |
var inputs = form.getElementsByTagName('input'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
751 |
var radios = new Array(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
752 |
var dbg = ''; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
753 |
for(var i = 0; i < inputs.length; i++) |
1 | 754 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
755 |
dbg += String(inputs[i]) + "\n"; |
1 | 756 |
if(inputs[i].type == 'radio') |
757 |
radios.push(inputs[i]); |
|
758 |
} |
|
759 |
for(var i in radios) |
|
760 |
{ |
|
761 |
if(radios[i].value == val) |
|
762 |
radios[i].checked = true; |
|
763 |
else |
|
764 |
radios[i].checked = false; |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
function __aclDeleteRule() |
|
769 |
{ |
|
42
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
770 |
if(!aclDataCache) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
771 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
772 |
if ( window.console ) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
773 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
774 |
try{ console.error('ACL editor: can\'t load data cache on delete'); } catch(e) {}; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
775 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
776 |
return false; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
777 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
778 |
if(aclDataCache.mode != 'seltarget' && aclDataCache.mode != 'save_new' && aclDataCache.mode != 'save_edit') |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
779 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
780 |
if ( window.console ) |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
781 |
{ |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
782 |
try{ console.error('ACL editor: wrong mode on aclDataCache: ' + aclDataCache.mode); } catch(e) {}; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
783 |
} |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
784 |
return false; |
45ebe475ff75
I dunno how many times I'm gonna have to fix the "problem seems to be the hex conversion" bug, but this is at least the fourth try.
Dan
parents:
40
diff
changeset
|
785 |
} |
1 | 786 |
parms = { |
787 |
'target_type' : aclDataCache.target_type, |
|
788 |
'target_id' : aclDataCache.target_id, |
|
789 |
'target_name' : aclDataCache.target_name, |
|
790 |
'page_id' : aclDataCache.page_id, |
|
791 |
'namespace' : aclDataCache.namespace, |
|
792 |
'mode' : 'delete' |
|
793 |
}; |
|
794 |
__aclJSONSubmitAjaxHandler(parms); |
|
795 |
} |
|
796 |
||
797 |
function array_keys(obj) |
|
798 |
{ |
|
799 |
keys = new Array(); |
|
800 |
for(var i in obj) |
|
801 |
keys.push(i); |
|
802 |
return keys; |
|
803 |
} |
|
804 |
||
805 |
function form_fetch_field(form, name) |
|
806 |
{ |
|
807 |
var fields = form.getElementsByTagName('input'); |
|
808 |
if ( fields.length < 1 ) |
|
809 |
return false; |
|
810 |
for ( var i = 0; i < fields.length; i++ ) |
|
811 |
{ |
|
812 |
var field = fields[i]; |
|
813 |
if ( field.name == name ) |
|
814 |
return field; |
|
815 |
} |
|
816 |
return false; |
|
817 |
} |
|
818 |