author | Dan |
Sat, 07 Jul 2007 18:33:21 -0400 | |
changeset 52 | 10ed1f728bf3 |
parent 40 | 723bb7acf914 |
child 57 | b354deeaa4c4 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* AJAX applets |
|
3 |
*/ |
|
4 |
||
5 |
function ajaxGet(uri, f) { |
|
6 |
if (window.XMLHttpRequest) { |
|
7 |
ajax = new XMLHttpRequest(); |
|
8 |
} else { |
|
9 |
if (window.ActiveXObject) { |
|
10 |
ajax = new ActiveXObject("Microsoft.XMLHTTP"); |
|
11 |
} else { |
|
12 |
alert('Enano client-side runtime error: No AJAX support, unable to continue'); |
|
13 |
return; |
|
14 |
} |
|
15 |
} |
|
16 |
ajax.onreadystatechange = f; |
|
17 |
ajax.open('GET', uri, true); |
|
18 |
ajax.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" ); |
|
19 |
ajax.send(null); |
|
20 |
} |
|
21 |
||
22 |
function ajaxPost(uri, parms, f) { |
|
23 |
if (window.XMLHttpRequest) { |
|
24 |
ajax = new XMLHttpRequest(); |
|
25 |
} else { |
|
26 |
if (window.ActiveXObject) { |
|
27 |
ajax = new ActiveXObject("Microsoft.XMLHTTP"); |
|
28 |
} else { |
|
29 |
alert('Enano client-side runtime error: No AJAX support, unable to continue'); |
|
30 |
return; |
|
31 |
} |
|
32 |
} |
|
33 |
ajax.onreadystatechange = f; |
|
34 |
ajax.open('POST', uri, true); |
|
35 |
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
32
diff
changeset
|
36 |
// Setting Content-length in Safari triggers a warning |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
32
diff
changeset
|
37 |
if ( !is_Safari ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
32
diff
changeset
|
38 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
32
diff
changeset
|
39 |
ajax.setRequestHeader("Content-length", parms.length); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
32
diff
changeset
|
40 |
} |
1 | 41 |
ajax.setRequestHeader("Connection", "close"); |
42 |
ajax.send(parms); |
|
43 |
} |
|
44 |
||
45 |
function ajaxEscape(text) |
|
46 |
{ |
|
47 |
text = escape(text); |
|
48 |
text = text.replace(/\+/g, '%2B', text); |
|
49 |
return text; |
|
50 |
} |
|
51 |
||
52 |
// Page editor |
|
53 |
||
54 |
function ajaxEditor() { |
|
55 |
setAjaxLoading(); |
|
56 |
ajaxGet(stdAjaxPrefix+'&_mode=getsource', function() { |
|
57 |
if(ajax.readyState == 4) { |
|
58 |
unsetAjaxLoading(); |
|
59 |
if(edit_open) { |
|
60 |
c=confirm('Do you really want to revert your changes?'); |
|
61 |
if(!c) return; |
|
62 |
} |
|
63 |
edit_open = true; |
|
64 |
selectButtonMajor('article'); |
|
65 |
selectButtonMinor('edit'); |
|
66 |
if(in_array('ajaxEditArea', grippied_textareas)) |
|
67 |
{ |
|
68 |
// Allow the textarea grippifier to re-create the resizer control on the textarea |
|
69 |
grippied_textareas.pop(in_array('ajaxEditArea', grippied_textareas)); |
|
70 |
} |
|
71 |
disableUnload('If you do, any changes that you have made to this page will be lost.'); |
|
72 |
var switcher = ( readCookie('enano_editor_mode') == 'tinymce' ) ? |
|
73 |
'<a href="#" onclick="setEditorText(); return false;">wikitext editor</a> | graphical editor' : |
|
74 |
'wikitext editor | <a href="#" onclick="setEditorMCE(); return false;">graphical editor</a>' ; |
|
75 |
document.getElementById('ajaxEditContainer').innerHTML = '\ |
|
76 |
<div id="mdgPreviewContainer"></div> \ |
|
77 |
<span id="switcher">' + switcher + '</span><br />\ |
|
78 |
<form name="mdgAjaxEditor" method="get" action="#" onsubmit="ajaxSavePage(); return false;">\ |
|
79 |
<textarea id="ajaxEditArea" rows="20" cols="60" style="display: block; margin: 1em 0 1em 1em; width: 96.5%;">'+ajax.responseText+'</textarea><br />\ |
|
80 |
Edit summary: <input id="ajaxEditSummary" size="40" /><br />\ |
|
81 |
<input id="ajaxEditMinor" name="minor" type="checkbox" /> <label for="ajaxEditMinor">This is a minor edit</label><br />\ |
|
82 |
<a href="#" onclick="void(ajaxSavePage()); return false;">save changes</a> | <a href="#" onclick="void(ajaxShowPreview()); return false;">preview changes</a> | <a href="#" onclick="void(ajaxEditor()); return false;">revert changes</a> | <a href="#" onclick="void(ajaxDiscard()); return false;">discard changes</a> | <a href="#" onclick="ajaxWikiEditHelp(); return false;">formatting help</a>\ |
|
83 |
<br />\ |
|
84 |
'+editNotice+'\ |
|
85 |
</form>'; |
|
86 |
// initTextareas(); |
|
87 |
if(readCookie('enano_editor_mode') == 'tinymce') |
|
88 |
{ |
|
89 |
$('ajaxEditArea').switchToMCE(); |
|
90 |
} |
|
91 |
} |
|
92 |
}); |
|
93 |
} |
|
94 |
||
95 |
function setEditorMCE() |
|
96 |
{ |
|
97 |
$('ajaxEditArea').switchToMCE(); |
|
98 |
createCookie('enano_editor_mode', 'tinymce', 365); |
|
99 |
$('switcher').object.innerHTML = '<a href="#" onclick="setEditorText(); return false;">wikitext editor</a> | graphical editor'; |
|
100 |
} |
|
101 |
||
102 |
function setEditorText() |
|
103 |
{ |
|
104 |
$('ajaxEditArea').destroyMCE(); |
|
105 |
createCookie('enano_editor_mode', 'text', 365); |
|
106 |
$('switcher').object.innerHTML = 'wikitext editor | <a href="#" onclick="setEditorMCE(); return false;">graphical editor</a>'; |
|
107 |
} |
|
108 |
||
109 |
function ajaxViewSource() { |
|
110 |
setAjaxLoading(); |
|
111 |
ajaxGet(stdAjaxPrefix+'&_mode=getsource', function() { |
|
112 |
if(ajax.readyState == 4) { |
|
113 |
unsetAjaxLoading(); |
|
114 |
if(edit_open) { |
|
115 |
c=confirm('Do you really want to revert your changes?'); |
|
116 |
if(!c) return; |
|
117 |
} |
|
118 |
edit_open = true; |
|
119 |
selectButtonMajor('article'); |
|
120 |
selectButtonMinor('edit'); |
|
121 |
if(in_array('ajaxEditArea', grippied_textareas)) |
|
122 |
{ |
|
123 |
// Allow the textarea grippifier to re-create the resizer control on the textarea |
|
124 |
grippied_textareas.pop(in_array('ajaxEditArea', grippied_textareas)); |
|
125 |
} |
|
126 |
document.getElementById('ajaxEditContainer').innerHTML = '\ |
|
127 |
<form method="get" action="#" onsubmit="ajaxSavePage(); return false;">\ |
|
128 |
<textarea readonly="readonly" id="ajaxEditArea" rows="20" cols="60" style="display: block; margin: 1em 0 1em 1em; width: 96.5%;">'+ajax.responseText+'</textarea><br />\ |
|
129 |
<a href="#" onclick="void(ajaxReset()); return false;">close viewer</a>\ |
|
130 |
</form>'; |
|
131 |
initTextareas(); |
|
132 |
} |
|
133 |
}); |
|
134 |
} |
|
135 |
||
136 |
function ajaxShowPreview() |
|
137 |
{ |
|
138 |
goBusy('Loading preview...'); |
|
139 |
var text = ajaxEscape($('ajaxEditArea').getContent()); |
|
140 |
if(document.mdgAjaxEditor.minor.checked) minor='&minor'; |
|
141 |
else minor=''; |
|
142 |
ajaxPost(stdAjaxPrefix+'&_mode=preview', 'summary='+document.getElementById('ajaxEditSummary').value+minor+'&text='+text, function() { |
|
143 |
if(ajax.readyState == 4) { |
|
144 |
unBusy(); |
|
145 |
edit_open = false; |
|
146 |
document.getElementById('mdgPreviewContainer').innerHTML = ajax.responseText; |
|
147 |
} |
|
148 |
}); |
|
149 |
} |
|
150 |
||
151 |
function ajaxSavePage() { |
|
152 |
goBusy('Saving page...'); |
|
153 |
var text = ajaxEscape($('ajaxEditArea').getContent()); |
|
154 |
if(document.mdgAjaxEditor.minor.checked) minor='&minor'; |
|
155 |
else minor=''; |
|
156 |
ajaxPost(stdAjaxPrefix+'&_mode=savepage', 'summary='+document.getElementById('ajaxEditSummary').value+minor+'&text='+text, function() { |
|
157 |
if(ajax.readyState == 4) { |
|
158 |
unBusy(); |
|
159 |
edit_open = false; |
|
160 |
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText; |
|
161 |
enableUnload(); |
|
162 |
unselectAllButtonsMinor(); |
|
163 |
} |
|
164 |
}); |
|
165 |
} |
|
166 |
||
167 |
function ajaxDiscard() { |
|
168 |
c = confirm('Do you really want to discard your changes?'); |
|
169 |
if(!c) return; |
|
170 |
ajaxReset(); |
|
171 |
} |
|
172 |
||
173 |
function ajaxReset() { |
|
174 |
enableUnload(); |
|
175 |
setAjaxLoading(); |
|
176 |
ajaxGet(stdAjaxPrefix+'&_mode=getpage&noheaders', function() { |
|
177 |
if(ajax.readyState == 4) { |
|
178 |
unsetAjaxLoading(); |
|
179 |
edit_open = false; |
|
180 |
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText; |
|
181 |
selectButtonMajor('article'); |
|
182 |
unselectAllButtonsMinor(); |
|
183 |
} |
|
184 |
}); |
|
185 |
} |
|
186 |
||
187 |
// Miscellaneous AJAX applets |
|
188 |
||
189 |
function ajaxProtect(l) { |
|
190 |
if(shift) { |
|
191 |
r = 'NO_REASON'; |
|
192 |
} else { |
|
193 |
r = prompt('Reason for (un)protecting:'); |
|
194 |
if(!r || r=='') return; |
|
195 |
} |
|
196 |
setAjaxLoading(); |
|
197 |
document.getElementById('protbtn_0').style.textDecoration = 'none'; |
|
198 |
document.getElementById('protbtn_1').style.textDecoration = 'none'; |
|
199 |
document.getElementById('protbtn_2').style.textDecoration = 'none'; |
|
200 |
document.getElementById('protbtn_'+l).style.textDecoration = 'underline'; |
|
201 |
ajaxPost(stdAjaxPrefix+'&_mode=protect', 'reason='+escape(r)+'&level='+l, function() { |
|
202 |
if(ajax.readyState == 4) { |
|
203 |
unsetAjaxLoading(); |
|
204 |
if(ajax.responseText != 'good') |
|
205 |
alert(ajax.responseText); |
|
206 |
} |
|
207 |
}); |
|
208 |
} |
|
209 |
||
210 |
function ajaxRename() { |
|
211 |
r = prompt('What title should this page be renamed to?\nNote: This does not and will never change the URL of this page, that must be done from the admin panel.'); |
|
212 |
if(!r || r=='') return; |
|
213 |
setAjaxLoading(); |
|
214 |
ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+escape(r), function() { |
|
215 |
if(ajax.readyState == 4) { |
|
216 |
unsetAjaxLoading(); |
|
217 |
alert(ajax.responseText); |
|
218 |
} |
|
219 |
}); |
|
220 |
} |
|
221 |
||
222 |
function ajaxMakePage() { |
|
223 |
setAjaxLoading(); |
|
224 |
ajaxPost(ENANO_SPECIAL_CREATEPAGE, ENANO_CREATEPAGE_PARAMS, function() { |
|
225 |
if(ajax.readyState == 4) { |
|
226 |
unsetAjaxLoading(); |
|
227 |
window.location.reload(); |
|
228 |
} |
|
229 |
}); |
|
230 |
} |
|
231 |
||
232 |
function ajaxDeletePage() { |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
30
diff
changeset
|
233 |
var reason = prompt('Please enter your reason for deleting this page.'); |
28 | 234 |
if ( !reason || reason == '' ) |
235 |
{ |
|
236 |
return false; |
|
237 |
} |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
30
diff
changeset
|
238 |
c = confirm('You are about to REVERSIBLY delete this page. Do you REALLY want to do this?\n\n(Comments and categorization data, as well as any attached files, will be permanently lost)'); |
28 | 239 |
if(!c) |
240 |
{ |
|
241 |
return; |
|
242 |
} |
|
1 | 243 |
setAjaxLoading(); |
28 | 244 |
ajaxPost(stdAjaxPrefix+'&_mode=deletepage', 'reason=' + escape(reason), function() { |
1 | 245 |
if(ajax.readyState == 4) { |
246 |
unsetAjaxLoading(); |
|
247 |
alert(ajax.responseText); |
|
248 |
window.location.reload(); |
|
249 |
} |
|
250 |
}); |
|
251 |
} |
|
252 |
||
253 |
function ajaxDelVote() { |
|
254 |
c = confirm('Are you sure that you want to vote that this page be deleted?'); |
|
255 |
if(!c) return; |
|
256 |
setAjaxLoading(); |
|
257 |
ajaxGet(stdAjaxPrefix+'&_mode=delvote', function() { |
|
258 |
if(ajax.readyState == 4) { |
|
259 |
unsetAjaxLoading(); |
|
260 |
alert(ajax.responseText); |
|
261 |
} |
|
262 |
}); |
|
263 |
} |
|
264 |
||
265 |
function ajaxResetDelVotes() { |
|
266 |
c = confirm('This will reset the number of votes against this page to zero. Do you really want to do this?'); |
|
267 |
if(!c) return; |
|
268 |
setAjaxLoading(); |
|
269 |
ajaxGet(stdAjaxPrefix+'&_mode=resetdelvotes', function() { |
|
270 |
if(ajax.readyState == 4) { |
|
271 |
unsetAjaxLoading(); |
|
272 |
alert(ajax.responseText); |
|
273 |
item = document.getElementById('mdgDeleteVoteNoticeBox'); |
|
274 |
if(item) |
|
275 |
{ |
|
276 |
opacity('mdgDeleteVoteNoticeBox', 100, 0, 1000); |
|
277 |
setTimeout("document.getElementById('mdgDeleteVoteNoticeBox').style.display = 'none';", 1000); |
|
278 |
} |
|
279 |
} |
|
280 |
}); |
|
281 |
} |
|
282 |
||
283 |
function ajaxSetWikiMode(val) { |
|
284 |
setAjaxLoading(); |
|
285 |
document.getElementById('wikibtn_0').style.textDecoration = 'none'; |
|
286 |
document.getElementById('wikibtn_1').style.textDecoration = 'none'; |
|
287 |
document.getElementById('wikibtn_2').style.textDecoration = 'none'; |
|
288 |
document.getElementById('wikibtn_'+val).style.textDecoration = 'underline'; |
|
289 |
ajaxGet(stdAjaxPrefix+'&_mode=setwikimode&mode='+val, function() { |
|
290 |
if(ajax.readyState == 4) { |
|
291 |
unsetAjaxLoading(); |
|
292 |
if(ajax.responseText!='GOOD') |
|
293 |
{ |
|
294 |
alert(ajax.responseText); |
|
295 |
} |
|
296 |
} |
|
297 |
}); |
|
298 |
} |
|
299 |
||
300 |
// Editing/saving category information |
|
301 |
// This was not easy to write, I hope enjoy it, and dang I swear I'm gonna |
|
302 |
// find someone to work on just the Javascript part of Enano... |
|
303 |
||
304 |
function ajaxCatEdit() { |
|
305 |
setAjaxLoading(); |
|
306 |
ajaxGet(stdAjaxPrefix+'&_mode=catedit', function() { |
|
307 |
if(ajax.readyState == 4) { |
|
308 |
unsetAjaxLoading(); |
|
309 |
edit_open = false; |
|
310 |
eval(ajax.responseText); |
|
311 |
} |
|
312 |
}); |
|
313 |
} |
|
314 |
||
315 |
function ajaxCatSave() |
|
316 |
{ |
|
317 |
if(!catlist) |
|
318 |
{ |
|
319 |
alert('Var catlist has no properties'); |
|
320 |
return; |
|
321 |
} |
|
322 |
query=''; |
|
323 |
for(i=0;i<catlist.length;i++) |
|
324 |
{ |
|
325 |
l = 'if(document.forms.mdgCatForm.mdgCat_'+catlist[i]+'.checked) s = true; else s = false;'; |
|
326 |
eval(l); |
|
327 |
if(s) query = query + '&' + catlist[i] + '=true'; |
|
328 |
} |
|
329 |
setAjaxLoading(); |
|
330 |
query = query.substring(1, query.length); |
|
331 |
ajaxPost(stdAjaxPrefix+'&_mode=catsave', query, function() { |
|
332 |
if(ajax.readyState == 4) { |
|
333 |
unsetAjaxLoading(); |
|
334 |
edit_open = false; |
|
335 |
if(ajax.responseText != 'GOOD') alert(ajax.responseText); |
|
336 |
ajaxReset(); |
|
337 |
} |
|
338 |
}); |
|
339 |
} |
|
340 |
||
341 |
// History stuff |
|
342 |
||
343 |
function ajaxHistory() { |
|
344 |
setAjaxLoading(); |
|
345 |
ajaxGet(stdAjaxPrefix+'&_mode=histlist', function() { |
|
346 |
if(ajax.readyState == 4) { |
|
347 |
unsetAjaxLoading(); |
|
348 |
edit_open = false; |
|
349 |
selectButtonMajor('article'); |
|
350 |
selectButtonMinor('history'); |
|
351 |
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText; |
|
352 |
buildDiffList(); |
|
353 |
} |
|
354 |
}); |
|
355 |
} |
|
356 |
||
357 |
function ajaxHistView(oldid, tit) { |
|
358 |
if(!tit) tit=title; |
|
359 |
setAjaxLoading(); |
|
360 |
ajaxGet(append_sid(scriptPath+'/ajax.php?title='+tit+'&_mode=getpage&oldid='+oldid), function() { |
|
361 |
if(ajax.readyState == 4) { |
|
362 |
unsetAjaxLoading(); |
|
363 |
edit_open = false; |
|
364 |
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText; |
|
365 |
} |
|
366 |
}); |
|
367 |
} |
|
368 |
||
369 |
function ajaxRollback(id) { |
|
370 |
setAjaxLoading(); |
|
371 |
ajaxGet(stdAjaxPrefix+'&_mode=rollback&id='+id, function() { |
|
372 |
if(ajax.readyState == 4) { |
|
373 |
unsetAjaxLoading(); |
|
374 |
alert(ajax.responseText); |
|
375 |
} |
|
376 |
}); |
|
377 |
} |
|
378 |
||
379 |
function ajaxClearLogs() { |
|
380 |
c = confirm('You are about to DESTROY all log entries for this page. As opposed to (example) deleting this page, this action is completely IRREVERSIBLE and should not be used except in dire circumstances. Do you REALLY want to do this?'); |
|
381 |
if(!c) return; |
|
382 |
c = confirm('You\'re ABSOLUTELY sure???'); |
|
383 |
if(!c) return; |
|
384 |
setAjaxLoading(); |
|
385 |
ajaxGet(stdAjaxPrefix+'&_mode=flushlogs', function() { |
|
386 |
if(ajax.readyState == 4) { |
|
387 |
unsetAjaxLoading(); |
|
388 |
alert(ajax.responseText); |
|
389 |
window.location.reload(); |
|
390 |
} |
|
391 |
}); |
|
392 |
} |
|
393 |
||
394 |
var timelist; |
|
395 |
||
396 |
function buildDiffList() |
|
397 |
{ |
|
398 |
arrDiff1Buttons = getElementsByClassName(document, 'input', 'clsDiff1Radio'); |
|
399 |
arrDiff2Buttons = getElementsByClassName(document, 'input', 'clsDiff2Radio'); |
|
400 |
var len = arrDiff1Buttons.length; |
|
401 |
if ( len < 1 ) |
|
402 |
return false; |
|
403 |
timelist = new Array(); |
|
404 |
for ( var i = 0; i < len; i++ ) |
|
405 |
{ |
|
406 |
timelist.push( arrDiff2Buttons[i].id.substr(6) ); |
|
407 |
} |
|
408 |
timelist.push( arrDiff1Buttons[len-1].id.substr(6) ); |
|
409 |
delete(timelist.toJSONString); |
|
410 |
for ( var i = 1; i < timelist.length-1; i++ ) |
|
411 |
{ |
|
412 |
if ( i >= timelist.length ) break; |
|
413 |
arrDiff2Buttons[i].style.display = 'none'; |
|
414 |
} |
|
415 |
} |
|
416 |
||
417 |
function selectDiff1Button(obj) |
|
418 |
{ |
|
419 |
var this_time = obj.id.substr(6); |
|
420 |
var index = parseInt(in_array(this_time, timelist)); |
|
421 |
for ( var i = 0; i < timelist.length - 1; i++ ) |
|
422 |
{ |
|
423 |
if ( i < timelist.length - 1 ) |
|
424 |
{ |
|
425 |
var state = ( i < index ) ? 'inline' : 'none'; |
|
426 |
var id = 'diff2_' + timelist[i]; |
|
427 |
document.getElementById(id).style.display = state; |
|
428 |
||
429 |
// alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i); |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
||
434 |
function selectDiff2Button(obj) |
|
435 |
{ |
|
436 |
var this_time = obj.id.substr(6); |
|
437 |
var index = parseInt(in_array(this_time, timelist)); |
|
438 |
for ( var i = 1; i < timelist.length; i++ ) |
|
439 |
{ |
|
440 |
if ( i < timelist.length - 1 ) |
|
441 |
{ |
|
442 |
var state = ( i > index ) ? 'inline' : 'none'; |
|
443 |
var id = 'diff1_' + timelist[i]; |
|
444 |
document.getElementById(id).style.display = state; |
|
445 |
||
446 |
// alert("Debug:\nIndex: "+index+"\nState: "+state+"\ni: "+i); |
|
447 |
} |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
function ajaxHistDiff() |
|
452 |
{ |
|
453 |
var id1=false; |
|
454 |
var id2=false; |
|
455 |
for ( i = 0; i < arrDiff1Buttons.length; i++ ) |
|
456 |
{ |
|
457 |
k = i + ''; |
|
458 |
kpp = i + 1; |
|
459 |
kpp = kpp + ''; |
|
460 |
if(arrDiff1Buttons[k].checked) id1 = arrDiff1Buttons[k].id.substr(6); |
|
461 |
if(arrDiff2Buttons[k].checked) id2 = arrDiff2Buttons[k].id.substr(6); |
|
462 |
} |
|
463 |
if(!id1 || !id2) { alert('BUG: Couldn\'t get checked radiobutton state'); return; } |
|
464 |
setAjaxLoading(); |
|
465 |
ajaxGet(stdAjaxPrefix+'&_mode=pagediff&diff1='+id1+'&diff2='+id2, function() |
|
466 |
{ |
|
467 |
if(ajax.readyState==4) |
|
468 |
{ |
|
469 |
unsetAjaxLoading(); |
|
470 |
document.getElementById('ajaxEditContainer').innerHTML = ajax.responseText; |
|
471 |
} |
|
472 |
}); |
|
473 |
} |
|
474 |
||
475 |
// Change the user's preferred style/theme |
|
476 |
||
477 |
function ajaxChangeStyle() |
|
478 |
{ |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
479 |
var inner_html = ''; |
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
480 |
inner_html += '<p><label>Theme: '; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
481 |
inner_html += ' <select id="chtheme_sel_theme" onchange="ajaxGetStyles(this.value);">'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
482 |
inner_html += ' <option value="_blank" selected="selected">[Select]</option>'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
483 |
inner_html += ENANO_THEME_LIST; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
484 |
inner_html += ' </select>'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
485 |
inner_html += '</label></p>'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
486 |
var chtheme_mb = new messagebox(MB_OKCANCEL|MB_ICONQUESTION, 'Change your theme', inner_html); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
487 |
chtheme_mb.onbeforeclick['OK'] = ajaxChangeStyleComplete; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
488 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
489 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
490 |
function ajaxGetStyles(id) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
491 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
492 |
var thediv = document.getElementById('chtheme_sel_style_parent'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
493 |
if ( thediv ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
494 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
495 |
thediv.parentNode.removeChild(thediv); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
496 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
497 |
if ( id == '_blank' ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
498 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
499 |
return null; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
500 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
501 |
ajaxGet(stdAjaxPrefix + '&_mode=getstyles&id=' + id, function() { |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
502 |
if ( ajax.readyState == 4 ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
503 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
504 |
// IE doesn't like substr() on ajax.responseText |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
505 |
var response = String(ajax.responseText + ' '); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
506 |
response = response.substr(0, response.length - 1); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
507 |
if ( response.substr(0,1) != '[' ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
508 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
509 |
alert('Invalid or unexpected JSON response from server:\n' + response); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
510 |
return null; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
511 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
512 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
513 |
// Build a selector and matching label |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
514 |
var data = parseJSON(response); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
515 |
var options = new Array(); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
516 |
for( var i in data ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
517 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
518 |
var item = data[i]; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
519 |
var title = themeid_to_title(item); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
520 |
var option = document.createElement('option'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
521 |
option.value = item; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
522 |
option.appendChild(document.createTextNode(title)); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
523 |
options.push(option); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
524 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
525 |
var p_parent = document.createElement('p'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
526 |
var label = document.createElement('label'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
527 |
p_parent.id = 'chtheme_sel_style_parent'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
528 |
label.appendChild(document.createTextNode('Style: ')); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
529 |
var select = document.createElement('select'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
530 |
select.id = 'chtheme_sel_style'; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
531 |
for ( var i in options ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
532 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
533 |
select.appendChild(options[i]); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
534 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
535 |
label.appendChild(select); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
536 |
p_parent.appendChild(label); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
537 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
538 |
// Stick it onto the messagebox |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
539 |
var div = document.getElementById('messageBox'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
540 |
var kid = div.firstChild.nextSibling; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
541 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
542 |
kid.appendChild(p_parent); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
543 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
544 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
545 |
}); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
546 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
547 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
548 |
function ajaxChangeStyleComplete() |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
549 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
550 |
var theme = $('chtheme_sel_theme'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
551 |
var style = $('chtheme_sel_style'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
552 |
if ( !theme.object || !style.object ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
553 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
554 |
alert('Please select a theme from the list.'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
555 |
return true; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
556 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
557 |
var theme_id = theme.object.value; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
558 |
var style_id = style.object.value; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
559 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
560 |
if ( typeof(theme_id) != 'string' || typeof(style_id) != 'string' ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
561 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
562 |
alert('Couldn\'t get theme or style ID'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
563 |
return true; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
564 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
565 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
566 |
if ( theme_id.length < 1 || style_id.length < 1 ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
567 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
568 |
alert('Theme or style ID is zero length'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
569 |
return true; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
570 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
571 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
572 |
ajaxPost(stdAjaxPrefix + '&_mode=change_theme', 'theme_id=' + escape(theme_id) + '&style_id=' + escape(style_id), function() |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
573 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
574 |
if ( ajax.readyState == 4 ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
575 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
576 |
if ( ajax.responseText == 'GOOD' ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
577 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
578 |
var c = confirm('Your theme preference has been changed.\nWould you like to reload the page now to see the changes?'); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
579 |
if ( c ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
580 |
window.location.reload(); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
581 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
582 |
else |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
583 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
584 |
alert('Error occurred during attempt to change theme:\n' + ajax.responseText); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
585 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
586 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
587 |
}); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
588 |
|
30 | 589 |
return false; |
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
590 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
591 |
} |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
592 |
|
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
593 |
function themeid_to_title(id) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
594 |
{ |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
595 |
if ( typeof(id) != 'string' ) |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
596 |
return false; |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
597 |
id = id.substr(0, 1).toUpperCase() + id.substr(1); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
598 |
id = id.replace(/_/g, ' '); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
599 |
id = id.replace(/-/g, ' '); |
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
parents:
28
diff
changeset
|
600 |
return id; |
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
601 |
} |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
602 |
|
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
603 |
/* |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
604 |
function ajaxChangeStyle() |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
605 |
{ |
1 | 606 |
var win = document.getElementById("cn2"); |
607 |
win.innerHTML = ' \ |
|
608 |
<form action="'+ENANO_SPECIAL_CHANGESTYLE+'" onsubmit="jws.closeWin(\'root2\');" method="post" style="text-align: center"> \ |
|
609 |
<h3>Select a theme...</h3>\ |
|
610 |
<select id="mdgThemeID" name="theme" onchange="ajaxGetStyles(this.value);"> \ |
|
611 |
'+ENANO_THEME_LIST+' \ |
|
612 |
</select> \ |
|
613 |
<div id="styleSelector"></div>\ |
|
614 |
<br /><br />\ |
|
615 |
<input type="hidden" name="return_to" value="'+title+'" />\ |
|
616 |
<input id="styleSubmitter" type="submit" style="display: none; font-weight: bold" value="Change theme" /> \ |
|
617 |
<input type="button" value="Cancel" onclick="jws.closeWin(\'root2\');" /> \ |
|
618 |
</form> \ |
|
619 |
'; |
|
620 |
ajaxGetStyles(ENANO_CURRENT_THEME); |
|
621 |
jws.openWin('root2', 340, 300); |
|
622 |
} |
|
623 |
||
624 |
function ajaxGetStyles(id) { |
|
625 |
setAjaxLoading(); |
|
626 |
ajaxGet(stdAjaxPrefix+'&_mode=getstyles&id='+id, function() { |
|
627 |
if(ajax.readyState == 4) { |
|
628 |
unsetAjaxLoading(); |
|
629 |
eval(ajax.responseText); |
|
630 |
html = '<h3>And a style...</h3><select id="mdgStyleID" name="style">'; |
|
631 |
for(i=0;i<list.length;i++) { |
|
632 |
lname = list[i].substr(0, 1).toUpperCase() + list[i].substr(1, list[i].length); |
|
633 |
html = html + '<option value="'+list[i]+'">'+lname+'</option>'; |
|
634 |
} |
|
635 |
html = html + '</select>'; |
|
636 |
document.getElementById('styleSelector').innerHTML = html; |
|
637 |
document.getElementById('styleSubmitter').style.display = 'inline'; |
|
638 |
} |
|
639 |
}); |
|
640 |
} |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
11
diff
changeset
|
641 |
*/ |
1 | 642 |
|
643 |
function ajaxSwapCSS() { |
|
644 |
setAjaxLoading(); |
|
645 |
if(_css) { |
|
646 |
document.getElementById('mdgCss').href = main_css; |
|
647 |
_css = false; |
|
648 |
} else { |
|
649 |
document.getElementById('mdgCss').href = print_css; |
|
650 |
_css = true; |
|
651 |
} |
|
652 |
unsetAjaxLoading(); |
|
653 |
menuOff(); |
|
654 |
} |
|
655 |
||
656 |
function ajaxSetPassword() |
|
657 |
{ |
|
658 |
pass = hex_sha1(document.getElementById('mdgPassSetField').value); |
|
659 |
setAjaxLoading(); |
|
660 |
ajaxPost(stdAjaxPrefix+'&_mode=setpass', 'password='+pass, function() |
|
661 |
{ |
|
662 |
unsetAjaxLoading(); |
|
663 |
if(ajax.readyState==4) |
|
664 |
{ |
|
665 |
alert(ajax.responseText); |
|
666 |
} |
|
667 |
} |
|
668 |
); |
|
669 |
} |
|
670 |
||
671 |
function ajaxWikiEditHelp() |
|
672 |
{ |
|
673 |
jws.openWin('root3', 640, 480); |
|
674 |
setAjaxLoading(); |
|
675 |
ajaxGet(stdAjaxPrefix+'&_mode=wikihelp', function() { |
|
676 |
if(ajax.readyState==4) |
|
677 |
{ |
|
678 |
unsetAjaxLoading(); |
|
679 |
document.getElementById('cn3').innerHTML = ajax.responseText; |
|
680 |
} |
|
681 |
}); |
|
682 |
} |
|
683 |
||
684 |
function ajaxStartLogin() |
|
685 |
{ |
|
686 |
ajaxPromptAdminAuth(function(k) { |
|
687 |
window.location.reload(); |
|
688 |
}, 2); |
|
689 |
} |
|
690 |
||
691 |
function ajaxAdminPage() |
|
692 |
{ |
|
693 |
if ( auth_level < USER_LEVEL_ADMIN ) |
|
694 |
{ |
|
695 |
ajaxPromptAdminAuth(function(k) { |
|
696 |
ENANO_SID = k; |
|
697 |
auth_level = USER_LEVEL_ADMIN; |
|
698 |
var loc = String(window.location + ''); |
|
699 |
window.location = append_sid(loc); |
|
700 |
var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title)); |
|
701 |
if ( (ENANO_SID + ' ').length > 1 ) |
|
702 |
window.location = loc; |
|
703 |
}, 9); |
|
704 |
return false; |
|
705 |
} |
|
706 |
var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title)); |
|
707 |
window.location = loc; |
|
708 |
} |
|
709 |
||
11
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
710 |
function ajaxDisableEmbeddedPHP() |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
711 |
{ |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
712 |
if ( !confirm('Are you really sure you want to do this? Some pages might not function if this emergency-only feature is activated.') ) |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
713 |
return false; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
714 |
var $killdiv = $dynano('php_killer'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
715 |
if ( !$killdiv.object ) |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
716 |
{ |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
717 |
alert('Can\'t get kill div object'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
718 |
return false; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
719 |
} |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
720 |
$killdiv.object.innerHTML = '<img alt="Loading..." src="' + scriptPath + '/images/loading-big.gif" /><br />Making request...'; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
721 |
var url = makeUrlNS('Admin', 'Home', 'src=ajax'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
722 |
ajaxPost(url, 'act=kill_php', function() { |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
723 |
if ( ajax.readyState == 4 ) |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
724 |
{ |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
725 |
if ( ajax.responseText == '1' ) |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
726 |
{ |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
727 |
var $killdiv = $dynano('php_killer'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
728 |
//$killdiv.object.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.'; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
729 |
$killdiv.object.parentNode.removeChild($killdiv.object); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
730 |
var newdiv = document.createElement('div'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
731 |
// newdiv.style = $killdiv.object.style; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
732 |
newdiv.className = $killdiv.object.className; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
733 |
newdiv.innerHTML = '<img alt="Success" src="' + scriptPath + '/images/error.png" /><br />Embedded PHP in pages has been disabled.'; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
734 |
$killdiv.object.parentNode.appendChild(newdiv); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
735 |
$killdiv.object.parentNode.removeChild($killdiv.object); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
736 |
} |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
737 |
else |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
738 |
{ |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
739 |
var $killdiv = $dynano('php_killer'); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
740 |
$killdiv.object.innerHTML = ajax.responseText; |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
741 |
} |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
742 |
} |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
743 |
}); |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
744 |
} |
ccad6026a168
Finalized permissions on files and directories; adding PHP shutoff button (actual shutoff not implemented)
Dan
parents:
1
diff
changeset
|
745 |