author | Dan |
Mon, 18 Feb 2008 16:18:03 -0500 | |
changeset 428 | 921bae9104b0 |
parent 426 | f5718d7c2a6a |
child 436 | 242353360e37 |
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() { |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
372
diff
changeset
|
41 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
1 | 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.'; |
|
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
126 |
window._unloadmsg = message; |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
127 |
window.onbeforeunload = function(e) |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
128 |
{ |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
129 |
if ( !e ) |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
130 |
e = window.event; |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
131 |
e.returnValue = window._unloadmsg; |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
132 |
} |
1 | 133 |
} |
134 |
||
135 |
function enableUnload() |
|
136 |
{ |
|
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
137 |
window._unloadmsg = null; |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
138 |
window.onbeforeunload = null; |
1 | 139 |
} |
140 |
||
141 |
/** |
|
142 |
* Gets the highest z-index of all divs in the document |
|
143 |
* @return integer |
|
144 |
*/ |
|
145 |
function getHighestZ() |
|
146 |
{ |
|
147 |
z = 0; |
|
148 |
var divs = document.getElementsByTagName('div'); |
|
149 |
for(var i = 0; i < divs.length; i++) |
|
150 |
{ |
|
151 |
if(divs[i].style.zIndex > z) z = divs[i].style.zIndex; |
|
152 |
} |
|
153 |
return z; |
|
154 |
} |
|
155 |
||
156 |
function isKeyPressed(event) |
|
157 |
{ |
|
158 |
if (event.shiftKey==1) |
|
159 |
{ |
|
160 |
shift = true; |
|
161 |
} |
|
162 |
else |
|
163 |
{ |
|
164 |
shift = false; |
|
165 |
} |
|
166 |
} |
|
167 |
||
168 |
function moveDiv(div, newparent) |
|
169 |
{ |
|
170 |
var backup = div; |
|
171 |
var oldparent = div.parentNode; |
|
172 |
oldparent.removeChild(div); |
|
173 |
newparent.appendChild(backup); |
|
174 |
} |
|
175 |
||
176 |
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;} |
|
177 |
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=/";} |
|
178 |
function eraseCookie(name) {createCookie(name,"",-1);} |
|
179 |
||
180 |
var busyBannerID; |
|
181 |
function goBusy(msg) |
|
182 |
{ |
|
183 |
if(!msg) msg = 'Please wait...'; |
|
184 |
body = document.getElementsByTagName('body'); |
|
185 |
body = body[0]; |
|
186 |
body.style.cursor = 'wait'; |
|
187 |
busyBannerID = bannerOn(msg); |
|
188 |
} |
|
189 |
||
190 |
function unBusy() |
|
191 |
{ |
|
192 |
body = document.getElementsByTagName('body'); |
|
193 |
body = body[0]; |
|
194 |
body.style.cursor = 'default'; |
|
195 |
bannerOff(busyBannerID); |
|
196 |
} |
|
197 |
||
198 |
function setAjaxLoading() |
|
199 |
{ |
|
200 |
if ( document.getElementById('ajaxloadicon') ) |
|
201 |
{ |
|
200
63fddf1335d9
Nothing real special. The AJAX loading icon can be changed using the Javascript variable ajax_load_icon in header.tpl.
Dan
parents:
176
diff
changeset
|
202 |
document.getElementById('ajaxloadicon').src=ajax_load_icon; |
1 | 203 |
} |
204 |
} |
|
205 |
||
206 |
function unsetAjaxLoading() |
|
207 |
{ |
|
208 |
if ( document.getElementById('ajaxloadicon') ) |
|
209 |
{ |
|
210 |
document.getElementById('ajaxloadicon').src=scriptPath + '/images/spacer.gif'; |
|
211 |
} |
|
212 |
} |
|
213 |
||
214 |
/* |
|
215 |
* Search boxes |
|
216 |
*/ |
|
217 |
||
218 |
function buildSearchBoxes() |
|
219 |
{ |
|
220 |
var divs = document.getElementsByTagName('*'); |
|
221 |
var boxes = new Array(); |
|
222 |
for ( var i = 0; i < divs.length; i++ ) |
|
223 |
{ |
|
224 |
if ( divs[i].className) |
|
225 |
{ |
|
226 |
if ( divs[i].className.substr(0, 9) == 'searchbox' ) |
|
227 |
{ |
|
228 |
boxes.push(divs[i]); |
|
229 |
} |
|
230 |
} |
|
231 |
} |
|
232 |
for ( var i = 0; i < boxes.length; i++ ) |
|
233 |
{ |
|
234 |
if ( boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/) ) |
|
235 |
{ |
|
236 |
var width = boxes[i].className.match(/^searchbox\[([0-9]+)px\]$/); |
|
237 |
width = parseInt(width[1]); |
|
238 |
} |
|
239 |
else |
|
240 |
{ |
|
241 |
var width = 120; |
|
242 |
} |
|
243 |
createSearchBox(boxes[i], width); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
function createSearchBox(parent, width) |
|
248 |
{ |
|
249 |
if ( typeof(parent) != 'object') |
|
250 |
{ |
|
251 |
alert('BUG: createSearchBox(): parent is not an object'); |
|
252 |
return false; |
|
253 |
} |
|
254 |
//parent.style.padding = '0px'; |
|
255 |
//parent.style.textAlign = 'center'; |
|
256 |
parent.style.width = width + 'px'; |
|
257 |
var submit = document.createElement('div'); |
|
258 |
submit.onclick = function() { searchFormSubmit(this); }; |
|
259 |
submit.className = 'js-search-submit'; |
|
260 |
var input = document.createElement('input'); |
|
261 |
input.className = 'js-search-box'; |
|
262 |
input.value = 'Search'; |
|
263 |
input.name = 'q'; |
|
264 |
input.style.width = ( width - 28 ) + 'px'; |
|
265 |
input.onfocus = function() { if ( this.value == 'Search' ) this.value = ''; }; |
|
266 |
input.onblur = function() { if ( this.value == '' ) this.value = 'Search'; }; |
|
267 |
parent.appendChild(input); |
|
268 |
var off = fetch_offset(input); |
|
269 |
var top = off['top'] + 'px'; |
|
270 |
var left = ( parseInt(off['left']) + ( width - 24 ) ) + 'px'; |
|
271 |
submit.style.top = top; |
|
272 |
submit.style.left = left; |
|
273 |
parent.appendChild(submit); |
|
274 |
} |
|
275 |
||
276 |
function searchFormSubmit(obj) |
|
277 |
{ |
|
278 |
var input = obj.previousSibling; |
|
279 |
if ( input.value == 'Search' || input.value == '' ) |
|
280 |
return false; |
|
281 |
var p = obj; |
|
282 |
while(true) |
|
283 |
{ |
|
284 |
p = p.parentNode; |
|
285 |
if ( !p ) |
|
286 |
break; |
|
287 |
if ( typeof(p.tagName) != 'string' ) |
|
288 |
break; |
|
289 |
else if ( p.tagName.toLowerCase() == 'form' ) |
|
290 |
{ |
|
291 |
p.submit(); |
|
292 |
} |
|
293 |
else if ( p.tagName.toLowerCase() == 'body' ) |
|
294 |
{ |
|
295 |
break; |
|
296 |
} |
|
297 |
} |
|
298 |
} |
|
299 |
||
300 |
/* |
|
301 |
* AJAX login box (experimental) |
|
302 |
*/ |
|
303 |
||
304 |
var ajax_auth_prompt_cache = false; |
|
305 |
var ajax_auth_mb_cache = false; |
|
306 |
var ajax_auth_level_cache = false; |
|
174
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
|
307 |
var ajax_auth_error_string = false; |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
308 |
var ajax_auth_show_captcha = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
309 |
|
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
310 |
function ajaxAuthErrorToString($data) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
311 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
312 |
var $errstring = $data.error; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
313 |
// this was literally copied straight from the PHP code. |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
314 |
switch($data.error) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
315 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
316 |
case 'key_not_found': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
317 |
$errstring = $lang.get('user_err_key_not_found'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
318 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
319 |
case 'key_wrong_length': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
320 |
$errstring = $lang.get('user_err_key_wrong_length'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
321 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
322 |
case 'too_big_for_britches': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
323 |
$errstring = $lang.get('user_err_too_big_for_britches'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
324 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
325 |
case 'invalid_credentials': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
326 |
$errstring = $lang.get('user_err_invalid_credentials'); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
327 |
var subst = { |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
348
diff
changeset
|
328 |
fails: $data.lockout_fails, |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
329 |
lockout_threshold: $data.lockout_threshold, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
330 |
lockout_duration: $data.lockout_duration |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
331 |
} |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
332 |
if ( $data.lockout_policy == 'lockout' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
333 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
334 |
$errstring += $lang.get('user_err_invalid_credentials_lockout', subst); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
335 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
336 |
else if ( $data.lockout_policy == 'captcha' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
337 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
338 |
$errstring += $lang.get('user_err_invalid_credentials_lockout_captcha', subst); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
339 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
340 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
341 |
case 'backend_fail': |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
342 |
$errstring = $lang.get('user_err_backend_fail'); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
343 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
344 |
case 'locked_out': |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
345 |
$attempts = parseInt($data['lockout_fails']); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
346 |
if ( $attempts > $data['lockout_threshold']) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
347 |
$attempts = $data['lockout_threshold']; |
182
c69730750be3
Fixed the security hole (really, I'm a moron - used $failed > $threshold instead of $failed >= $threashold) and patched up some...erm... math issues
Dan
parents:
179
diff
changeset
|
348 |
$time_rem = $data.time_rem; |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
349 |
$s = ( $time_rem == 1 ) ? '' : $lang.get('meta_plural'); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
350 |
|
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
351 |
var subst = { |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
352 |
lockout_threshold: $data.lockout_threshold, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
353 |
time_rem: $time_rem, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
354 |
plural: $s, |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
355 |
captcha_blurb: ( $data.lockout_policy == 'captcha' ? $lang.get('user_err_locked_out_captcha_blurb') : '' ) |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
356 |
} |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
357 |
|
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
358 |
$errstring = $lang.get('user_err_locked_out', subst); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
359 |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
360 |
break; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
361 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
362 |
return $errstring; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
363 |
} |
1 | 364 |
|
365 |
function ajaxPromptAdminAuth(call_on_ok, level) |
|
366 |
{ |
|
367 |
if ( typeof(call_on_ok) == 'function' ) |
|
368 |
{ |
|
369 |
ajax_auth_prompt_cache = call_on_ok; |
|
370 |
} |
|
371 |
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
|
372 |
level = USER_LEVEL_MEMBER; |
1 | 373 |
ajax_auth_level_cache = level; |
374 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
375 |
<p>' + $lang.get('user_login_ajax_fetching_key') + '</p> \ |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
376 |
<p><small>' + $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title) }) + '</p> \ |
1 | 377 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
378 |
</div>'; |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
379 |
var title = ( level > USER_LEVEL_MEMBER ) ? $lang.get('user_login_ajax_prompt_title_elev') : $lang.get('user_login_ajax_prompt_title'); |
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
|
380 |
ajax_auth_mb_cache = new messagebox(MB_OKCANCEL|MB_ICONLOCK, title, loading_win); |
1 | 381 |
ajax_auth_mb_cache.onbeforeclick['OK'] = ajaxValidateLogin; |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
382 |
ajax_auth_mb_cache.onbeforeclick['Cancel'] = function() |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
383 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
384 |
if ( document.getElementById('autoCaptcha') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
385 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
386 |
var to = fly_out_top(document.getElementById('autoCaptcha'), false, true); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
387 |
setTimeout(function() { |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
388 |
var d = document.getElementById('autoCaptcha'); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
389 |
d.parentNode.removeChild(d); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
390 |
}, to); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
391 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
392 |
} |
1 | 393 |
ajaxAuthLoginInnerSetup(); |
394 |
} |
|
395 |
||
396 |
function ajaxAuthLoginInnerSetup() |
|
397 |
{ |
|
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
398 |
// 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:
200
diff
changeset
|
399 |
var _ = new Image(32, 32); |
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
parents:
407
diff
changeset
|
400 |
_.src = scriptPath + "/images/check.png"; |
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
401 |
|
1 | 402 |
ajaxGet(makeUrlNS('Special', 'Login', 'act=getkey'), function() { |
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
372
diff
changeset
|
403 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
1 | 404 |
{ |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
9
diff
changeset
|
405 |
var response = String(ajax.responseText); |
1 | 406 |
if ( response.substr(0,1) != '{' ) |
407 |
{ |
|
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
315
diff
changeset
|
408 |
handle_invalid_json(response); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
315
diff
changeset
|
409 |
ajax_auth_mb_cache.destroy(); |
1 | 410 |
return false; |
411 |
} |
|
412 |
response = parseJSON(response); |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
413 |
var disable_controls = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
414 |
if ( response.locked_out && !ajax_auth_error_string ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
415 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
416 |
response.error = 'locked_out'; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
417 |
ajax_auth_error_string = ajaxAuthErrorToString(response); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
418 |
if ( response.lockout_policy == 'captcha' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
419 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
420 |
ajax_auth_show_captcha = response.captcha; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
421 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
422 |
else |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
423 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
424 |
disable_controls = true; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
425 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
426 |
} |
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
|
427 |
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
|
428 |
var form_html = ''; |
176 | 429 |
var shown_error = false; |
174
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
|
430 |
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
|
431 |
{ |
176 | 432 |
shown_error = true; |
433 |
form_html += '<div class="error-box-mini" id="ajax_auth_error">' + ajax_auth_error_string + '</div>'; |
|
174
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
|
434 |
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
|
435 |
} |
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
|
436 |
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
|
437 |
{ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
438 |
form_html += $lang.get('user_login_ajax_prompt_body_elev') + '<br /><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
|
439 |
} |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
440 |
if ( ajax_auth_show_captcha ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
441 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
442 |
var captcha_html = ' \ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
443 |
<tr> \ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
444 |
<td>' + $lang.get('user_login_field_captcha') + ':</td> \ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
445 |
<td><input type="hidden" id="ajaxlogin_captcha_hash" value="' + ajax_auth_show_captcha + '" /><input type="text" tabindex="3" size="25" id="ajaxlogin_captcha_code" /> \ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
446 |
</tr>'; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
447 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
448 |
else |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
449 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
450 |
var captcha_html = ''; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
451 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
452 |
var disableme = ( disable_controls ) ? 'disabled="disabled" ' : ''; |
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
|
453 |
form_html += ' \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
454 |
<form action="#" onsubmit="ajaxValidateLogin(); return false;" name="ajax_login_form"> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
455 |
<table border="0" align="center"> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
456 |
<tr> \ |
326 | 457 |
<td>' + $lang.get('user_login_field_username') + ':</td><td><input tabindex="1" id="ajaxlogin_user" type="text" ' + disableme + 'size="25" /> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
458 |
</tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
459 |
<tr> \ |
326 | 460 |
<td>' + $lang.get('user_login_field_password') + ':</td><td><input tabindex="2" id="ajaxlogin_pass" type="password" ' + disableme + 'size="25" /> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
461 |
</tr> \ |
326 | 462 |
' + captcha_html + ' \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
463 |
<tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
464 |
<td colspan="2" style="text-align: center;"> \ |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
465 |
<small>' + $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title, 'level=' + level) }) + '<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
|
466 |
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
|
467 |
{ |
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
|
468 |
form_html += ' \ |
326 | 469 |
' + $lang.get('user_login_ajax_link_forgotpass', { forgotpass_link: makeUrlNS('Special', 'PasswordReset') }) + '<br /> \ |
470 |
' + $lang.get('user_login_createaccount_blurb', { reg_link: makeUrlNS('Special', 'Register') }); |
|
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
|
471 |
} |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
472 |
form_html += '</small> \ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
473 |
</td> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
474 |
</tr> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
475 |
</table> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
476 |
<input type="hidden" id="ajaxlogin_crypt_key" value="' + response.key + '" /> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
477 |
<input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
478 |
</form>'; |
1 | 479 |
ajax_auth_mb_cache.updateContent(form_html); |
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
480 |
$dynano('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
|
481 |
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
|
482 |
{ |
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
483 |
$dynano('ajaxlogin_user').object.value = response.username; |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
484 |
if ( IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
485 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
486 |
setTimeout("document.forms['ajax_login_form'].password.focus();", 200); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
487 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
488 |
else |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
489 |
{ |
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
490 |
$dynano('ajaxlogin_pass').object.focus(); |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
491 |
} |
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
|
492 |
} |
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
|
493 |
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
|
494 |
{ |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
495 |
if ( IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
496 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
497 |
setTimeout("document.forms['ajax_login_form'].username.focus();", 200); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
498 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
499 |
else |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
500 |
{ |
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
501 |
$dynano('ajaxlogin_user').object.focus(); |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
502 |
} |
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
|
503 |
} |
326 | 504 |
var enter_obj = ( ajax_auth_show_captcha ) ? 'ajaxlogin_captcha_code' : 'ajaxlogin_pass'; |
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
505 |
$dynano(enter_obj).object.onblur = function(e) { if ( !shift ) $dynano('messageBox').object.nextSibling.firstChild.focus(); }; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
506 |
$dynano(enter_obj).object.onkeypress = function(e) |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
507 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
508 |
// Trigger a form submit when the password field is focused and the user presses enter |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
509 |
|
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
510 |
// IE doesn't give us an event object when it should - check window.event. If that |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
511 |
// still fails, give up. |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
512 |
if ( !e ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
513 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
514 |
e = window.event; |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
515 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
516 |
if ( !e && IE ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
517 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
518 |
return true; |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
519 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
520 |
if ( e.keyCode == 13 ) |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
521 |
{ |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
522 |
ajaxValidateLogin(); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
523 |
} |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
295
diff
changeset
|
524 |
}; |
176 | 525 |
/* |
526 |
## This causes the background image to disappear under Fx 2 |
|
527 |
if ( shown_error ) |
|
528 |
{ |
|
529 |
// fade to #FFF4F4 |
|
530 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 1000, from: '#FFF4F4', to: '#805600', restoreColor: '#805600', finish: function() |
|
531 |
{ |
|
532 |
var fader = new Spry.Effect.Highlight('ajax_auth_error', {duration: 3000, from: '#805600', to: '#FFF4F4', restoreColor: '#FFF4F4'}); |
|
533 |
fader.start(); |
|
534 |
}}); |
|
535 |
fader.start(); |
|
536 |
} |
|
537 |
*/ |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
538 |
if ( ajax_auth_show_captcha ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
539 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
540 |
ajaxShowCaptcha(ajax_auth_show_captcha); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
541 |
ajax_auth_show_captcha = false; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
542 |
} |
1 | 543 |
} |
544 |
}); |
|
545 |
} |
|
546 |
||
547 |
function ajaxValidateLogin() |
|
548 |
{ |
|
549 |
var username,password,auth_enabled,crypt_key,crypt_data,challenge_salt,challenge_data; |
|
550 |
username = document.getElementById('ajaxlogin_user'); |
|
551 |
if ( !username ) |
|
552 |
return false; |
|
553 |
username = document.getElementById('ajaxlogin_user').value; |
|
554 |
password = document.getElementById('ajaxlogin_pass').value; |
|
555 |
auth_enabled = false; |
|
556 |
||
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
557 |
if ( document.getElementById('autoCaptcha') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
558 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
559 |
var to = fly_out_top(document.getElementById('autoCaptcha'), false, true); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
560 |
setTimeout(function() { |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
561 |
var d = document.getElementById('autoCaptcha'); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
562 |
d.parentNode.removeChild(d); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
563 |
}, to); |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
564 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
565 |
|
1 | 566 |
disableJSONExts(); |
567 |
||
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
568 |
var auth_enabled = aes_self_test(); |
1 | 569 |
|
570 |
if ( !auth_enabled ) |
|
571 |
{ |
|
572 |
alert('Login error: encryption sanity check failed\n'); |
|
573 |
return true; |
|
574 |
} |
|
575 |
||
576 |
crypt_key = document.getElementById('ajaxlogin_crypt_key').value; |
|
577 |
challenge_salt = document.getElementById('ajaxlogin_crypt_challenge').value; |
|
578 |
||
579 |
var crypt_key_md5 = hex_md5(crypt_key); |
|
580 |
||
581 |
challenge_data = hex_md5(password + challenge_salt) + challenge_salt; |
|
582 |
||
583 |
password = stringToByteArray(password); |
|
584 |
crypt_key = hexToByteArray(crypt_key); |
|
585 |
||
586 |
crypt_data = rijndaelEncrypt(password, crypt_key, 'ECB'); |
|
587 |
crypt_data = byteArrayToHex(crypt_data); |
|
588 |
||
589 |
var json_data = { |
|
590 |
'username' : username, |
|
591 |
'crypt_key' : crypt_key_md5, |
|
592 |
'challenge' : challenge_data, |
|
593 |
'crypt_data' : crypt_data, |
|
594 |
'level' : ajax_auth_level_cache |
|
595 |
}; |
|
596 |
||
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
597 |
if ( document.getElementById('ajaxlogin_captcha_hash') ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
598 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
599 |
json_data.captcha_hash = document.getElementById('ajaxlogin_captcha_hash').value; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
600 |
json_data.captcha_code = document.getElementById('ajaxlogin_captcha_code').value; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
601 |
} |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
602 |
|
1 | 603 |
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
|
604 |
json_data = encodeURIComponent(json_data); |
1 | 605 |
|
606 |
var loading_win = '<div align="center" style="text-align: center;"> \ |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
204
diff
changeset
|
607 |
<p>' + $lang.get('user_login_ajax_loggingin') + '</p> \ |
1 | 608 |
<p><img alt="Please wait..." src="'+scriptPath+'/images/loading-big.gif" /></p> \ |
609 |
</div>'; |
|
610 |
||
611 |
ajax_auth_mb_cache.updateContent(loading_win); |
|
612 |
||
613 |
ajaxPost(makeUrlNS('Special', 'Login', 'act=ajaxlogin'), 'params=' + json_data, function() { |
|
407
35d94240a197
Mass-fixed all AJAX functions to also check the HTTP status code before parsing the response
Dan
parents:
372
diff
changeset
|
614 |
if ( ajax.readyState == 4 && ajax.status == 200 ) |
1 | 615 |
{ |
616 |
var response = ajax.responseText; |
|
617 |
if ( response.substr(0,1) != '{' ) |
|
618 |
{ |
|
619 |
alert('Invalid JSON response from server: ' + response); |
|
620 |
ajaxAuthLoginInnerSetup(); |
|
621 |
return false; |
|
622 |
} |
|
623 |
response = parseJSON(response); |
|
624 |
switch(response.result) |
|
625 |
{ |
|
626 |
case 'success': |
|
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
627 |
var success_win = '<div align="center" style="text-align: center;"> \ |
304 | 628 |
<p>' + $lang.get('user_login_success_short') + '</p> \ |
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
parents:
407
diff
changeset
|
629 |
<p><img alt=" " src="'+scriptPath+'/images/check.png" /></p> \ |
281
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
630 |
</div>'; |
db8d5111ad20
AJAX login box now briefly shows the message "success" when a login is successful
Dan
parents:
200
diff
changeset
|
631 |
ajax_auth_mb_cache.updateContent(success_win); |
1 | 632 |
if ( typeof(ajax_auth_prompt_cache) == 'function' ) |
633 |
{ |
|
634 |
ajax_auth_prompt_cache(response.key); |
|
635 |
} |
|
636 |
break; |
|
637 |
case 'success_reset': |
|
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
638 |
var conf = confirm($lang.get('user_login_ajax_msg_used_temp_pass')); |
1 | 639 |
if ( conf ) |
640 |
{ |
|
641 |
var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temppass); |
|
642 |
window.location = url; |
|
643 |
} |
|
644 |
else |
|
645 |
{ |
|
646 |
ajaxAuthLoginInnerSetup(); |
|
647 |
} |
|
648 |
break; |
|
649 |
case 'error': |
|
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
650 |
if ( response.data.error == 'invalid_credentials' || response.data.error == 'locked_out' ) |
174
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
|
651 |
{ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
652 |
ajax_auth_error_string = ajaxAuthErrorToString(response.data); |
174
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
|
653 |
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
|
654 |
document.getElementById('messageBox').style.backgroundColor = '#C0C0C0'; |
175
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:
174
diff
changeset
|
655 |
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:
174
diff
changeset
|
656 |
new Spry.Effect.Shake(mb_parent, {duration: 1500}).start(); |
174
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
|
657 |
setTimeout("document.getElementById('messageBox').style.backgroundColor = '#FFF'; ajaxAuthLoginInnerSetup();", 2500); |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
658 |
|
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
659 |
if ( response.data.lockout_policy == 'captcha' && response.data.error == 'locked_out' ) |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
660 |
{ |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
661 |
ajax_auth_show_captcha = response.captcha; |
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
662 |
} |
174
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
|
663 |
} |
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
|
664 |
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
|
665 |
{ |
179
36b287f1d85c
[F] Added support for account lockouts. User is locked out or required to complete a CAPTCHA after specified threshold for specified period.
Dan
parents:
176
diff
changeset
|
666 |
ajax_auth_error_string = ajaxAuthErrorToString(response.data); |
174
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
|
667 |
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
|
668 |
} |
1 | 669 |
break; |
670 |
default: |
|
671 |
alert(ajax.responseText); |
|
672 |
break; |
|
673 |
} |
|
674 |
} |
|
675 |
}); |
|
676 |
||
677 |
return true; |
|
678 |
||
679 |
} |
|
680 |
||
681 |
// This code is in the public domain. Feel free to link back to http://jan.moesen.nu/ |
|
682 |
function sprintf() |
|
683 |
{ |
|
684 |
if (!arguments || arguments.length < 1 || !RegExp) |
|
685 |
{ |
|
686 |
return; |
|
687 |
} |
|
688 |
var str = arguments[0]; |
|
689 |
var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; |
|
690 |
var a = b = [], numSubstitutions = 0, numMatches = 0; |
|
691 |
while (a = re.exec(str)) |
|
692 |
{ |
|
693 |
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; |
|
694 |
var pPrecision = a[5], pType = a[6], rightPart = a[7]; |
|
695 |
||
696 |
//alert(a + '\n' + [a[0], leftpart, pPad, pJustify, pMinLength, pPrecision); |
|
697 |
||
698 |
numMatches++; |
|
699 |
if (pType == '%') |
|
700 |
{ |
|
701 |
subst = '%'; |
|
702 |
} |
|
703 |
else |
|
704 |
{ |
|
705 |
numSubstitutions++; |
|
706 |
if (numSubstitutions >= arguments.length) |
|
707 |
{ |
|
708 |
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).'); |
|
709 |
} |
|
710 |
var param = arguments[numSubstitutions]; |
|
711 |
var pad = ''; |
|
712 |
if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1); |
|
713 |
else if (pPad) pad = pPad; |
|
714 |
var justifyRight = true; |
|
715 |
if (pJustify && pJustify === "-") justifyRight = false; |
|
716 |
var minLength = -1; |
|
717 |
if (pMinLength) minLength = parseInt(pMinLength); |
|
718 |
var precision = -1; |
|
719 |
if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1)); |
|
720 |
var subst = param; |
|
721 |
if (pType == 'b') subst = parseInt(param).toString(2); |
|
722 |
else if (pType == 'c') subst = String.fromCharCode(parseInt(param)); |
|
723 |
else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0; |
|
724 |
else if (pType == 'u') subst = Math.abs(param); |
|
725 |
else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param); |
|
726 |
else if (pType == 'o') subst = parseInt(param).toString(8); |
|
727 |
else if (pType == 's') subst = param; |
|
728 |
else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase(); |
|
729 |
else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase(); |
|
730 |
} |
|
731 |
str = leftpart + subst + rightPart; |
|
732 |
} |
|
733 |
return str; |
|
734 |
} |
|
735 |
||
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
736 |
/** |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
737 |
* 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
|
738 |
* @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
|
739 |
* @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
|
740 |
* @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
|
741 |
*/ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
742 |
|
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
743 |
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
|
744 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
745 |
try |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
746 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
747 |
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
|
748 |
parent.appendChild(baby); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
749 |
else |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
750 |
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
|
751 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
752 |
catch(e) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
753 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
754 |
alert(e.toString()); |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
755 |
if ( window.console ) |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
756 |
{ |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
757 |
// Firebug support |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
758 |
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
|
759 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
760 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
761 |
} |
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
60
diff
changeset
|
762 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
763 |
/** |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
764 |
* 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
|
765 |
* @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
|
766 |
* @return bool |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
767 |
*/ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
768 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
769 |
function validateEmail(email) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
770 |
{ |
295
f948557af068
Add warning in installer for PHP < 5.2.0; hopefully fix validation of e-mail addresses with dashes
Dan
parents:
281
diff
changeset
|
771 |
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
|
772 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
85
diff
changeset
|
773 |
|
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
774 |
/** |
348
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
775 |
* Validates a username. |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
776 |
* @param string Username to test |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
777 |
* @return bool |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
778 |
*/ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
779 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
780 |
function validateUsername(username) |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
781 |
{ |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
782 |
var regex = new RegExp('^[^<>&\?\'"%\n\r/]+$', ''); |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
783 |
return ( username.match(regex) ) ? true : false; |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
784 |
} |
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
785 |
|
87e08a6e4fec
Welcome to the new Enano installer. Much distance still to be covered but the basics are there.
Dan
parents:
340
diff
changeset
|
786 |
/** |
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
787 |
* Equivalent of PHP's time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
788 |
* @return int |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
789 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
790 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
791 |
function unix_time() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
792 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
793 |
return parseInt((new Date()).getTime()/1000); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
794 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
326
diff
changeset
|
795 |
|
420
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
796 |
/* |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
797 |
* Utility functions, moved from windows.js |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
798 |
*/ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
799 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
800 |
// getElementWidth() and getElementHeight() |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
801 |
// Source: http://www.aspandjavascript.co.uk/javascript/javascript_api/get_element_width_height.asp |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
802 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
803 |
function getElementHeight(Elem) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
804 |
if (ns4) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
805 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
806 |
var elem = getObjNN4(document, Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
807 |
return elem.clip.height; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
808 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
809 |
else |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
810 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
811 |
if(document.getElementById) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
812 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
813 |
var elem = document.getElementById(Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
814 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
815 |
else if (document.all) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
816 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
817 |
var elem = document.all[Elem]; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
818 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
819 |
if (op5) |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
820 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
821 |
xPos = elem.style.pixelHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
822 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
823 |
else |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
824 |
{ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
825 |
xPos = elem.offsetHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
826 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
827 |
return xPos; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
828 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
829 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
830 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
831 |
function getElementWidth(Elem) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
832 |
if (ns4) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
833 |
var elem = getObjNN4(document, Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
834 |
return elem.clip.width; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
835 |
} else { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
836 |
if(document.getElementById) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
837 |
var elem = document.getElementById(Elem); |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
838 |
} else if (document.all){ |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
839 |
var elem = document.all[Elem]; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
840 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
841 |
if (op5) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
842 |
xPos = elem.style.pixelWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
843 |
} else { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
844 |
xPos = elem.offsetWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
845 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
846 |
return xPos; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
847 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
848 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
849 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
850 |
function getHeight() { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
851 |
var myHeight = 0; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
852 |
if( typeof( window.innerWidth ) == 'number' ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
853 |
myHeight = window.innerHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
854 |
} else if( document.documentElement && |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
855 |
( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
856 |
myHeight = document.documentElement.clientHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
857 |
} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
858 |
myHeight = document.body.clientHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
859 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
860 |
return myHeight; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
861 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
862 |
|
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
863 |
function getWidth() { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
864 |
var myWidth = 0; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
865 |
if( typeof( window.innerWidth ) == 'number' ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
866 |
myWidth = window.innerWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
867 |
} else if( document.documentElement && |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
868 |
( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
869 |
myWidth = document.documentElement.clientWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
870 |
} else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) { |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
871 |
myWidth = document.body.clientWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
872 |
} |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
873 |
return myWidth; |
301f546688d1
Re-enabled, debugged, and optimized Javascript compression code
Dan
parents:
413
diff
changeset
|
874 |
} |
426 | 875 |
|
876 |
/** |
|
877 |
* Sanitizes a page URL string so that it can safely be stored in the database. |
|
878 |
* @param string Page ID to sanitize |
|
879 |
* @return string Cleaned text |
|
880 |
*/ |
|
881 |
||
882 |
function sanitize_page_id(page_id) |
|
883 |
{ |
|
884 |
// Remove character escapes |
|
885 |
page_id = dirtify_page_id(page_id); |
|
886 |
||
887 |
var regex = new RegExp('[A-Za-z0-9\\[\\]\./:;\(\)@_-]', 'g'); |
|
888 |
pid_clean = page_id.replace(regex, 'X'); |
|
889 |
var pid_dirty = []; |
|
890 |
for ( var i = 0; i < pid_clean.length; i++ ) |
|
891 |
pid_dirty[i] = pid_clean.substr(i, 1); |
|
892 |
||
893 |
for ( var i = 0; i < pid_dirty.length; i++ ) |
|
894 |
{ |
|
895 |
var char = pid_dirty[i]; |
|
896 |
if ( char == 'X' ) |
|
897 |
continue; |
|
898 |
var cid = char.charCodeAt(0); |
|
899 |
cid = cid.toString(16).toUpperCase(); |
|
900 |
if ( cid.length < 2 ) |
|
901 |
{ |
|
902 |
cid = '0' + cid; |
|
903 |
} |
|
904 |
pid_dirty[i] = "." + cid; |
|
905 |
} |
|
906 |
||
907 |
var pid_chars = []; |
|
908 |
for ( var i = 0; i < page_id.length; i++ ) |
|
909 |
pid_chars[i] = page_id.substr(i, 1); |
|
910 |
||
911 |
var page_id_cleaned = ''; |
|
912 |
||
913 |
for ( var id in pid_chars ) |
|
914 |
{ |
|
915 |
var char = pid_chars[id]; |
|
916 |
if ( pid_dirty[id] == 'X' ) |
|
917 |
page_id_cleaned += char; |
|
918 |
else |
|
919 |
page_id_cleaned += pid_dirty[id]; |
|
920 |
} |
|
921 |
||
922 |
return page_id_cleaned; |
|
923 |
} |
|
924 |
||
925 |
/** |
|
926 |
* Removes character escapes in a page ID string |
|
927 |
* @param string Page ID string to dirty up |
|
928 |
* @return string |
|
929 |
*/ |
|
930 |
||
931 |
function dirtify_page_id(page_id) |
|
932 |
{ |
|
933 |
// First, replace spaces with underscores |
|
934 |
page_id = page_id.replace(/ /g, '_'); |
|
935 |
||
936 |
var matches = page_id.match(/\.[A-Fa-f0-9][A-Fa-f0-9]/g); |
|
937 |
||
938 |
if ( matches != null ) |
|
939 |
{ |
|
940 |
for ( var i = 0; i < matches.length; i++ ) |
|
941 |
{ |
|
942 |
var match = matches[i]; |
|
943 |
var byt = (match.substr(1)).toUpperCase(); |
|
944 |
var code = eval("0x" + byt); |
|
945 |
var regex = new RegExp('\\.' + byt, 'g'); |
|
946 |
page_id = page_id.replace(regex, String.fromCharCode(code)); |
|
947 |
} |
|
948 |
} |
|
949 |
||
950 |
return page_id; |
|
951 |
} |