src/org/openbravo/erpCommon/security/Login.html
author David Baz Fayos <david.baz@openbravo.com>
Mon, 31 Jan 2011 02:13:40 +0100
changeset 10246 bc0167ea077c
parent 10033 b7ed6692dd1f
child 10269 44d5aae0602b
permissions -rw-r--r--
[login] Added Chrome 5+ as supported browser and recommended browser's list
asier@8910
     1
<!--
asier@8910
     2
 *************************************************************************
asier@8910
     3
 * The contents of this file are subject to the Openbravo  Public  License
priya@9072
     4
 * Version  1.1  (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 
asier@10033
    14
 * All portions are Copyright (C) 2010-2011 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@10246
    36
<script language="JavaScript" type="text/javascript" id="validBrowserMsg">var validBrowserMsg = 'xx';</script>
david@10246
    37
<script language="JavaScript" type="text/javascript" id="recBrowserMsgTitle">var recBrowserMsgTitle = 'xx';</script>
david@10246
    38
<script language="JavaScript" type="text/javascript" id="recBrowserMsgText">var recBrowserMsgText = 'xx';</script>
asier@8923
    39
asier@8910
    40
<script type="text/javascript">
asier@8910
    41
  function redirectWhenPopup() {
asier@8910
    42
    var permission = false;
asier@8910
    43
    try {
asier@8910
    44
      if (top.opener.parent.frames['appFrame']) {
asier@8910
    45
        permission = true;
asier@8910
    46
      }
asier@8910
    47
    }
asier@8910
    48
    catch (e) {}
asier@8910
    49
    if (permission && top.opener) {
asier@8910
    50
      top.opener.parent.location.href = top.document.location.href;
asier@8910
    51
      top.window.close();
asier@8910
    52
    }
asier@8910
    53
  }
asier@8910
    54
asier@8910
    55
  function redirectWhenInsideMDI() {
asier@8910
    56
    if (typeof isWindowInMDIPage !== 'undefined' && isWindowInMDIPage) {
david@8918
    57
      var LayoutMDI = null;
david@8918
    58
      if (isWindowInMDIPopup && parent.opener) {
david@8918
    59
        LayoutMDI = parent.opener.getFrame('LayoutMDI'); // Since getFrame('LayoutMDI') function frameset checks equals the current opened Login_FS.html modal popup
david@8918
    60
      } else {
david@8918
    61
        LayoutMDI = getFrame('LayoutMDI');
david@8918
    62
      }
asier@8910
    63
      if (LayoutMDI && typeof parent.document.getElementById('framesetMenu') === 'object') {
asier@8910
    64
        LayoutMDI.location.href = parent.window.location.href;
asier@8910
    65
      }
asier@8910
    66
    }
asier@8910
    67
  }
asier@8910
    68
asier@8910
    69
  function hideMenuFrame() {
asier@8910
    70
    if (parent.document.getElementById('framesetMenu')) {
asier@8910
    71
      parent.document.getElementById('framesetMenu').cols = parent.document.getElementById('framesetMenu').cols.replace(parent.menuWidth, '0%');
asier@8910
    72
    }
asier@8910
    73
  }
david@8918
    74
</script>
david@8918
    75
<script type="text/javascript">
david@8958
    76
  function setLoginMessage(type, title, text) {
david@8931
    77
    if (type === 'Error') {
david@8918
    78
      var msgContainer = document.getElementById('errorMsg');
david@8958
    79
      var msgContainerTitle = document.getElementById('errorMsgTitle');
david@8958
    80
      var msgContainerContent = document.getElementById('errorMsgContent');
david@8958
    81
      if (typeof title !== 'undefined' && title !== '' && title !== null) {
david@8958
    82
        msgContainerTitle.innerHTML = title.replace(/\n/g, '<br>').replace(/\\n/g, '<br>');
david@8958
    83
      } else {
david@8958
    84
        msgContainerTitle.innerHTML = '';
david@8958
    85
      }
david@8958
    86
      if (typeof text !== 'undefined' && text !== '' && text !== null) {
david@8958
    87
        msgContainerContent.innerHTML = text.replace(/\n/g, '<br>').replace(/\\n/g, '<br>');
david@8958
    88
      } else {
david@8958
    89
        msgContainerContent.innerHTML = '';
david@8958
    90
      }
david@8931
    91
      msgContainer.style.display = '';
david@8931
    92
    } else if (type === 'Warning') {
david@8958
    93
      var alertText = '';
david@8958
    94
      if (typeof title !== 'undefined' && title !== '' && title !== null) {
david@8958
    95
        alertText += title.replace(/<br>/g, '\n') + '\n';
david@8958
    96
      }
david@8958
    97
      if (typeof text !== 'undefined' && text !== '' && text !== null) {
david@8958
    98
        alertText += text.replace(/<br>/g, '\n')
david@8958
    99
      }
david@8958
   100
      alert(alertText);
asier@8910
   101
    }
asier@8910
   102
  }
asier@8921
   103
david@10246
   104
  function setRecommendedBrowserMessage(title, text) {
david@10246
   105
    var msgContainer = document.getElementById('errorMsg');
david@10246
   106
    var msgContainerTitle = document.getElementById('errorMsgTitle');
david@10246
   107
    var msgContainerContent = document.getElementById('errorMsgContent');
david@10246
   108
    msgContainerTitle.innerHTML = '';
david@10246
   109
    if (typeof title !== 'undefined' && title !== '' && title !== null) {
david@10246
   110
      msgContainerContent.innerHTML = '<span class="Login_RecBrowserMsg_Title">' + title.replace(/\n/g, '<br>').replace(/\\n/g, '<br>') + ': ' + '</span>';
david@10246
   111
    } else {
david@10246
   112
      msgContainerContent.innerHTML = '';
david@10246
   113
    }
david@10246
   114
    if (typeof text !== 'undefined' && text !== '' && text !== null) {
david@10246
   115
      msgContainerContent.innerHTML = msgContainerContent.innerHTML + '<span class="Login_RecBrowserMsg_Content">' + text.replace(/\n/g, '<br>').replace(/\\n/g, '<br>') + '</span>';
david@10246
   116
    }
david@10246
   117
    msgContainer.style.display = '';
david@10246
   118
  }
david@10246
   119
david@8973
   120
  function resetLoginMessage() {
asier@8921
   121
    var msgContainer = document.getElementById('errorMsg');
david@8958
   122
    var msgContainerTitle = document.getElementById('errorMsgTitle');
david@8958
   123
    var msgContainerContent = document.getElementById('errorMsgContent');
david@8958
   124
    msgContainerTitle.innerHTML = '';
david@8958
   125
    msgContainerContent.innerHTML = '';
david@8931
   126
    msgContainer.style.display = 'none';
asier@8921
   127
  }
david@8973
   128
david@8973
   129
  function addInputChangeCheck(input) {
david@8973
   130
    setObjAttribute(input, 'onkeypress', 'checkInputKeyDown(this); return true;');
david@8973
   131
    setObjAttribute(input, 'oncut', 'checkInputKeyDown(this); return true;');
david@8973
   132
    setObjAttribute(input, 'oncopy', 'checkInputKeyDown(this); return true;');
david@8973
   133
    setObjAttribute(input, 'onpaste', 'checkInputKeyDown(this); return true;');
david@8973
   134
  }
david@8973
   135
david@8973
   136
  function checkInputKeyDown(input, valueLength) {
david@8973
   137
    var msgContainer = document.getElementById('errorMsg');
david@8973
   138
    if (msgContainer.style.display !== "none" && typeof input === "object") {
david@8973
   139
      if (typeof valueLength === "undefined" || valueLength === null) {
david@8973
   140
        valueLength = input.value.length;
david@8973
   141
        setTimeout(function() { checkInputKeyDown(input, valueLength); }, 100);
david@8973
   142
      } else {
david@8973
   143
        if (valueLength !== input.value.length) {
david@8973
   144
          resetLoginMessage();
david@8973
   145
        }
david@8973
   146
      }
david@8973
   147
    }
david@8973
   148
    return true;
david@8973
   149
  }
david@8918
   150
</script>
david@8918
   151
<script type="text/javascript">
david@8918
   152
  function buttonOK_click() {
david@8939
   153
    if (focusedWindowElement.id === 'user' && document.getElementById('user').value === '') {
david@8934
   154
      return true;
david@8939
   155
    } else if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8937
   156
      setTimeout(function() { // To manage browser autocomplete feature if it is active
david@8939
   157
       if (focusedWindowElement.id === 'user' && document.getElementById('password').value === '') {
david@8934
   158
         setWindowElementFocus(document.getElementById('password')) 
david@8934
   159
       } else {
david@8934
   160
         return true;
david@8934
   161
       }
david@8934
   162
      }, 10);
david@8939
   163
    } else if (focusedWindowElement.id === 'password' && document.getElementById('password').value === '') {
david@8934
   164
      return true;
david@8939
   165
    } else if (focusedWindowElement.id === 'password' && document.getElementById('user').value === '') {
david@8934
   166
      setWindowElementFocus(document.getElementById('user'))
david@8934
   167
    } else {
david@8934
   168
      disableButton('buttonOK');
david@8934
   169
      submitXmlHttpRequest(loginResult, document.frmIdentificacion, 'DEFAULT', '../secureApp/LoginHandler.html', false, null, null);
david@8934
   170
    }
david@8918
   171
    return false;
david@8918
   172
  }
asier@8919
   173
asier@8919
   174
  function loginResult(paramXMLParticular, XMLHttpRequestObj) {
david@8931
   175
     var strText = '';
david@8931
   176
     if (getReadyStateHandler(XMLHttpRequestObj, null, false)) {
asier@8919
   177
       if (XMLHttpRequestObj.responseText) {
asier@8919
   178
         strText = XMLHttpRequestObj.responseText;
asier@8919
   179
       }
asier@8919
   180
       strText = strText.toString();
david@8931
   181
       var result = eval('('+strText+')');
asier@8919
   182
       processResult(result);
asier@8919
   183
     }
asier@8919
   184
  }
asier@8919
   185
asier@8919
   186
  function processResult(result){
asier@8919
   187
    if (result.showMessage) {
david@8958
   188
      setLoginMessage(result.messageType, result.messageTitle, result.messageText);
david@8934
   189
      document.getElementById('password').value = '';
asier@8919
   190
    }
asier@8919
   191
david@8931
   192
    if (!result.showMessage || result.messageType === 'Warning') {
david@8931
   193
      var target;
asier@8936
   194
      try {
asier@8936
   195
        if (parent.frameMenu) {
asier@8936
   196
          target = '_parent';
asier@8936
   197
        } else {
asier@8936
   198
          target = '_self';
asier@8936
   199
        }
asier@8936
   200
      } catch (e) {
asier@8936
   201
        target = '_self';
david@8931
   202
      }
asier@8935
   203
      submitCommandForm('DEFAULT', false, null, result.target, target, true);
asier@8923
   204
    } else {
david@8931
   205
      enableButton('buttonOK');
david@8966
   206
      setWindowElementFocus('password', 'id');
asier@8923
   207
    }
asier@8919
   208
  }
david@8918
   209
</script>
david@8918
   210
<script type="text/javascript">
david@8937
   211
  function manageVisualPreferences() {
david@8937
   212
    var bottomLogos = document.getElementById('BottomLogos_Container');
david@8939
   213
    if (showSupportLogo && showForgeLogo) {
david@8939
   214
      bottomLogos.className = 'Login_BottomLogos_Container_Support_Forge';
david@8937
   215
    } else if (showSupportLogo) {
david@8939
   216
      bottomLogos.className = 'Login_BottomLogos_Container_Support';
david@8939
   217
    } else if (showForgeLogo) {
david@8939
   218
      bottomLogos.className = 'Login_BottomLogos_Container_Forge';
david@8937
   219
    } else {
david@8939
   220
      bottomLogos.className = 'Login_BottomLogos_Container_None';
david@8937
   221
    }
david@8937
   222
david@8939
   223
    if (showCompanyLogo && urlCompany !== '') {
david@8971
   224
      document.getElementById('CompanyLogo_Container').innerHTML = '<a href="' + urlCompany + '" target="_blank" class="Login_Img_Link">' + document.getElementById('CompanyLogo_Container').innerHTML + '</a>';
david@8937
   225
    }
david@8937
   226
david@8939
   227
    if (showSupportLogo && urlSupport !== '') {
david@8971
   228
      document.getElementById('SupportLogo_Container').innerHTML = '<a href="' + urlSupport + '" target="_blank" class="Login_Img_Link">' + document.getElementById('SupportLogo_Container').innerHTML + '</a>';
david@8937
   229
    }
david@8937
   230
david@8939
   231
    if (showForgeLogo && urlForge !== '') {
david@8971
   232
      document.getElementById('ForgeLogo_Container').innerHTML = '<a href="' + urlForge + '" target="_blank" class="Login_Img_Link">' + document.getElementById('ForgeLogo_Container').innerHTML + '</a>';
david@8937
   233
    }
david@8937
   234
david@8937
   235
    if (showCompanyLogo) {
david@8939
   236
      document.getElementById('CompanyLogo_Container').style.display = ''
david@8937
   237
    }
david@8939
   238
    bottomLogos.style.display = '';
david@8958
   239
david@8958
   240
    var msgContainer = document.getElementById('errorMsg');
david@8958
   241
    msgContainer.innerHTML = '<span id="errorMsgTitle" class="Login_ErrorMsg_Title">xx</span><br><span id="errorMsgContent" class="Login_ErrorMsg_Content">xx</span>';
david@8937
   242
  }
david@9005
   243
david@9005
   244
  function maskLoginWindow(errorMsg) {
david@9005
   245
    var client = document.getElementById('client');
david@9005
   246
    var blocker = document.getElementById('blocker');
david@9005
   247
    blocker.innerHTML = '<div class="Login_Home_Logo_Icon" style="position: relative; padding: 50px 0px 0px 0px; margin: 0 auto;"></div><div class="LabelText" style="position: relative; text-align: center; color: red; font-size: 11pt; padding: 10px 0px 0px 0px; width: 608px; margin: 0 auto;">' + errorMsg + '</div>';
david@9005
   248
    blocker.style.display = '';
david@9005
   249
    client.style.display = 'none';
david@9005
   250
  }
david@8937
   251
</script>
david@8937
   252
<script type="text/javascript">
asier@8910
   253
  function beforeLoadDo() {
asier@8910
   254
    redirectWhenPopup();
asier@8910
   255
    redirectWhenInsideMDI();
asier@8910
   256
    hideMenuFrame();
asier@8910
   257
  }
asier@8910
   258
asier@8910
   259
  function onLoadDo() {
david@9002
   260
    try { // To avoid in a release upgrade, that a change in code depending on these functions cause revisionControl message not being displayed
david@9002
   261
      manageVisualPreferences();
david@9002
   262
      addInputChangeCheck(document.getElementById('user'));
david@9002
   263
      addInputChangeCheck(document.getElementById('password'));
david@9002
   264
      this.windowTables = new Array(
david@9002
   265
        new windowTableId('client', 'buttonOK')
david@9002
   266
      );
david@9002
   267
      setWindowTableParentElement();
david@9002
   268
      enableShortcuts('edition');
david@9002
   269
      setWindowElementFocus('user', 'id');
david@9002
   270
    }
david@9002
   271
    catch (e) { }
asier@8923
   272
david@10246
   273
    if ((!revisionControl('10246')) || (isOpsInstance() != isOpsInstanceCached())) {
david@9005
   274
      maskLoginWindow(cacheMsg);
david@8958
   275
      setLoginMessage('Warning', '', cacheMsg);
asier@8923
   276
    }
asier@8923
   277
asier@8923
   278
    if (!checkBrowserCompatibility()) {
david@10246
   279
      setLoginMessage('Warning', '', validBrowserMsg);
david@10246
   280
    }
david@10246
   281
    if (!checkRecommendedBrowser()) {
david@10246
   282
      setRecommendedBrowserMessage(recBrowserMsgTitle, recBrowserMsgText);
asier@8923
   283
    }
asier@8910
   284
  }
asier@8910
   285
</script>
david@8918
   286
<script type="text/javascript">
david@8918
   287
  beforeLoadDo();
david@8918
   288
</script>
asier@8910
   289
</head>
david@8918
   290
<body onload="onLoadDo();">
david@9005
   291
  <div style="display: none; width: 100%; height: 100%; position: absolute; vertical-align: middle; padding: 0px; text-align: center;" id="blocker"></div>
asier@8910
   292
david@8918
   293
  <div class="Login_Main" id="client">
asier@8910
   294
david@8937
   295
    <div class="Login_Container">
asier@8910
   296
david@8937
   297
      <div class="Login_LogForm">
david@8918
   298
        <form method="post" action="../secureApp/LoginHandler.html" name="frmIdentificacion" id="frmFormulario" autocomplete="off">
asier@8935
   299
            <input type="hidden" name="Command" value="" />
david@8937
   300
david@8937
   301
            <div class="Login_LogForm_CompanyLogo_Container">
david@8937
   302
              <div class="Login_LogForm_CompanyLogo" id="CompanyLogo_Container" style="display: none;"><img class="Login_Logo_Company" src="../../../../../web/images/blank.gif" /></div>
david@8918
   303
            </div>
david@8937
   304
            <div class="Login_LogForm_Input_Container">
david@8918
   305
              <dl>
david@8918
   306
                <dt>
david@8967
   307
                  <label for="user" class="LabelText Login_LabelText">User Name</label>
david@8918
   308
                </dt>
david@8918
   309
                <dd>
david@8973
   310
                  <input class="dojoValidateValid Login_TextBox" type="text" maxlength="60" name="user" id="user"/>
david@8918
   311
                </dd>
david@8918
   312
                <dt>
david@8918
   313
                  <label for="password" class="LabelText Login_LabelText">Password</label>
david@8918
   314
                </dt>
david@8918
   315
                <dd>
david@8973
   316
                  <input class="dojoValidateValid Login_TextBox" type="password" maxlength="40" name="password" id="password"/>
david@8918
   317
                </dd>
david@8918
   318
              </dl>
david@8958
   319
              <div id="errorMsg" class="LabelText Login_ErrorMsg_Container" style="display: none"><!-- xxChild tags developed in javascript --></div>
david@8918
   320
            </div>
david@8937
   321
            <div class="Login_LogForm_Button_Container">
david@8937
   322
              <div class="Login_LogForm_Button">
david@8918
   323
                <button type="button" 
david@8918
   324
                  id="buttonOK" 
david@8918
   325
                  class="ButtonLink" 
david@8918
   326
                  onclick="buttonOK_click();" 
david@8918
   327
                  onfocus="buttonEvent('onfocus', this); window.status='Login'; return true;" 
david@8918
   328
                  onblur="buttonEvent('onblur', this);" 
david@8918
   329
                  onkeyup="buttonEvent('onkeyup', this);" 
david@8918
   330
                  onkeydown="buttonEvent('onkeydown', this);" 
david@8918
   331
                  onkeypress="buttonEvent('onkeypress', this);" 
david@8918
   332
                  onmouseup="buttonEvent('onmouseup', this);" 
david@8918
   333
                  onmousedown="buttonEvent('onmousedown', this);" 
david@8918
   334
                  onmouseover="buttonEvent('onmouseover', this); window.status='Login'; return true;" 
david@8918
   335
                  onmouseout="buttonEvent('onmouseout', this);">
david@8918
   336
                  <table class="Button" id="fieldTable">
david@8918
   337
                    <tr>
david@8918
   338
                      <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
   339
                      <td class="Button_text Button_width">Log in</td>
david@8918
   340
                      <td class="Button_right"></td>
david@8918
   341
                    </tr>
david@8918
   342
                  </table>
david@8918
   343
                </button>
david@8918
   344
              </div>
david@8918
   345
            </div>
david@8918
   346
david@8918
   347
        </form>
david@8918
   348
      </div>
david@8918
   349
          
david@8937
   350
      <div class="Login_TopLogos_Container">
david@8918
   351
        <div>
asier@8944
   352
          <img class="Main_NavBar_logo" src="../../../../../web/images/blank.gif" onclick="openNewBrowser('http://www.openbravo.com', 'Openbravo');return false;" />
david@8937
   353
          <span class="Login_TopLogos_VersionNumber">3.0</span>
asier@8910
   354
        </div>
david@8937
   355
        <span class="Login_TopLogos_CopyrightText">&copy; Copyright Openbravo <br />
david@8918
   356
        2001-2010</span>
david@8918
   357
      </div>
david@8918
   358
david@8939
   359
      <div class="Login_BottomLogos_Container_Support_Forge" id="BottomLogos_Container" style="display: none;">
david@8937
   360
        <div class="Login_BottomLogos_SupportLogo_Container">
david@8937
   361
          <div class="LabelText Login_LabelText Login_BottomLogos_SupportLogo_Text">For support, contact:</div>
david@8937
   362
          <div class="Login_BottomLogos_SupportLogo_Logo_Container" id="SupportLogo_Container"><img class="Login_Logo_Support" src="../../../../../web/images/blank.gif" /></div>
asier@8910
   363
        </div>
david@8939
   364
        <div class="Login_BottomLogos_ForgeLogo_Container">
david@8939
   365
          <div class="LabelText Login_LabelText Login_BottomLogos_ForgeLogo_Text">Project hosted at:</div>
david@8939
   366
          <div class="Login_BottomLogos_ForgeLogo_Logo_Container" id="ForgeLogo_Container"><img class="Login_Logo_Forge" src="../../../../../web/images/blank.gif" /></div>
david@8918
   367
        </div>
david@8918
   368
      </div>
david@8918
   369
    </div>
asier@8910
   370
david@8918
   371
  </div>
asier@8910
   372
david@8918
   373
</body>
david@8918
   374
</html>