src/org/openbravo/erpCommon/security/Login.html
author David Baz Fayos <david.baz@openbravo.com>
Thu, 25 Nov 2010 14:10:18 +0100
changeset 9002 6af5592c6067
parent 8973 20437f0d16c5
child 9005 877851744012
permissions -rw-r--r--
[login] Now revisionControl number is displayed even if any previous js function fail
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
david@8973
   102
  function resetLoginMessage() {
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@8973
   110
david@8973
   111
  function addInputChangeCheck(input) {
david@8973
   112
    setObjAttribute(input, 'onkeypress', 'checkInputKeyDown(this); return true;');
david@8973
   113
    setObjAttribute(input, 'oncut', 'checkInputKeyDown(this); return true;');
david@8973
   114
    setObjAttribute(input, 'oncopy', 'checkInputKeyDown(this); return true;');
david@8973
   115
    setObjAttribute(input, 'onpaste', 'checkInputKeyDown(this); return true;');
david@8973
   116
  }
david@8973
   117
david@8973
   118
  function checkInputKeyDown(input, valueLength) {
david@8973
   119
    var msgContainer = document.getElementById('errorMsg');
david@8973
   120
    if (msgContainer.style.display !== "none" && typeof input === "object") {
david@8973
   121
      if (typeof valueLength === "undefined" || valueLength === null) {
david@8973
   122
        valueLength = input.value.length;
david@8973
   123
        setTimeout(function() { checkInputKeyDown(input, valueLength); }, 100);
david@8973
   124
      } else {
david@8973
   125
        if (valueLength !== input.value.length) {
david@8973
   126
          resetLoginMessage();
david@8973
   127
        }
david@8973
   128
      }
david@8973
   129
    }
david@8973
   130
    return true;
david@8973
   131
  }
david@8918
   132
</script>
david@8918
   133
<script type="text/javascript">
david@8918
   134
  function buttonOK_click() {
david@8939
   135
    if (focusedWindowElement.id === 'user' && document.getElementById('user').value === '') {
david@8934
   136
      return true;
david@8939
   137
    } else if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8937
   138
      setTimeout(function() { // To manage browser autocomplete feature if it is active
david@8939
   139
       if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8934
   140
         setWindowElementFocus(document.getElementById('password')) 
david@8934
   141
       } else {
david@8934
   142
         return true;
david@8934
   143
       }
david@8934
   144
      }, 10);
david@8939
   145
    } else if (focusedWindowElement.id === 'password' && document.getElementById('password').value === '') {
david@8934
   146
      return true;
david@8939
   147
    } else if (focusedWindowElement.id === 'password' && document.getElementById('user').value === '') {
david@8934
   148
      setWindowElementFocus(document.getElementById('user'))
david@8934
   149
    } else {
david@8934
   150
      disableButton('buttonOK');
david@8934
   151
      submitXmlHttpRequest(loginResult, document.frmIdentificacion, 'DEFAULT', '../secureApp/LoginHandler.html', false, null, null);
david@8934
   152
    }
david@8918
   153
    return false;
david@8918
   154
  }
asier@8919
   155
asier@8919
   156
  function loginResult(paramXMLParticular, XMLHttpRequestObj) {
david@8931
   157
     var strText = '';
david@8931
   158
     if (getReadyStateHandler(XMLHttpRequestObj, null, false)) {
asier@8919
   159
       if (XMLHttpRequestObj.responseText) {
asier@8919
   160
         strText = XMLHttpRequestObj.responseText;
asier@8919
   161
       }
asier@8919
   162
       strText = strText.toString();
david@8931
   163
       var result = eval('('+strText+')');
asier@8919
   164
       processResult(result);
asier@8919
   165
     }
asier@8919
   166
  }
asier@8919
   167
asier@8919
   168
  function processResult(result){
asier@8919
   169
    if (result.showMessage) {
david@8958
   170
      setLoginMessage(result.messageType, result.messageTitle, result.messageText);
david@8934
   171
      document.getElementById('password').value = '';
asier@8919
   172
    }
asier@8919
   173
david@8931
   174
    if (!result.showMessage || result.messageType === 'Warning') {
david@8931
   175
      var target;
asier@8936
   176
      try {
asier@8936
   177
        if (parent.frameMenu) {
asier@8936
   178
          target = '_parent';
asier@8936
   179
        } else {
asier@8936
   180
          target = '_self';
asier@8936
   181
        }
asier@8936
   182
      } catch (e) {
asier@8936
   183
        target = '_self';
david@8931
   184
      }
asier@8935
   185
      submitCommandForm('DEFAULT', false, null, result.target, target, true);
asier@8923
   186
    } else {
david@8931
   187
      enableButton('buttonOK');
david@8966
   188
      setWindowElementFocus('password', 'id');
asier@8923
   189
    }
asier@8919
   190
  }
david@8918
   191
</script>
david@8918
   192
<script type="text/javascript">
david@8937
   193
  function manageVisualPreferences() {
david@8937
   194
    var bottomLogos = document.getElementById('BottomLogos_Container');
david@8939
   195
    if (showSupportLogo && showForgeLogo) {
david@8939
   196
      bottomLogos.className = 'Login_BottomLogos_Container_Support_Forge';
david@8937
   197
    } else if (showSupportLogo) {
david@8939
   198
      bottomLogos.className = 'Login_BottomLogos_Container_Support';
david@8939
   199
    } else if (showForgeLogo) {
david@8939
   200
      bottomLogos.className = 'Login_BottomLogos_Container_Forge';
david@8937
   201
    } else {
david@8939
   202
      bottomLogos.className = 'Login_BottomLogos_Container_None';
david@8937
   203
    }
david@8937
   204
david@8939
   205
    if (showCompanyLogo && urlCompany !== '') {
david@8971
   206
      document.getElementById('CompanyLogo_Container').innerHTML = '<a href="' + urlCompany + '" target="_blank" class="Login_Img_Link">' + document.getElementById('CompanyLogo_Container').innerHTML + '</a>';
david@8937
   207
    }
david@8937
   208
david@8939
   209
    if (showSupportLogo && urlSupport !== '') {
david@8971
   210
      document.getElementById('SupportLogo_Container').innerHTML = '<a href="' + urlSupport + '" target="_blank" class="Login_Img_Link">' + document.getElementById('SupportLogo_Container').innerHTML + '</a>';
david@8937
   211
    }
david@8937
   212
david@8939
   213
    if (showForgeLogo && urlForge !== '') {
david@8971
   214
      document.getElementById('ForgeLogo_Container').innerHTML = '<a href="' + urlForge + '" target="_blank" class="Login_Img_Link">' + document.getElementById('ForgeLogo_Container').innerHTML + '</a>';
david@8937
   215
    }
david@8937
   216
david@8937
   217
    if (showCompanyLogo) {
david@8939
   218
      document.getElementById('CompanyLogo_Container').style.display = ''
david@8937
   219
    }
david@8939
   220
    bottomLogos.style.display = '';
david@8958
   221
david@8958
   222
    var msgContainer = document.getElementById('errorMsg');
david@8958
   223
    msgContainer.innerHTML = '<span id="errorMsgTitle" class="Login_ErrorMsg_Title">xx</span><br><span id="errorMsgContent" class="Login_ErrorMsg_Content">xx</span>';
david@8937
   224
  }
david@8937
   225
</script>
david@8937
   226
<script type="text/javascript">
asier@8910
   227
  function beforeLoadDo() {
asier@8910
   228
    redirectWhenPopup();
asier@8910
   229
    redirectWhenInsideMDI();
asier@8910
   230
    hideMenuFrame();
asier@8910
   231
  }
asier@8910
   232
asier@8910
   233
  function onLoadDo() {
david@9002
   234
    try { // To avoid in a release upgrade, that a change in code depending on these functions cause revisionControl message not being displayed
david@9002
   235
      manageVisualPreferences();
david@9002
   236
      addInputChangeCheck(document.getElementById('user'));
david@9002
   237
      addInputChangeCheck(document.getElementById('password'));
david@9002
   238
      this.windowTables = new Array(
david@9002
   239
        new windowTableId('client', 'buttonOK')
david@9002
   240
      );
david@9002
   241
      setWindowTableParentElement();
david@9002
   242
      enableShortcuts('edition');
david@9002
   243
      setWindowElementFocus('user', 'id');
david@9002
   244
    }
david@9002
   245
    catch (e) { }
asier@8923
   246
david@8958
   247
    if ((!revisionControl('8958')) || (isOpsInstance() != isOpsInstanceCached())) {
david@8958
   248
      setLoginMessage('Warning', '', cacheMsg);
asier@8923
   249
    }
asier@8923
   250
asier@8923
   251
    if (!checkBrowserCompatibility()) {
david@8958
   252
      setLoginMessage('Warning', '', browserMsg);
asier@8923
   253
    }
asier@8910
   254
  }
asier@8910
   255
</script>
david@8918
   256
<script type="text/javascript">
david@8918
   257
  beforeLoadDo();
david@8918
   258
</script>
asier@8910
   259
</head>
david@8918
   260
<body onload="onLoadDo();">
asier@8910
   261
david@8918
   262
  <div class="Login_Main" id="client">
asier@8910
   263
david@8937
   264
    <div class="Login_Container">
asier@8910
   265
david@8937
   266
      <div class="Login_LogForm">
david@8918
   267
        <form method="post" action="../secureApp/LoginHandler.html" name="frmIdentificacion" id="frmFormulario" autocomplete="off">
asier@8935
   268
            <input type="hidden" name="Command" value="" />
david@8937
   269
david@8937
   270
            <div class="Login_LogForm_CompanyLogo_Container">
david@8937
   271
              <div class="Login_LogForm_CompanyLogo" id="CompanyLogo_Container" style="display: none;"><img class="Login_Logo_Company" src="../../../../../web/images/blank.gif" /></div>
david@8918
   272
            </div>
david@8937
   273
            <div class="Login_LogForm_Input_Container">
david@8918
   274
              <dl>
david@8918
   275
                <dt>
david@8967
   276
                  <label for="user" class="LabelText Login_LabelText">User Name</label>
david@8918
   277
                </dt>
david@8918
   278
                <dd>
david@8973
   279
                  <input class="dojoValidateValid Login_TextBox" type="text" maxlength="60" name="user" id="user"/>
david@8918
   280
                </dd>
david@8918
   281
                <dt>
david@8918
   282
                  <label for="password" class="LabelText Login_LabelText">Password</label>
david@8918
   283
                </dt>
david@8918
   284
                <dd>
david@8973
   285
                  <input class="dojoValidateValid Login_TextBox" type="password" maxlength="40" name="password" id="password"/>
david@8918
   286
                </dd>
david@8918
   287
              </dl>
david@8958
   288
              <div id="errorMsg" class="LabelText Login_ErrorMsg_Container" style="display: none"><!-- xxChild tags developed in javascript --></div>
david@8918
   289
            </div>
david@8937
   290
            <div class="Login_LogForm_Button_Container">
david@8937
   291
              <div class="Login_LogForm_Button">
david@8918
   292
                <button type="button" 
david@8918
   293
                  id="buttonOK" 
david@8918
   294
                  class="ButtonLink" 
david@8918
   295
                  onclick="buttonOK_click();" 
david@8918
   296
                  onfocus="buttonEvent('onfocus', this); window.status='Login'; return true;" 
david@8918
   297
                  onblur="buttonEvent('onblur', this);" 
david@8918
   298
                  onkeyup="buttonEvent('onkeyup', this);" 
david@8918
   299
                  onkeydown="buttonEvent('onkeydown', this);" 
david@8918
   300
                  onkeypress="buttonEvent('onkeypress', this);" 
david@8918
   301
                  onmouseup="buttonEvent('onmouseup', this);" 
david@8918
   302
                  onmousedown="buttonEvent('onmousedown', this);" 
david@8918
   303
                  onmouseover="buttonEvent('onmouseover', this); window.status='Login'; return true;" 
david@8918
   304
                  onmouseout="buttonEvent('onmouseout', this);">
david@8918
   305
                  <table class="Button" id="fieldTable">
david@8918
   306
                    <tr>
david@8918
   307
                      <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
   308
                      <td class="Button_text Button_width">Log in</td>
david@8918
   309
                      <td class="Button_right"></td>
david@8918
   310
                    </tr>
david@8918
   311
                  </table>
david@8918
   312
                </button>
david@8918
   313
              </div>
david@8918
   314
            </div>
david@8918
   315
david@8918
   316
        </form>
david@8918
   317
      </div>
david@8918
   318
          
david@8937
   319
      <div class="Login_TopLogos_Container">
david@8918
   320
        <div>
asier@8944
   321
          <img class="Main_NavBar_logo" src="../../../../../web/images/blank.gif" onclick="openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;" />
david@8937
   322
          <span class="Login_TopLogos_VersionNumber">3.0</span>
asier@8910
   323
        </div>
david@8937
   324
        <span class="Login_TopLogos_CopyrightText">&copy; Copyright Openbravo <br />
david@8918
   325
        2001-2010</span>
david@8918
   326
      </div>
david@8918
   327
david@8939
   328
      <div class="Login_BottomLogos_Container_Support_Forge" id="BottomLogos_Container" style="display: none;">
david@8937
   329
        <div class="Login_BottomLogos_SupportLogo_Container">
david@8937
   330
          <div class="LabelText Login_LabelText Login_BottomLogos_SupportLogo_Text">For support, contact:</div>
david@8937
   331
          <div class="Login_BottomLogos_SupportLogo_Logo_Container" id="SupportLogo_Container"><img class="Login_Logo_Support" src="../../../../../web/images/blank.gif" /></div>
asier@8910
   332
        </div>
david@8939
   333
        <div class="Login_BottomLogos_ForgeLogo_Container">
david@8939
   334
          <div class="LabelText Login_LabelText Login_BottomLogos_ForgeLogo_Text">Project hosted at:</div>
david@8939
   335
          <div class="Login_BottomLogos_ForgeLogo_Logo_Container" id="ForgeLogo_Container"><img class="Login_Logo_Forge" src="../../../../../web/images/blank.gif" /></div>
david@8918
   336
        </div>
david@8918
   337
      </div>
david@8918
   338
    </div>
asier@8910
   339
david@8918
   340
  </div>
asier@8910
   341
david@8918
   342
</body>
david@8918
   343
</html>