includes/clientside/static/login.js
changeset 1264 28c82f292a52
parent 1231 4797a4a88533
child 1294 f61a263564b2
equal deleted inserted replaced
1263:eb717f5c283f 1264:28c82f292a52
    97  * Switch to decide if DiffieHellman shows a "browser incompatible" error
    97  * Switch to decide if DiffieHellman shows a "browser incompatible" error
    98  * @var bool
    98  * @var bool
    99  */
    99  */
   100 
   100 
   101 var ajax_login_prevent_dh = ( IE && !IE_8 ) || ( is_iPhone && !is_iPhone_3 );
   101 var ajax_login_prevent_dh = ( IE && !IE_8 ) || ( is_iPhone && !is_iPhone_3 );
       
   102 
       
   103 /**
       
   104  * Time to wait to focus the controls.
       
   105  * @var int
       
   106  */
       
   107 
       
   108 var AJAX_LOGIN_FOCUS_WAIT = aclDisableTransitionFX ? 0 : 750;
   102 
   109 
   103 /**
   110 /**
   104  * Performs the AJAX request to get an encryption key and from there spawns the login form.
   111  * Performs the AJAX request to get an encryption key and from there spawns the login form.
   105  * @param function The function that will be called once authentication completes successfully.
   112  * @param function The function that will be called once authentication completes successfully.
   106  * @param int The security level to authenticate at - see http://docs.enanocms.org/Help:Appendix_B
   113  * @param int The security level to authenticate at - see http://docs.enanocms.org/Help:Appendix_B
   152 	
   159 	
   153 	// Initialize state
   160 	// Initialize state
   154 	logindata.showing_status = false;
   161 	logindata.showing_status = false;
   155 	logindata.user_level = user_level;
   162 	logindata.user_level = user_level;
   156 	logindata.successfunc = call_on_finish;
   163 	logindata.successfunc = call_on_finish;
       
   164 	logindata.start_time = (new Date()).getTime();
   157 	
   165 	
   158 	// Build the "loading" window
   166 	// Build the "loading" window
   159 	ajaxLoginSetStatus(AJAX_STATUS_LOADING_KEY);
   167 	ajaxLoginSetStatus(AJAX_STATUS_LOADING_KEY);
   160 	
   168 	
   161 	// Request the key
   169 	// Request the key
   754 	// Insert the entire form into the login window
   762 	// Insert the entire form into the login window
   755 	logindata.mb_inner.innerHTML = '';
   763 	logindata.mb_inner.innerHTML = '';
   756 	logindata.mb_inner.appendChild(div);
   764 	logindata.mb_inner.appendChild(div);
   757 	
   765 	
   758 	// Post operations: field focus
   766 	// Post operations: field focus
       
   767 	var wait_time = AJAX_LOGIN_FOCUS_WAIT - ((new Date()).getTime() - logindata.start_time);
       
   768 	wait_time = Math.max(0, wait_time);
   759 	setTimeout(
   769 	setTimeout(
   760 		function()
   770 		function()
   761 		{
   771 		{
   762 			if ( logindata.loggedin_username )
   772 			if ( logindata.loggedin_username )
   763 				document.getElementById('ajax_login_field_password').focus();
   773 				document.getElementById('ajax_login_field_password').focus();
   764 			else
   774 			else
   765 				document.getElementById('ajax_login_field_username').focus();
   775 				document.getElementById('ajax_login_field_username').focus();
   766 		}, 750);        
   776 		}, wait_time);
   767 	
   777 	
   768 	// Post operations: show captcha window
   778 	// Post operations: show captcha window
   769 	if ( show_captcha )
   779 	if ( show_captcha )
   770 	{
   780 	{
   771 		ajaxShowCaptcha(show_captcha);
   781 		ajaxShowCaptcha(show_captcha);