includes/clientside/static/misc.js
changeset 315 f49e3c8b638c
parent 295 f948557af068
child 320 112debff64bd
equal deleted inserted replaced
312:6c7060d36a23 315:f49e3c8b638c
   351         else if ( level > USER_LEVEL_MEMBER )
   351         else if ( level > USER_LEVEL_MEMBER )
   352         {
   352         {
   353           form_html += 'Please re-enter your login details, to verify your identity.<br /><br />';
   353           form_html += 'Please re-enter your login details, to verify your identity.<br /><br />';
   354         }
   354         }
   355         form_html += ' \
   355         form_html += ' \
   356           <table border="0" align="center"> \
   356           <form action="#" onsubmit="ajaxValidateLogin(); return false;" name="ajax_login_form"> \
   357             <tr> \
   357             <table border="0" align="center"> \
   358               <td>Username:</td><td><input tabindex="1" id="ajaxlogin_user" type="text"     size="25" /> \
   358               <tr> \
   359             </tr> \
   359                 <td>Username:</td><td><input name="username" tabindex="1" id="ajaxlogin_user" type="text"     size="25" /> \
   360             <tr> \
   360               </tr> \
   361               <td>Password:</td><td><input tabindex="2" id="ajaxlogin_pass" type="password" size="25" /> \
   361               <tr> \
   362             </tr> \
   362                 <td>Password:</td><td><input name="password" tabindex="2" id="ajaxlogin_pass" type="password" size="25" /> \
   363             <tr> \
   363               </tr> \
   364               <td colspan="2" style="text-align: center;"> \
   364               <tr> \
   365                 <br /><small>Trouble logging in? Try the <a href="'+makeUrlNS('Special', 'Login/' + title, 'level=' + level)+'">full login form</a>.<br />';
   365                 <td colspan="2" style="text-align: center;"> \
       
   366                   <br /><small>Trouble logging in? Try the <a href="'+makeUrlNS('Special', 'Login/' + title, 'level=' + level)+'">full login form</a>.<br />';
   366        if ( level <= USER_LEVEL_MEMBER )
   367        if ( level <= USER_LEVEL_MEMBER )
   367        {
   368        {
   368          form_html += ' \
   369          form_html += ' \
   369                 Did you <a href="'+makeUrlNS('Special', 'PasswordReset')+'">forget your password</a>?<br /> \
   370                   Did you <a href="'+makeUrlNS('Special', 'PasswordReset')+'">forget your password</a>?<br /> \
   370                 Maybe you need to <a href="'+makeUrlNS('Special', 'Register')+'">create an account</a>.</small>';
   371                   Maybe you need to <a href="'+makeUrlNS('Special', 'Register')+'">create an account</a>.</small>';
   371        }
   372        }
   372        form_html += ' \
   373        form_html += ' \
   373               </td> \
   374                 </td> \
   374             </tr> \
   375               </tr> \
   375           </table> \
   376             </table> \
   376           <input type="hidden" id="ajaxlogin_crypt_key"       value="' + response.key + '" /> \
   377             <input type="hidden" id="ajaxlogin_crypt_key"       value="' + response.key + '" /> \
   377           <input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \
   378             <input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \
   378         </form>';
   379           </form>';
   379         ajax_auth_mb_cache.updateContent(form_html);
   380         ajax_auth_mb_cache.updateContent(form_html);
   380         $('messageBox').object.nextSibling.firstChild.tabindex = '3';
   381         $('messageBox').object.nextSibling.firstChild.tabindex = '3';
   381         if ( typeof(response.username) == 'string' )
   382         if ( typeof(response.username) == 'string' )
   382         {
   383         {
   383           $('ajaxlogin_user').object.value = response.username;
   384           $('ajaxlogin_user').object.value = response.username;
   384           $('ajaxlogin_pass').object.focus();
   385           if ( IE )
       
   386           {
       
   387             setTimeout("document.forms['ajax_login_form'].password.focus();", 200);
       
   388           }
       
   389           else
       
   390           {
       
   391             $('ajaxlogin_pass').object.focus();
       
   392           }
   385         }
   393         }
   386         else
   394         else
   387         {
   395         {
   388           $('ajaxlogin_user').object.focus();
   396           if ( IE )
       
   397           {
       
   398             setTimeout("document.forms['ajax_login_form'].username.focus();", 200);
       
   399           }
       
   400           else
       
   401           {
       
   402             $('ajaxlogin_user').object.focus();
       
   403           }
   389         }
   404         }
   390         $('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); };
   405         $('ajaxlogin_pass').object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); };
   391         $('ajaxlogin_pass').object.onkeypress = function(e) { if ( !e && IE ) return true; if ( e.keyCode == 13 ) $('messageBox').object.nextSibling.firstChild.click(); };
   406         $('ajaxlogin_pass').object.onkeypress = function(e)
       
   407         {
       
   408           // Trigger a form submit when the password field is focused and the user presses enter
       
   409           
       
   410           // IE doesn't give us an event object when it should - check window.event. If that
       
   411           // still fails, give up.
       
   412           if ( !e )
       
   413           {
       
   414             e = window.event;
       
   415           }
       
   416           if ( !e && IE )
       
   417           {
       
   418             return true;
       
   419           }
       
   420           if ( e.keyCode == 13 )
       
   421           {
       
   422             ajaxValidateLogin();
       
   423           }
       
   424         };
   392         /*
   425         /*
   393         ## This causes the background image to disappear under Fx 2
   426         ## This causes the background image to disappear under Fx 2
   394         if ( shown_error )
   427         if ( shown_error )
   395         {
   428         {
   396           // fade to #FFF4F4
   429           // fade to #FFF4F4