diff -r 474f8be55943 -r ab66d6d1f1f4 includes/clientside/static/misc.js --- a/includes/clientside/static/misc.js Fri Dec 07 18:47:37 2007 -0500 +++ b/includes/clientside/static/misc.js Wed Dec 19 22:55:40 2007 -0500 @@ -402,7 +402,8 @@ var response = String(ajax.responseText); if ( response.substr(0,1) != '{' ) { - alert('Invalid JSON response from server: ' + response); + handle_invalid_json(response); + ajax_auth_mb_cache.destroy(); return false; } response = parseJSON(response); @@ -447,56 +448,77 @@ } var disableme = ( disable_controls ) ? 'disabled="disabled" ' : ''; form_html += ' \ - \ - \ - \ - \ - \ - ' + captcha_html + ' \ - \ - \ + \ +
' + $lang.get('user_login_field_username') + ': \ -
' + $lang.get('user_login_field_password') + ': \ -
\ +
\ + \ + \ + \ + \ + \ + ' + captcha_html + ' \ + \ + \ - \ -
' + $lang.get('user_login_field_username') + ': \ +
' + $lang.get('user_login_field_password') + ': \ +
\ ' + $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title, 'level=' + level) }) + '
'; if ( level <= USER_LEVEL_MEMBER ) { form_html += ' \ - ' + $lang.get('user_login_ajax_link_forgotpass', { forgotpass_link: makeUrlNS('Special', 'PasswordReset') }) + '
\ - ' + $lang.get('user_login_createaccount_blurb', { reg_link: makeUrlNS('Special', 'Register') }); + ' + $lang.get('user_login_ajax_link_forgotpass', { forgotpass_link: makeUrlNS('Special', 'PasswordReset') }) + '
\ + ' + $lang.get('user_login_createaccount_blurb', { reg_link: makeUrlNS('Special', 'Register') }); } form_html += '
\ -
\ - \ - \ -
'; +
\ + \ + \ + '; ajax_auth_mb_cache.updateContent(form_html); $('messageBox').object.nextSibling.firstChild.tabindex = '3'; if ( typeof(response.username) == 'string' ) { $('ajaxlogin_user').object.value = response.username; - $('ajaxlogin_pass').object.focus(); + if ( IE ) + { + setTimeout("document.forms['ajax_login_form'].password.focus();", 200); + } + else + { + $('ajaxlogin_pass').object.focus(); + } } else { - $('ajaxlogin_user').object.focus(); + if ( IE ) + { + setTimeout("document.forms['ajax_login_form'].username.focus();", 200); + } + else + { + $('ajaxlogin_user').object.focus(); + } } - if ( ajax_auth_show_captcha ) - { - $('ajaxlogin_captcha_code').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; - $('ajaxlogin_captcha_code').object.onkeypress = function(e) { if ( !e && IE ) return true; if ( e.keyCode == 13 ) $('messageBox').object.nextSibling.firstChild.click(); }; - } - else + var enter_obj = ( ajax_auth_show_captcha ) ? 'ajaxlogin_captcha_code' : 'ajaxlogin_pass'; + $(enter_obj).object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; + $(enter_obj).object.onkeypress = function(e) { - $('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); }; - $('ajaxlogin_pass').object.onkeypress = function(e) { if ( !e && IE ) return true; if ( e.keyCode == 13 ) $('messageBox').object.nextSibling.firstChild.click(); }; - } - if ( disable_controls ) - { - var panel = document.getElementById('messageBoxButtons'); - panel.firstChild.disabled = true; - } + // Trigger a form submit when the password field is focused and the user presses enter + + // IE doesn't give us an event object when it should - check window.event. If that + // still fails, give up. + if ( !e ) + { + e = window.event; + } + if ( !e && IE ) + { + return true; + } + if ( e.keyCode == 13 ) + { + ajaxValidateLogin(); + } + }; /* ## This causes the background image to disappear under Fx 2 if ( shown_error )