src/org/openbravo/erpCommon/security/Login.html
author David Baz Fayos <david.baz@openbravo.com>
Thu, 18 Nov 2010 12:40:24 +0100
changeset 8958 c31259baefd0
parent 8948 3b0ba2e87b30
child 8966 3747d6ca3d5c
permissions -rw-r--r--
[login] Improved Error message container
asier@8910
     1
<!--
asier@8910
     2
 *************************************************************************
asier@8910
     3
 * The contents of this file are subject to the Openbravo  Public  License
asier@8910
     4
 * Version  1.0  (the  "License"),  being   the  Mozilla   Public  License
asier@8910
     5
 * Version 1.1  with a permitted attribution clause; you may not  use this
asier@8910
     6
 * file except in compliance with the License. You  may  obtain  a copy of
asier@8910
     7
 * the License at http://www.openbravo.com/legal/license.html 
asier@8910
     8
 * Software distributed under the License  is  distributed  on  an "AS IS"
asier@8910
     9
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
asier@8910
    10
 * License for the specific  language  governing  rights  and  limitations
asier@8910
    11
 * under the License. 
asier@8910
    12
 * The Original Code is Openbravo ERP. 
asier@8910
    13
 * The Initial Developer of the Original Code is Openbravo SLU 
david@8918
    14
 * All portions are Copyright (C) 2010 Openbravo SLU 
asier@8910
    15
 * All Rights Reserved. 
asier@8910
    16
 * Contributor(s):  ______________________________________.
asier@8910
    17
 ************************************************************************
asier@8910
    18
-->
asier@8910
    19
david@8918
    20
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
david@8918
    21
<head>
asier@8910
    22
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
asier@8910
    23
<title>Openbravo</title>
asier@8910
    24
<link rel="shortcut icon" href="../../../../../web/images/favicon.ico" type="image/x-icon" id="favicon" />
asier@8910
    25
<link rel="stylesheet" type="text/css" href="../../../../../web/skins/Default/Openbravo_ERP_250.css" id="paramCSS" />
david@8918
    26
<script language="JavaScript" src="../../../../../web/js/shortcuts.js" type="text/javascript"></script>
asier@8910
    27
<script language="JavaScript" src="../../../../../web/js/utils.js" type="text/javascript"></script>
david@8931
    28
<script language="JavaScript" src="../../../../../web/js/windowKeyboard.js" type="text/javascript"></script>
asier@8920
    29
<script language="JavaScript" src="../../../../../web/js/appStatus.js" type="text/javascript"></script>
asier@8920
    30
<script language="JavaScript" src="../../../../../web/js/ajax.js" type="text/javascript"></script>
asier@8923
    31
<script language="JavaScript" src="../utility/CheckCleanCache.js?cache=true" type="text/javascript"></script>
asier@8923
    32
<script language="JavaScript" src="../utility/CheckCleanCache.js?cache=false" type="text/javascript"></script>
david@8941
    33
<script language="JavaScript" type="text/javascript" id="visualPrefs">var showCompanyLogo = true, showSupportLogo = true, showForgeLogo = true, urlCompany = 'http://www.openbravo.com/', urlSupport = 'http://support.openbravo.com/';/* Parameters retreived from Login.java */</script>
david@8939
    34
<script language="JavaScript" type="text/javascript">var urlForge = 'http://forge.openbravo.com/';</script>
david@8931
    35
<script language="JavaScript" type="text/javascript" id="cacheMsg">var cacheMsg = 'xx';</script>
david@8931
    36
<script language="JavaScript" type="text/javascript" id="browserMsg">var browserMsg = 'xx';</script>
asier@8923
    37
asier@8910
    38
<script type="text/javascript">
asier@8910
    39
  function redirectWhenPopup() {
asier@8910
    40
    var permission = false;
asier@8910
    41
    try {
asier@8910
    42
      if (top.opener.parent.frames['appFrame']) {
asier@8910
    43
        permission = true;
asier@8910
    44
      }
asier@8910
    45
    }
asier@8910
    46
    catch (e) {}
asier@8910
    47
    if (permission && top.opener) {
asier@8910
    48
      top.opener.parent.location.href = top.document.location.href;
asier@8910
    49
      top.window.close();
asier@8910
    50
    }
asier@8910
    51
  }
asier@8910
    52
asier@8910
    53
  function redirectWhenInsideMDI() {
asier@8910
    54
    if (typeof isWindowInMDIPage !== 'undefined' && isWindowInMDIPage) {
david@8918
    55
      var LayoutMDI = null;
david@8918
    56
      if (isWindowInMDIPopup && parent.opener) {
david@8918
    57
        LayoutMDI = parent.opener.getFrame('LayoutMDI'); // Since getFrame('LayoutMDI') function frameset checks equals the current opened Login_FS.html modal popup
david@8918
    58
      } else {
david@8918
    59
        LayoutMDI = getFrame('LayoutMDI');
david@8918
    60
      }
asier@8910
    61
      if (LayoutMDI && typeof parent.document.getElementById('framesetMenu') === 'object') {
asier@8910
    62
        LayoutMDI.location.href = parent.window.location.href;
asier@8910
    63
      }
asier@8910
    64
    }
asier@8910
    65
  }
asier@8910
    66
asier@8910
    67
  function hideMenuFrame() {
asier@8910
    68
    if (parent.document.getElementById('framesetMenu')) {
asier@8910
    69
      parent.document.getElementById('framesetMenu').cols = parent.document.getElementById('framesetMenu').cols.replace(parent.menuWidth, '0%');
asier@8910
    70
    }
asier@8910
    71
  }
david@8918
    72
</script>
david@8918
    73
<script type="text/javascript">
david@8958
    74
  function setLoginMessage(type, title, text) {
david@8931
    75
    if (type === 'Error') {
david@8918
    76
      var msgContainer = document.getElementById('errorMsg');
david@8958
    77
      var msgContainerTitle = document.getElementById('errorMsgTitle');
david@8958
    78
      var msgContainerContent = document.getElementById('errorMsgContent');
david@8958
    79
      if (typeof title !== 'undefined' && title !== '' && title !== null) {
david@8958
    80
        msgContainerTitle.innerHTML = title.replace(/\n/g, '<br>').replace(/\\n/g, '<br>');
david@8958
    81
      } else {
david@8958
    82
        msgContainerTitle.innerHTML = '';
david@8958
    83
      }
david@8958
    84
      if (typeof text !== 'undefined' && text !== '' && text !== null) {
david@8958
    85
        msgContainerContent.innerHTML = text.replace(/\n/g, '<br>').replace(/\\n/g, '<br>');
david@8958
    86
      } else {
david@8958
    87
        msgContainerContent.innerHTML = '';
david@8958
    88
      }
david@8931
    89
      msgContainer.style.display = '';
david@8931
    90
    } else if (type === 'Warning') {
david@8958
    91
      var alertText = '';
david@8958
    92
      if (typeof title !== 'undefined' && title !== '' && title !== null) {
david@8958
    93
        alertText += title.replace(/<br>/g, '\n') + '\n';
david@8958
    94
      }
david@8958
    95
      if (typeof text !== 'undefined' && text !== '' && text !== null) {
david@8958
    96
        alertText += text.replace(/<br>/g, '\n')
david@8958
    97
      }
david@8958
    98
      alert(alertText);
asier@8910
    99
    }
asier@8910
   100
  }
asier@8921
   101
asier@8921
   102
  function resetMessage(){
asier@8921
   103
    var msgContainer = document.getElementById('errorMsg');
david@8958
   104
    var msgContainerTitle = document.getElementById('errorMsgTitle');
david@8958
   105
    var msgContainerContent = document.getElementById('errorMsgContent');
david@8958
   106
    msgContainerTitle.innerHTML = '';
david@8958
   107
    msgContainerContent.innerHTML = '';
david@8931
   108
    msgContainer.style.display = 'none';
asier@8921
   109
  }
david@8918
   110
</script>
david@8918
   111
<script type="text/javascript">
david@8918
   112
  function buttonOK_click() {
david@8939
   113
    if (focusedWindowElement.id === 'user' && document.getElementById('user').value === '') {
david@8934
   114
      return true;
david@8939
   115
    } else if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8937
   116
      setTimeout(function() { // To manage browser autocomplete feature if it is active
david@8939
   117
       if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8934
   118
         setWindowElementFocus(document.getElementById('password')) 
david@8934
   119
       } else {
david@8934
   120
         return true;
david@8934
   121
       }
david@8934
   122
      }, 10);
david@8939
   123
    } else if (focusedWindowElement.id === 'password' && document.getElementById('password').value === '') {
david@8934
   124
      return true;
david@8939
   125
    } else if (focusedWindowElement.id === 'password' && document.getElementById('user').value === '') {
david@8934
   126
      setWindowElementFocus(document.getElementById('user'))
david@8934
   127
    } else {
david@8934
   128
      disableButton('buttonOK');
david@8934
   129
      submitXmlHttpRequest(loginResult, document.frmIdentificacion, 'DEFAULT', '../secureApp/LoginHandler.html', false, null, null);
david@8934
   130
    }
david@8918
   131
    return false;
david@8918
   132
  }
asier@8919
   133
asier@8919
   134
  function loginResult(paramXMLParticular, XMLHttpRequestObj) {
david@8931
   135
     var strText = '';
david@8931
   136
     if (getReadyStateHandler(XMLHttpRequestObj, null, false)) {
asier@8919
   137
       if (XMLHttpRequestObj.responseText) {
asier@8919
   138
         strText = XMLHttpRequestObj.responseText;
asier@8919
   139
       }
asier@8919
   140
       strText = strText.toString();
david@8931
   141
       var result = eval('('+strText+')');
asier@8919
   142
       processResult(result);
asier@8919
   143
     }
asier@8919
   144
  }
asier@8919
   145
asier@8919
   146
  function processResult(result){
asier@8919
   147
    if (result.showMessage) {
david@8958
   148
      setLoginMessage(result.messageType, result.messageTitle, result.messageText);
david@8934
   149
      document.getElementById('password').value = '';
david@8934
   150
      setWindowElementFocus('password', 'id');
asier@8919
   151
    }
asier@8919
   152
david@8931
   153
    if (!result.showMessage || result.messageType === 'Warning') {
david@8931
   154
      var target;
asier@8936
   155
      try {
asier@8936
   156
        if (parent.frameMenu) {
asier@8936
   157
          target = '_parent';
asier@8936
   158
        } else {
asier@8936
   159
          target = '_self';
asier@8936
   160
        }
asier@8936
   161
      } catch (e) {
asier@8936
   162
        target = '_self';
david@8931
   163
      }
asier@8935
   164
      submitCommandForm('DEFAULT', false, null, result.target, target, true);
asier@8923
   165
    } else {
david@8931
   166
      enableButton('buttonOK');
asier@8923
   167
    }
asier@8919
   168
  }
david@8918
   169
</script>
david@8918
   170
<script type="text/javascript">
david@8937
   171
  function manageVisualPreferences() {
david@8937
   172
    var bottomLogos = document.getElementById('BottomLogos_Container');
david@8939
   173
    if (showSupportLogo && showForgeLogo) {
david@8939
   174
      bottomLogos.className = 'Login_BottomLogos_Container_Support_Forge';
david@8937
   175
    } else if (showSupportLogo) {
david@8939
   176
      bottomLogos.className = 'Login_BottomLogos_Container_Support';
david@8939
   177
    } else if (showForgeLogo) {
david@8939
   178
      bottomLogos.className = 'Login_BottomLogos_Container_Forge';
david@8937
   179
    } else {
david@8939
   180
      bottomLogos.className = 'Login_BottomLogos_Container_None';
david@8937
   181
    }
david@8937
   182
david@8939
   183
    if (showCompanyLogo && urlCompany !== '') {
david@8937
   184
      document.getElementById('CompanyLogo_Container').innerHTML = '<a href="' + urlCompany + '" class="Login_Img_Link">' + document.getElementById('CompanyLogo_Container').innerHTML + '</a>';
david@8937
   185
    }
david@8937
   186
david@8939
   187
    if (showSupportLogo && urlSupport !== '') {
david@8937
   188
      document.getElementById('SupportLogo_Container').innerHTML = '<a href="' + urlSupport + '" class="Login_Img_Link">' + document.getElementById('SupportLogo_Container').innerHTML + '</a>';
david@8937
   189
    }
david@8937
   190
david@8939
   191
    if (showForgeLogo && urlForge !== '') {
david@8939
   192
      document.getElementById('ForgeLogo_Container').innerHTML = '<a href="' + urlForge + '" class="Login_Img_Link">' + document.getElementById('ForgeLogo_Container').innerHTML + '</a>';
david@8937
   193
    }
david@8937
   194
david@8937
   195
    if (showCompanyLogo) {
david@8939
   196
      document.getElementById('CompanyLogo_Container').style.display = ''
david@8937
   197
    }
david@8939
   198
    bottomLogos.style.display = '';
david@8958
   199
david@8958
   200
    var msgContainer = document.getElementById('errorMsg');
david@8958
   201
    msgContainer.innerHTML = '<span id="errorMsgTitle" class="Login_ErrorMsg_Title">xx</span><br><span id="errorMsgContent" class="Login_ErrorMsg_Content">xx</span>';
david@8937
   202
  }
david@8937
   203
</script>
david@8937
   204
<script type="text/javascript">
asier@8910
   205
  function beforeLoadDo() {
asier@8910
   206
    redirectWhenPopup();
asier@8910
   207
    redirectWhenInsideMDI();
asier@8910
   208
    hideMenuFrame();
asier@8910
   209
  }
asier@8910
   210
asier@8910
   211
  function onLoadDo() {
david@8937
   212
    manageVisualPreferences();
david@8918
   213
    this.windowTables = new Array(
david@8918
   214
      new windowTableId('client', 'buttonOK')
david@8918
   215
    );
david@8918
   216
    setWindowTableParentElement();
david@8918
   217
    enableShortcuts('edition');
david@8934
   218
    setWindowElementFocus('user', 'id');
asier@8923
   219
david@8958
   220
    if ((!revisionControl('8958')) || (isOpsInstance() != isOpsInstanceCached())) {
david@8958
   221
      setLoginMessage('Warning', '', cacheMsg);
asier@8923
   222
    }
asier@8923
   223
asier@8923
   224
    if (!checkBrowserCompatibility()) {
david@8958
   225
      setLoginMessage('Warning', '', browserMsg);
asier@8923
   226
    }
asier@8910
   227
  }
asier@8910
   228
</script>
david@8918
   229
<script type="text/javascript">
david@8918
   230
  beforeLoadDo();
david@8918
   231
</script>
asier@8910
   232
</head>
david@8918
   233
<body onload="onLoadDo();">
asier@8910
   234
david@8918
   235
  <div class="Login_Main" id="client">
asier@8910
   236
david@8937
   237
    <div class="Login_Container">
asier@8910
   238
david@8937
   239
      <div class="Login_LogForm">
david@8918
   240
        <form method="post" action="../secureApp/LoginHandler.html" name="frmIdentificacion" id="frmFormulario" autocomplete="off">
asier@8935
   241
            <input type="hidden" name="Command" value="" />
david@8937
   242
david@8937
   243
            <div class="Login_LogForm_CompanyLogo_Container">
david@8937
   244
              <div class="Login_LogForm_CompanyLogo" id="CompanyLogo_Container" style="display: none;"><img class="Login_Logo_Company" src="../../../../../web/images/blank.gif" /></div>
david@8918
   245
            </div>
david@8937
   246
            <div class="Login_LogForm_Input_Container">
david@8918
   247
              <dl>
david@8918
   248
                <dt>
david@8918
   249
                  <label for="user" class="LabelText Login_LabelText">User name</label>
david@8918
   250
                </dt>
david@8918
   251
                <dd>
david@8934
   252
                  <input class="dojoValidateValid Login_TextBox" type="text" maxlength="60" name="user" onKeyDown="resetMessage(); return true;" id="user"/>
david@8918
   253
                </dd>
david@8918
   254
                <dt>
david@8918
   255
                  <label for="password" class="LabelText Login_LabelText">Password</label>
david@8918
   256
                </dt>
david@8918
   257
                <dd>
david@8934
   258
                  <input class="dojoValidateValid Login_TextBox" type="password" maxlength="40" name="password" onKeyDown="resetMessage(); return true;" id="password"/>
david@8918
   259
                </dd>
david@8918
   260
              </dl>
david@8958
   261
              <div id="errorMsg" class="LabelText Login_ErrorMsg_Container" style="display: none"><!-- xxChild tags developed in javascript --></div>
david@8918
   262
            </div>
david@8937
   263
            <div class="Login_LogForm_Button_Container">
david@8937
   264
              <div class="Login_LogForm_Button">
david@8918
   265
                <button type="button" 
david@8918
   266
                  id="buttonOK" 
david@8918
   267
                  class="ButtonLink" 
david@8918
   268
                  onclick="buttonOK_click();" 
david@8918
   269
                  onfocus="buttonEvent('onfocus', this); window.status='Login'; return true;" 
david@8918
   270
                  onblur="buttonEvent('onblur', this);" 
david@8918
   271
                  onkeyup="buttonEvent('onkeyup', this);" 
david@8918
   272
                  onkeydown="buttonEvent('onkeydown', this);" 
david@8918
   273
                  onkeypress="buttonEvent('onkeypress', this);" 
david@8918
   274
                  onmouseup="buttonEvent('onmouseup', this);" 
david@8918
   275
                  onmousedown="buttonEvent('onmousedown', this);" 
david@8918
   276
                  onmouseover="buttonEvent('onmouseover', this); window.status='Login'; return true;" 
david@8918
   277
                  onmouseout="buttonEvent('onmouseout', this);">
david@8918
   278
                  <table class="Button" id="fieldTable">
david@8918
   279
                    <tr>
david@8918
   280
                      <td class="Button_left"><img class="Button_Icon Button_Icon_ok" alt="Login" title="Login" src="../../../../../web/images/blank.gif" border="0" id="fieldButton" /></td>
david@8937
   281
                      <td class="Button_text Button_width">Log in</td>
david@8918
   282
                      <td class="Button_right"></td>
david@8918
   283
                    </tr>
david@8918
   284
                  </table>
david@8918
   285
                </button>
david@8918
   286
              </div>
david@8918
   287
            </div>
david@8918
   288
david@8918
   289
        </form>
david@8918
   290
      </div>
david@8918
   291
          
david@8937
   292
      <div class="Login_TopLogos_Container">
david@8918
   293
        <div>
asier@8944
   294
          <img class="Main_NavBar_logo" src="../../../../../web/images/blank.gif" onclick="openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;" />
david@8937
   295
          <span class="Login_TopLogos_VersionNumber">3.0</span>
asier@8910
   296
        </div>
david@8937
   297
        <span class="Login_TopLogos_CopyrightText">&copy; Copyright Openbravo <br />
david@8918
   298
        2001-2010</span>
david@8918
   299
      </div>
david@8918
   300
david@8939
   301
      <div class="Login_BottomLogos_Container_Support_Forge" id="BottomLogos_Container" style="display: none;">
david@8937
   302
        <div class="Login_BottomLogos_SupportLogo_Container">
david@8937
   303
          <div class="LabelText Login_LabelText Login_BottomLogos_SupportLogo_Text">For support, contact:</div>
david@8937
   304
          <div class="Login_BottomLogos_SupportLogo_Logo_Container" id="SupportLogo_Container"><img class="Login_Logo_Support" src="../../../../../web/images/blank.gif" /></div>
asier@8910
   305
        </div>
david@8939
   306
        <div class="Login_BottomLogos_ForgeLogo_Container">
david@8939
   307
          <div class="LabelText Login_LabelText Login_BottomLogos_ForgeLogo_Text">Project hosted at:</div>
david@8939
   308
          <div class="Login_BottomLogos_ForgeLogo_Logo_Container" id="ForgeLogo_Container"><img class="Login_Logo_Forge" src="../../../../../web/images/blank.gif" /></div>
david@8918
   309
        </div>
david@8918
   310
      </div>
david@8918
   311
    </div>
asier@8910
   312
david@8918
   313
  </div>
asier@8910
   314
david@8918
   315
</body>
david@8918
   316
</html>