1/** 2 * Provides the javascript for the login.php script. 3 * 4 * @author Michael Slusarz <[email protected]> 5 * @copyright 2006-2015 Horde LLC 6 * @license LGPL-2 (http://www.horde.org/licenses/lgpl) 7 */ 8 9var HordeLogin = { 10 11 // Variables set by outside code: user_error, pass_error 12 13 submit: function() 14 { 15 if ($('horde_user') && !$F('horde_user')) { 16 alert(HordeLogin.user_error); 17 $('horde_user').focus(); 18 } else if ($('horde_pass') && !$F('horde_pass')) { 19 alert(HordeLogin.pass_error); 20 $('horde_pass').focus(); 21 } else { 22 $('login-button').disable(); 23 $('login_post').setValue(1); 24 $('horde_login').submit(); 25 } 26 }, 27 28 selectLang: function() 29 { 30 // We need to reload the login page here, but only if the user hasn't 31 // already entered a username and password. 32 if ((!$('horde_user') || !$F('horde_user')) && 33 (!$('horde_pass') || !$F('horde_pass'))) { 34 var params = { new_lang: $F('new_lang') }; 35 self.location = 'login.php?' + Object.toQueryString(params); 36 } 37 }, 38 39 loginButton: function(e) 40 { 41 if (e.isRightClick()) { 42 return; 43 } 44 45 if (!e.element().readAttribute('disabled')) { 46 this.submit(); 47 } 48 e.stop(); 49 }, 50 51 keypressPassword: function(e) 52 { 53 var kc = e.keyCode || e.charCode; 54 55 if (((kc >= 65 & kc <= 90) && !e.shiftKey) || 56 ((kc >= 97 & kc <= 122) && e.shiftKey)) { 57 $('horde-login-pass-capslock').show(); 58 } else { 59 $('horde-login-pass-capslock').hide(); 60 } 61 }, 62 63 /* Removes any leading hash that might be on a location string. */ 64 _removeHash: function(h) 65 { 66 return (Object.isString(h) && h.startsWith("#")) ? h.substring(1) : h; 67 }, 68 69 onDomLoad: function() 70 { 71 var s = $('horde_select_view'); 72 73 // Need to capture hash information if it exists in URL 74 if (location.hash) { 75 $('anchor_string').setValue(this._removeHash(location.hash)); 76 } 77 78 if ($('horde_user') && !$F('horde_user')) { 79 $('horde_user').focus(); 80 } else if ($('horde_pass') && !$F('horde_pass')) { 81 $('horde_pass').focus(); 82 } else { 83 $('login-button').focus(); 84 } 85 86 /* Programatically activate views that require javascript. */ 87 if (s) { 88 s.down('option[value=mobile_nojs]').remove(); 89 if (this.pre_sel) { 90 s.selectedIndex = s.down('option[value=' + this.pre_sel + ']').index; 91 } 92 $('horde_select_view_div').show(); 93 } 94 } 95 96}; 97 98document.observe('dom:loaded', HordeLogin.onDomLoad.bind(HordeLogin)); 99document.on('change', '#new_lang', HordeLogin.selectLang.bind(HordeLogin)); 100document.on('click', '#login-button', HordeLogin.loginButton.bind(HordeLogin)); 101document.on('keypress', '#horde_pass', HordeLogin.keypressPassword.bind(HordeLogin));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.