includes/clientside/static/misc.js
changeset 420 301f546688d1
parent 413 6607cd646d6d
child 426 f5718d7c2a6a
equal deleted inserted replaced
419:b8b4e38825db 420:301f546688d1
   475             </table> \
   475             </table> \
   476             <input type="hidden" id="ajaxlogin_crypt_key"       value="' + response.key + '" /> \
   476             <input type="hidden" id="ajaxlogin_crypt_key"       value="' + response.key + '" /> \
   477             <input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \
   477             <input type="hidden" id="ajaxlogin_crypt_challenge" value="' + response.challenge + '" /> \
   478           </form>';
   478           </form>';
   479         ajax_auth_mb_cache.updateContent(form_html);
   479         ajax_auth_mb_cache.updateContent(form_html);
   480         $('messageBox').object.nextSibling.firstChild.tabindex = '3';
   480         $dynano('messageBox').object.nextSibling.firstChild.tabindex = '3';
   481         if ( typeof(response.username) == 'string' )
   481         if ( typeof(response.username) == 'string' )
   482         {
   482         {
   483           $('ajaxlogin_user').object.value = response.username;
   483           $dynano('ajaxlogin_user').object.value = response.username;
   484           if ( IE )
   484           if ( IE )
   485           {
   485           {
   486             setTimeout("document.forms['ajax_login_form'].password.focus();", 200);
   486             setTimeout("document.forms['ajax_login_form'].password.focus();", 200);
   487           }
   487           }
   488           else
   488           else
   489           {
   489           {
   490             $('ajaxlogin_pass').object.focus();
   490             $dynano('ajaxlogin_pass').object.focus();
   491           }
   491           }
   492         }
   492         }
   493         else
   493         else
   494         {
   494         {
   495           if ( IE )
   495           if ( IE )
   496           {
   496           {
   497             setTimeout("document.forms['ajax_login_form'].username.focus();", 200);
   497             setTimeout("document.forms['ajax_login_form'].username.focus();", 200);
   498           }
   498           }
   499           else
   499           else
   500           {
   500           {
   501             $('ajaxlogin_user').object.focus();
   501             $dynano('ajaxlogin_user').object.focus();
   502           }
   502           }
   503         }
   503         }
   504         var enter_obj = ( ajax_auth_show_captcha ) ? 'ajaxlogin_captcha_code' : 'ajaxlogin_pass';
   504         var enter_obj = ( ajax_auth_show_captcha ) ? 'ajaxlogin_captcha_code' : 'ajaxlogin_pass';
   505         $(enter_obj).object.onblur = function(e) { if ( !shift ) $('messageBox').object.nextSibling.firstChild.focus(); };
   505         $dynano(enter_obj).object.onblur = function(e) { if ( !shift ) $dynano('messageBox').object.nextSibling.firstChild.focus(); };
   506         $(enter_obj).object.onkeypress = function(e)
   506         $dynano(enter_obj).object.onkeypress = function(e)
   507         {
   507         {
   508           // Trigger a form submit when the password field is focused and the user presses enter
   508           // Trigger a form submit when the password field is focused and the user presses enter
   509           
   509           
   510           // IE doesn't give us an event object when it should - check window.event. If that
   510           // IE doesn't give us an event object when it should - check window.event. If that
   511           // still fails, give up.
   511           // still fails, give up.
   791 function unix_time()
   791 function unix_time()
   792 {
   792 {
   793   return parseInt((new Date()).getTime()/1000);
   793   return parseInt((new Date()).getTime()/1000);
   794 }
   794 }
   795 
   795 
       
   796 /*
       
   797  * Utility functions, moved from windows.js
       
   798  */
       
   799  
       
   800 // getElementWidth() and getElementHeight()
       
   801 // Source: http://www.aspandjavascript.co.uk/javascript/javascript_api/get_element_width_height.asp
       
   802 
       
   803 function getElementHeight(Elem) {
       
   804   if (ns4) 
       
   805   {
       
   806     var elem = getObjNN4(document, Elem);
       
   807     return elem.clip.height;
       
   808   } 
       
   809   else
       
   810   {
       
   811     if(document.getElementById) 
       
   812     {
       
   813       var elem = document.getElementById(Elem);
       
   814     }
       
   815     else if (document.all)
       
   816     {
       
   817       var elem = document.all[Elem];
       
   818     }
       
   819     if (op5) 
       
   820     { 
       
   821       xPos = elem.style.pixelHeight;
       
   822     }
       
   823     else
       
   824     {
       
   825       xPos = elem.offsetHeight;
       
   826     }
       
   827     return xPos;
       
   828   } 
       
   829 }
       
   830 
       
   831 function getElementWidth(Elem) {
       
   832   if (ns4) {
       
   833     var elem = getObjNN4(document, Elem);
       
   834     return elem.clip.width;
       
   835   } else {
       
   836     if(document.getElementById) {
       
   837       var elem = document.getElementById(Elem);
       
   838     } else if (document.all){
       
   839       var elem = document.all[Elem];
       
   840     }
       
   841     if (op5) {
       
   842       xPos = elem.style.pixelWidth;
       
   843     } else {
       
   844       xPos = elem.offsetWidth;
       
   845     }
       
   846     return xPos;
       
   847   }
       
   848 }
       
   849 
       
   850 function getHeight() {
       
   851   var myHeight = 0;
       
   852   if( typeof( window.innerWidth ) == 'number' ) {
       
   853     myHeight = window.innerHeight;
       
   854   } else if( document.documentElement &&
       
   855       ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
       
   856     myHeight = document.documentElement.clientHeight;
       
   857   } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
       
   858     myHeight = document.body.clientHeight;
       
   859   }
       
   860   return myHeight;
       
   861 }
       
   862 
       
   863 function getWidth() {
       
   864   var myWidth = 0;
       
   865   if( typeof( window.innerWidth ) == 'number' ) {
       
   866     myWidth = window.innerWidth;
       
   867   } else if( document.documentElement &&
       
   868       ( document.documentElement.clientWidth || document.documentElement.clientWidth ) ) {
       
   869     myWidth = document.documentElement.clientWidth;
       
   870   } else if( document.body && ( document.body.clientWidth || document.body.clientWidth ) ) {
       
   871     myWidth = document.body.clientWidth;
       
   872   }
       
   873   return myWidth;
       
   874 }