author | Dan |
Sun, 25 Nov 2007 20:24:16 -0500 | |
changeset 238 | f948557af068 |
parent 224 | db8d5111ad20 |
child 254 | f49e3c8b638c |
permissions | -rw-r--r-- |
1 | 1 |
// Some additional DHTML functions |
2 |
||
3 |
function fetch_offset(obj) { |
|
4 |
var left_offset = obj.offsetLeft; |
|
5 |
var top_offset = obj.offsetTop; |
|
6 |
while ((obj = obj.offsetParent) != null) { |
|
7 |
left_offset += obj.offsetLeft; |
|
8 |
top_offset += obj.offsetTop; |
|
9 |
} |
|
10 |
return { 'left' : left_offset, 'top' : top_offset }; |
|
11 |
} |
|
12 |
||
13 |
function fetch_dimensions(o) { |
|
14 |
var w = o.offsetWidth; |
|
15 |
var h = o.offsetHeight; |
|
16 |
return { 'w' : w, 'h' : h }; |
|
17 |
} |
|
18 |
||
19 |
function findParentForm(o) |
|
20 |
{ |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
21 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
22 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
23 |
while(true) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
24 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
25 |
o = o.parentNode; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
26 |
if ( !o ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
27 |
return false; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
28 |
if ( o.tagName == 'FORM' ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
29 |
return o; |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
30 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
31 |
return false; |
1 | 32 |
} |
33 |
||
34 |
function ajaxReverseDNS(o, text) |
|
35 |
{ |
|
36 |
if(text) var ipaddr = text; |
|
37 |
else var ipaddr = o.innerHTML; |
|
38 |
rDnsObj = o; |
|
39 |
rDnsBannerObj = bannerOn('Retrieving reverse DNS info...'); |
|
40 |
ajaxGet(stdAjaxPrefix+'&_mode=rdns&ip='+ipaddr, function() { |
|
41 |
if(ajax.readyState == 4) |
|
42 |
{ |
|
43 |
off = fetch_offset(rDnsObj); |
|
44 |
dim = fetch_dimensions(rDnsObj); |
|
45 |
right = off['left'] + dim['w']; |
|
46 |
top = off['top'] + dim['h']; |
|
47 |
var thediv = document.createElement('div'); |
|
48 |
thediv.className = 'info-box'; |
|
49 |
thediv.style.margin = '0'; |
|
50 |
thediv.style.position = 'absolute'; |
|
51 |
thediv.style.top = top + 'px'; |
|
52 |
thediv.style.display = 'none'; |
|
53 |
thediv.style.zIndex = getHighestZ() + 2; |
|
54 |
thediv.id = 'mdgDynamic_rDnsInfoDiv_'+Math.floor(Math.random() * 1000000); |
|
55 |
thediv.innerHTML = '<b>Reverse DNS:</b><br />'+ajax.responseText+' <a href="#" onclick="elem = document.getElementById(\''+thediv.id+'\'); elem.innerHTML = \'\'; elem.style.display = \'none\';return false;">Close</a>'; |
|
56 |
var body = document.getElementsByTagName('body'); |
|
57 |
body = body[0]; |
|
58 |
bannerOff(rDnsBannerObj); |
|
59 |
body.appendChild(thediv); |
|
60 |
thediv.style.display = 'block'; |
|
61 |
left = fetch_dimensions(thediv); |
|
62 |
thediv.style.display = 'none'; |
|
63 |
left = right - left['w']; |
|
64 |
thediv.style.left = left + 'px'; |
|
65 |
thediv.style.display = 'block'; |
|
66 |
fadeInfoBoxes(); |
|
67 |
} |
|
68 |
}); |
|
69 |
} |
|
70 |
||
71 |
function bannerOn(text) |
|
72 |
{ |
|
73 |
darken(true); |
|
74 |
var thediv = document.createElement('div'); |
|
75 |
thediv.className = 'mdg-comment'; |
|
76 |
thediv.style.padding = '0'; |
|
77 |
thediv.style.marginLeft = '0'; |
|
78 |
thediv.style.position = 'absolute'; |
|
79 |
thediv.style.display = 'none'; |
|
80 |
thediv.style.padding = '4px'; |
|
81 |
thediv.style.fontSize = '14pt'; |
|
82 |
thediv.id = 'mdgDynamic_bannerDiv_'+Math.floor(Math.random() * 1000000); |
|
83 |
thediv.innerHTML = text; |
|
84 |
||
85 |
var body = document.getElementsByTagName('body'); |
|
86 |
body = body[0]; |
|
87 |
body.appendChild(thediv); |
|
88 |
body.style.cursor = 'wait'; |
|
89 |
||
90 |
thediv.style.display = 'block'; |
|
91 |
dim = fetch_dimensions(thediv); |
|
92 |
thediv.style.display = 'none'; |
|
93 |
bdim = { 'w' : getWidth(), 'h' : getHeight() }; |
|
94 |
so = getScrollOffset(); |
|
95 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
96 |
var left = (bdim['w'] / 2) - ( dim['w'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
97 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
98 |
var top = (bdim['h'] / 2); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
99 |
top = top - ( dim['h'] / 2 ); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
100 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
101 |
top = top + so; |
1 | 102 |
|
103 |
thediv.style.top = top + 'px'; |
|
104 |
thediv.style.left = left + 'px'; |
|
105 |
||
106 |
thediv.style.display = 'block'; |
|
107 |
||
108 |
return thediv.id; |
|
109 |
} |
|
110 |
||
111 |
function bannerOff(id) |
|
112 |
{ |
|
113 |
e = document.getElementById(id); |
|
114 |
if(!e) return; |
|
115 |
e.innerHTML = ''; |
|
116 |
e.style.display = 'none'; |
|
117 |
var body = document.getElementsByTagName('body'); |
|
118 |
body = body[0]; |
|
119 |
body.style.cursor = 'default'; |
|
120 |
enlighten(true); |
|
121 |
} |
|
122 |
||
123 |
function disableUnload(message) |
|
124 |
{ |
|
125 |
if(typeof message != 'string') message = 'You may want to save your changes first.'; |
|
126 |
var body = document.getElementsByTagName('body'); |
|
127 |
body = body[0]; |
|
128 |
body.onbeforeunload='return unescape(\''+escape(message)+'\')'; |
|
129 |
} |
|
130 |
||
131 |
function enableUnload() |
|
132 |
{ |
|
133 |
var body = document.getElementsByTagName('body'); |
|
134 |
body = body[0]; |
|
135 |
body.onbeforeunload = null; |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* Gets the highest z-index of all divs in the document |
|
140 |
* @return integer |
|
141 |
*/ |
|
142 |
function getHighestZ() |
|
143 |
{ |
|
144 |
z = 0; |
|
145 |
var divs = document.getElementsByTagName('div'); |
|
146 |
for(var i = 0; i < divs.length; i++) |
|
147 |
{ |
|
148 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
|
149 |
} |
|
150 |
return z; |
|
151 |
} |
|
152 |
||
153 |
function isKeyPressed(event) |
|
154 |
{ |
|
155 |
if (event.shiftKey==1) |
|
156 |
{ |
|
157 |
shift = true; |
|
158 |
} |
|
159 |
else |
|
160 |
{ |
|
161 |
shift = false; |
|
162 |
} |
|
163 |
} |
|
164 |
||
165 |
function moveDiv(div, newparent) |
|
166 |
{ |
|
167 |
var backup = div; |
|
168 |
var oldparent = div.parentNode; |
|
169 |
oldparent.removeChild(div); |
|
170 |
newparent.appendChild(backup); |
|
171 |
} |
|
172 |
||
173 |
function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;} |
|
174 |
function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";} |
|
175 |
function eraseCookie(name) {createCookie(name,"",-1);} |
|
176 |
||
177 |
var busyBannerID; |
|
178 |
function goBusy(msg) |
|
179 |
{ |
|
180 |
if(!msg) msg = 'Please wait...'; |
|
181 |
body = document.getElementsByTagName('body'); |
|
182 |
body = body[0]; |
|
183 |
body.style.cursor = 'wait'; |
|
184 |
busyBannerID = bannerOn(msg); |
|
185 |
} |
|
186 |
||
187 |
function unBusy() |
|
188 |
{ |
|
189 |
body = document.getElementsByTagName('body'); |
|
190 |
body = body[0]; |
|
191 |
body.style.cursor = 'default'; |
|
192 |
bannerOff(busyBannerID); |
|
193 |
} |
|
194 |
||
195 |
function setAjaxLoading() |
|
196 |
{ |
|
197 |
if ( document.getElementById('ajaxloadicon') ) |
|
198 |
{ |
|
188
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents:
172
diff
changeset
|
199 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
1 | 200 |
} |
201 |
} |
|
202 |
||
203 |
function unsetAjaxLoading() |
|
204 |
{ |
|
205 |
if ( document.getElementById('ajaxloadicon') ) |
|
206 |
{ |
|
207 |
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif'; |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
/* |
|
212 |
* Search boxes |
|
213 |
*/ |
|
214 |
||
215 |
function buildSearchBoxes() |
|
216 |
{ |
|
217 |
var divs = document.getElementsByTagName('*'); |
|
218 |
var boxes = new Array(); |
|
219 |
for ( var i = 0; i < divs.length; i++ ) |
|
220 |
{ |
|
221 |
if ( divs[i].className) |
|
222 |
{ |
|
223 |
if ( divs[i].className.substr(0, 9) == 'searchbox' ) |
|
224 |
{ |
|
225 |
boxes.push(divs[i]); |
|
226 |
} |
|
227 |
} |
|
228 |
} |
|
229 |
for ( var i = 0; i < boxes.length; i++ ) |
|
230 |
{ |
|
231 |
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) ) |
|
232 |
{ |
|
233 |
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/); |
|
234 |
width = parseInt(width[1]); |
|
235 |
} |
|
236 |
else |
|
237 |
{ |
|
238 |
var width = 120; |
|
239 |
} |
|
240 |
createSearchBox(boxes[i], width); |
|
241 |
} |
|
242 |
} |
|
243 |
||
244 |
function createSearchBox(parent, width) |
|
245 |
{ |
|
246 |
if ( typeof(parent) != 'object') |
|
247 |
{ |
|
248 |
alert('BUG: createSearchBox(): parent is not an object'); |
|
249 |
return false; |
|
250 |
} |
|
251 |
//parent.style.padding = '0px'; |
|
252 |
//parent.style.textAlign = 'center'; |
|
253 |
parent.style.width = width + 'px'; |
|
254 |
var submit = document.createElement('div'); |
|
255 |
submit.onclick = function() { searchFormSubmit(this); }; |
|
256 |
submit.className = 'js-search-submit'; |
|
257 |
var input = document.createElement('input'); |
|
258 |
input.className = 'js-search-box'; |
|
259 |
input.value = 'Search'; |
|
260 |
input.name = 'q'; |
|
261 |
input.style.width = ( width - 28 ) + 'px'; |
|
262 |
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; }; |
|
263 |
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; }; |
|
264 |
parent.appendChild(input); |
|
265 |
var off = fetch_offset(input); |
|
266 |
var top = off['top'] + 'px'; |
|
267 |
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px'; |
|
268 |
submit.style.top = top; |
|
269 |
submit.style.left = left; |
|
270 |
parent.appendChild(submit); |
|
271 |
} |
|
272 |
||
273 |
function searchFormSubmit(obj) |
|
274 |
{ |
|
275 |
var input = obj.previousSibling; |
|
276 |
if ( input.value == 'Search' || input.value == '' ) |
|
277 |
return false; |
|
278 |
var p = obj; |
|
279 |
while(true) |
|
280 |
{ |
|
281 |
p = p.parentNode; |
|
282 |
if ( !p ) |
|
283 |
break; |
|
284 |
if ( typeof(p.tagName) != 'string' ) |
|
285 |
break; |
|
286 |
else if ( p.tagName.toLowerCase() == 'form' ) |
|
287 |
{ |
|
288 |
p.submit(); |
|
289 |
} |
|
290 |
else if ( p.tagName.toLowerCase() == 'body' ) |
|
291 |
{ |
|
292 |
break; |
|
293 |
} |
|
294 |
} |
|
295 |
} |
|
296 |
||
297 |
/* |
|
298 |
* AJAX login box (experimental) |
|
299 |
*/ |
|
300 |
||
301 |
var ajax_auth_prompt_cache = false; |
|
302 |
var ajax_auth_mb_cache = false; |
|
303 |
var ajax_auth_level_cache = false; |
|
170
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
304 |
var ajax_auth_error_string = false; |
1 | 305 |
|
306 |
function ajaxPromptAdminAuth(call_on_ok, level) |
|
307 |
{ |
|
308 |
if ( typeof(call_on_ok) == 'function' ) |
|
309 |
{ |
|
310 |
ajax_auth_prompt_cache = call_on_ok; |
|
311 |
} |
|
312 |
if ( !level ) |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
313 |
level = USER_LEVEL_MEMBER; |
1 | 314 |
ajax_auth_level_cache = level; |
315 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
316 |
<p>Fetching an encryption key...</p> \ |
|
317 |
<p><small>Not working? Use the <a href="'+makeUrlNS('Special', 'Login/' + title)+'">alternate login form</a>.</p> \ |
|
318 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
|
319 |
</div>'; |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
320 |
var title = ( level > USER_LEVEL_MEMBER ) ? 'You are requesting a sensitive operation.' : 'Please enter your username and password to continue.'; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
321 |
ajax_auth_mb_cache = new messagebox(MB_OKCANCEL|MB_ICONLOCK, title, loading_win); |
1 | 322 |
ajax_auth_mb_cache.onbeforeclick['OK'] = ajaxValidateLogin; |
323 |
ajaxAuthLoginInnerSetup(); |
|
324 |
} |
|
325 |
||
326 |
function ajaxAuthLoginInnerSetup() |
|
327 |
{ |
|
224
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
328 |
// let's hope this gets the image cached |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
329 |
var _ = new Image(32, 32); |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
330 |
_.src = scriptPath + "/images/good.gif"; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
331 |
|
1 | 332 |
ajaxGet(makeUrlNS('Special', 'Login', 'act=getkey'), function() { |
333 |
if ( ajax.readyState == 4 ) |
|
334 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
335 |
var response = String(ajax.responseText); |
1 | 336 |
if ( response.substr(0,1) != '{' ) |
337 |
{ |
|
338 |
alert('Invalid JSON response from server: ' + response); |
|
339 |
return false; |
|
340 |
} |
|
341 |
response = parseJSON(response); |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
342 |
var level = ajax_auth_level_cache; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
343 |
var form_html = ''; |
172 | 344 |
var shown_error = false; |
170
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
345 |
if ( ajax_auth_error_string ) |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
346 |
{ |
172 | 347 |
shown_error = true; |
348 |
form_html += '<div class="error-box-mini" id="ajax_auth_error">' + ajax_auth_error_string + '</div>'; |
|
170
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
349 |
ajax_auth_error_string = false; |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
350 |
} |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
351 |
else if ( level > USER_LEVEL_MEMBER ) |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
352 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
353 |
form_html += 'Please re-enter your login details, to verify your identity.<br /><br />'; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
354 |
} |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
355 |
form_html += ' \ |
1 | 356 |
<table border="0" align="center"> \ |
357 |
<tr> \ |
|
358 |
<td>Username:</td><td><input tabindex="1" id="ajaxlogin_user" type="text" size="25" /> \ |
|
359 |
</tr> \ |
|
360 |
<tr> \ |
|
361 |
<td>Password:</td><td><input tabindex="2" id="ajaxlogin_pass" type="password" size="25" /> \ |
|
362 |
</tr> \ |
|
363 |
<tr> \ |
|
364 |
<td colspan="2" style="text-align: center;"> \ |
|
172 | 365 |
<br /><small>Trouble logging in? Try the <a href="'+makeUrlNS('Special', 'Login/' + title, 'level=' + level)+'">full login form</a>.<br />'; |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
366 |
if ( level <= USER_LEVEL_MEMBER ) |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
367 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
368 |
form_html += ' \ |
1 | 369 |
Did you <a href="'+makeUrlNS('Special', 'PasswordReset')+'">forget your password</a>?<br /> \ |
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
370 |
Maybe you need to <a href="'+makeUrlNS('Special', 'Register')+'">create an account</a>.</small>'; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
371 |
} |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
372 |
form_html += ' \ |
1 | 373 |
</td> \ |
374 |
</tr> \ |
|
375 |
</table> \ |
|
376 |
<input type="hidden" id="ajaxlogin_crypt_key" value="' + response.key + '" /> \ |
|
377 |
<input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \ |
|
378 |
</form>'; |
|
379 |
ajax_auth_mb_cache.updateContent(form_html); |
|
380 |
$('messageBox').object.nextSibling.firstChild.tabindex = '3'; |
|
60
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
381 |
if ( typeof(response.username) == 'string' ) |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
382 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
383 |
$('ajaxlogin_user').object.value = response.username; |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
384 |
$('ajaxlogin_pass').object.focus(); |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
385 |
} |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
386 |
else |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
387 |
{ |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
388 |
$('ajaxlogin_user').object.focus(); |
71b50f8c8f85
Changed administration login request to use the AJAX login form; made high-level authentication more apparent in the AJAX box; recompiled Oxygen Mint
Dan
parents:
40
diff
changeset
|
389 |
} |
9
1e61232606d6
Following fixes: admin theme supports <button> tag now, PageProcessor can eval now, and SpecialAdmin.php plugin can no longer be disabled
dan@fuhry
parents:
1
diff
changeset
|
390 |
$('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
391 |
$('ajaxlogin_pass').object.onkeypress = function(e) { if ( !e && IE ) return true; if ( e.keyCode == 13 ) $('messageBox').object.nextSibling.firstChild.click(); }; |
172 | 392 |
/* |
393 |
## This causes the background image to disappear under Fx 2 |
|
394 |
if ( shown_error ) |
|
395 |
{ |
|
396 |
// fade to #FFF4F4 |
|
397 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 1000, from: '#FFF4F4', to: '#805600', restoreColor: '#805600', finish: function() |
|
398 |
{ |
|
399 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 3000, from: '#805600', to: '#FFF4F4', restoreColor: '#FFF4F4'}); |
|
400 |
fader.start(); |
|
401 |
}}); |
|
402 |
fader.start(); |
|
403 |
} |
|
404 |
*/ |
|
1 | 405 |
} |
406 |
}); |
|
407 |
} |
|
408 |
||
409 |
function ajaxValidateLogin() |
|
410 |
{ |
|
411 |
var username,password,auth_enabled,crypt_key,crypt_data,challenge_salt,challenge_data; |
|
412 |
username = document.getElementById('ajaxlogin_user'); |
|
413 |
if ( !username ) |
|
414 |
return false; |
|
415 |
username = document.getElementById('ajaxlogin_user').value; |
|
416 |
password = document.getElementById('ajaxlogin_pass').value; |
|
417 |
auth_enabled = false; |
|
418 |
||
419 |
disableJSONExts(); |
|
420 |
||
421 |
// |
|
422 |
// Encryption test |
|
423 |
// |
|
424 |
||
425 |
var str = ''; |
|
426 |
for(i=0;i<keySizeInBits/4;i++) |
|
427 |
{ |
|
428 |
str+='0'; |
|
429 |
} |
|
430 |
str = hexToByteArray(str); |
|
431 |
var ct = rijndaelEncrypt(str, str, 'ECB'); |
|
432 |
ct = byteArrayToHex(ct); |
|
433 |
var v; |
|
434 |
switch(keySizeInBits) |
|
435 |
{ |
|
436 |
case 128: |
|
437 |
v = '66e94bd4ef8a2c3b884cfa59ca342b2e'; |
|
438 |
break; |
|
439 |
case 192: |
|
440 |
v = 'aae06992acbf52a3e8f4a96ec9300bd7aae06992acbf52a3e8f4a96ec9300bd7'; |
|
441 |
break; |
|
442 |
case 256: |
|
443 |
v = 'dc95c078a2408989ad48a21492842087dc95c078a2408989ad48a21492842087'; |
|
444 |
break; |
|
445 |
} |
|
446 |
auth_enabled = ( ct == v && md5_vm_test() ); |
|
447 |
if ( !auth_enabled ) |
|
448 |
{ |
|
449 |
alert('Login error: encryption sanity check failed\n'); |
|
450 |
return true; |
|
451 |
} |
|
452 |
||
453 |
crypt_key = document.getElementById('ajaxlogin_crypt_key').value; |
|
454 |
challenge_salt = document.getElementById('ajaxlogin_crypt_challenge').value; |
|
455 |
||
456 |
var crypt_key_md5 = hex_md5(crypt_key); |
|
457 |
||
458 |
challenge_data = hex_md5(password + challenge_salt) + challenge_salt; |
|
459 |
||
460 |
password = stringToByteArray(password); |
|
461 |
crypt_key = hexToByteArray(crypt_key); |
|
462 |
||
463 |
crypt_data = rijndaelEncrypt(password, crypt_key, 'ECB'); |
|
464 |
crypt_data = byteArrayToHex(crypt_data); |
|
465 |
||
466 |
var json_data = { |
|
467 |
'username' : username, |
|
468 |
'crypt_key' : crypt_key_md5, |
|
469 |
'challenge' : challenge_data, |
|
470 |
'crypt_data' : crypt_data, |
|
471 |
'level' : ajax_auth_level_cache |
|
472 |
}; |
|
473 |
||
474 |
json_data = toJSONString(json_data); |
|
135
c5dbad7ec2d0
Enano should now fully support UTF-8 usernames; newly registered users are now granted automatic edit access to their user pages (admins can still use protection on the page)
Dan
parents:
133
diff
changeset
|
475 |
json_data = encodeURIComponent(json_data); |
1 | 476 |
|
477 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
478 |
<p>Logging in...</p> \ |
|
479 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
|
480 |
</div>'; |
|
481 |
||
482 |
ajax_auth_mb_cache.updateContent(loading_win); |
|
483 |
||
484 |
ajaxPost(makeUrlNS('Special', 'Login', 'act=ajaxlogin'), 'params=' + json_data, function() { |
|
485 |
if ( ajax.readyState == 4 ) |
|
486 |
{ |
|
487 |
var response = ajax.responseText; |
|
488 |
if ( response.substr(0,1) != '{' ) |
|
489 |
{ |
|
490 |
alert('Invalid JSON response from server: ' + response); |
|
491 |
ajaxAuthLoginInnerSetup(); |
|
492 |
return false; |
|
493 |
} |
|
494 |
response = parseJSON(response); |
|
495 |
switch(response.result) |
|
496 |
{ |
|
497 |
case 'success': |
|
224
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
498 |
var success_win = '<div align="center" style="text-align: center;"> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
499 |
<p>Success.</p> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
500 |
<p><img alt=" " src="'+scriptPath+'/images/good.gif" /></p> \ |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
501 |
</div>'; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
188
diff
changeset
|
502 |
ajax_auth_mb_cache.updateContent(success_win); |
1 | 503 |
if ( typeof(ajax_auth_prompt_cache) == 'function' ) |
504 |
{ |
|
505 |
ajax_auth_prompt_cache(response.key); |
|
506 |
} |
|
507 |
break; |
|
508 |
case 'success_reset': |
|
509 |
var conf = confirm('You have logged in using a temporary password. Before you can log in, you must finish resetting your password. Do you want to reset your real password now?'); |
|
510 |
if ( conf ) |
|
511 |
{ |
|
512 |
var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temppass); |
|
513 |
window.location = url; |
|
514 |
} |
|
515 |
else |
|
516 |
{ |
|
517 |
ajaxAuthLoginInnerSetup(); |
|
518 |
} |
|
519 |
break; |
|
520 |
case 'error': |
|
170
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
521 |
if ( response.error == 'The username and/or password is incorrect.' ) |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
522 |
{ |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
523 |
ajax_auth_error_string = response.error; |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
524 |
mb_current_obj.updateContent(''); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
525 |
document.getElementById('messageBox').style.backgroundColor = '#C0C0C0'; |
171
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
170
diff
changeset
|
526 |
var mb_parent = document.getElementById('messageBox').parentNode; |
1465f48faba0
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
Dan
parents:
170
diff
changeset
|
527 |
new Spry.Effect.Shake(mb_parent, {duration: 1500}).start(); |
170
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
528 |
setTimeout("document.getElementById('messageBox').style.backgroundColor = '#FFF'; ajaxAuthLoginInnerSetup();", 2500); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
529 |
} |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
530 |
else |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
531 |
{ |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
532 |
alert(response.error); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
533 |
ajaxAuthLoginInnerSetup(); |
4c5c2b66a34d
SECURITY: remove debug message in session manager; implemented alternate MediaWiki syntax for template embedding; added Adobe Spry for "shake" effect on unsuccessful login
Dan
parents:
144
diff
changeset
|
534 |
} |
1 | 535 |
break; |
536 |
default: |
|
537 |
alert(ajax.responseText); |
|
538 |
break; |
|
539 |
} |
|
540 |
} |
|
541 |
}); |
|
542 |
||
543 |
return true; |
|
544 |
||
545 |
} |
|
546 |
||
547 |
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ |
|
548 |
function sprintf() |
|
549 |
{ |
|
550 |
if (!arguments || arguments.length < 1 || !RegExp) |
|
551 |
{ |
|
552 |
return; |
|
553 |
} |
|
554 |
var str = arguments[0]; |
|
555 |
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; |
|
556 |
var a = b = [], numSubstitutions = 0, numMatches = 0; |
|
557 |
while (a = re.exec(str)) |
|
558 |
{ |
|
559 |
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; |
|
560 |
var pPrecision = a[5], pType = a[6], rightPart = a[7]; |
|
561 |
||
562 |
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); |
|
563 |
||
564 |
numMatches++; |
|
565 |
if (pType == '%') |
|
566 |
{ |
|
567 |
subst = '%'; |
|
568 |
} |
|
569 |
else |
|
570 |
{ |
|
571 |
numSubstitutions++; |
|
572 |
if (numSubstitutions >= arguments.length) |
|
573 |
{ |
|
574 |
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); |
|
575 |
} |
|
576 |
var param = arguments[numSubstitutions]; |
|
577 |
var pad = ''; |
|
578 |
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); |
|
579 |
else if (pPad) pad = pPad; |
|
580 |
var justifyRight = true; |
|
581 |
if (pJustify && pJustify === "-") justifyRight = false; |
|
582 |
var minLength = -1; |
|
583 |
if (pMinLength) minLength = parseInt(pMinLength); |
|
584 |
var precision = -1; |
|
585 |
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); |
|
586 |
var subst = param; |
|
587 |
if (pType == 'b') subst = parseInt(param).toString(2); |
|
588 |
else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); |
|
589 |
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; |
|
590 |
else if (pType == 'u') subst = Math.abs(param); |
|
591 |
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); |
|
592 |
else if (pType == 'o') subst = parseInt(param).toString(8); |
|
593 |
else if (pType == 's') subst = param; |
|
594 |
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); |
|
595 |
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); |
|
596 |
} |
|
597 |
str = leftpart + subst + rightPart; |
|
598 |
} |
|
599 |
return str; |
|
600 |
} |
|
601 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
602 |
/** |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
603 |
* Insert a DOM object _after_ the specified child. |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
604 |
* @param object Parent node |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
605 |
* @param object Node to insert |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
606 |
* @param object Node to insert after |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
607 |
*/ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
608 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
609 |
function insertAfter(parent, baby, bigsister) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
610 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
611 |
try |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
612 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
613 |
if ( parent.childNodes[parent.childNodes.length-1] == bigsister ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
614 |
parent.appendChild(baby); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
615 |
else |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
616 |
parent.insertBefore(baby, bigsister.nextSibling); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
617 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
618 |
catch(e) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
619 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
620 |
alert(e.toString()); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
621 |
if ( window.console ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
622 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
623 |
// Firebug support |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
624 |
window.console.warn(e); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
625 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
626 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
627 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
628 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
629 |
/** |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
630 |
* Validates an e-mail address. |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
631 |
* @param string E-mail address |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
632 |
* @return bool |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
633 |
*/ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
634 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
635 |
function validateEmail(email) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
636 |
{ |
238
f948557af068
Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
parents:
224
diff
changeset
|
637 |
return ( email.match(/^(?:[\w\d_-]+\.?)+@((?:(?:[\w\d_-]\-?)+\.)+\w{2,4}|localhost)$/) ) ? true : false; |
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
638 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
639 |