src/org/openbravo/erpCommon/security/Login.html
author Asier Lostalé <asier.lostale@openbravo.com>
Tue, 16 Nov 2010 12:48:29 +0100
changeset 8936 5e97328b240d
parent 8935 78552d6c531d
child 8937 ebdd64b7e73b
permissions -rw-r--r--
[login] properly calculate target
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@8931
    33
<script language="JavaScript" type="text/javascript" id="cacheMsg">var cacheMsg = 'xx';</script>
david@8931
    34
<script language="JavaScript" type="text/javascript" id="browserMsg">var browserMsg = 'xx';</script>
asier@8923
    35
asier@8910
    36
<script type="text/javascript">
asier@8910
    37
  function redirectWhenPopup() {
asier@8910
    38
    var permission = false;
asier@8910
    39
    try {
asier@8910
    40
      if (top.opener.parent.frames['appFrame']) {
asier@8910
    41
        permission = true;
asier@8910
    42
      }
asier@8910
    43
    }
asier@8910
    44
    catch (e) {}
asier@8910
    45
    if (permission && top.opener) {
asier@8910
    46
      top.opener.parent.location.href = top.document.location.href;
asier@8910
    47
      top.window.close();
asier@8910
    48
    }
asier@8910
    49
  }
asier@8910
    50
asier@8910
    51
  function redirectWhenInsideMDI() {
asier@8910
    52
    if (typeof isWindowInMDIPage !== 'undefined' && isWindowInMDIPage) {
david@8918
    53
      var LayoutMDI = null;
david@8918
    54
      if (isWindowInMDIPopup && parent.opener) {
david@8918
    55
        LayoutMDI = parent.opener.getFrame('LayoutMDI'); // Since getFrame('LayoutMDI') function frameset checks equals the current opened Login_FS.html modal popup
david@8918
    56
      } else {
david@8918
    57
        LayoutMDI = getFrame('LayoutMDI');
david@8918
    58
      }
asier@8910
    59
      if (LayoutMDI && typeof parent.document.getElementById('framesetMenu') === 'object') {
asier@8910
    60
        LayoutMDI.location.href = parent.window.location.href;
asier@8910
    61
      }
asier@8910
    62
    }
asier@8910
    63
  }
asier@8910
    64
asier@8910
    65
  function hideMenuFrame() {
asier@8910
    66
    if (parent.document.getElementById('framesetMenu')) {
asier@8910
    67
      parent.document.getElementById('framesetMenu').cols = parent.document.getElementById('framesetMenu').cols.replace(parent.menuWidth, '0%');
asier@8910
    68
    }
asier@8910
    69
  }
david@8918
    70
</script>
david@8918
    71
<script type="text/javascript">
david@8918
    72
  function setLoginMessage(type, text) {
david@8931
    73
    if (type === 'Error') {
david@8918
    74
      var msgContainer = document.getElementById('errorMsg');
david@8931
    75
      msgContainer.innerHTML = text.replace(/\n/g, '<br>').replace(/\\n/g, '<br>');
david@8931
    76
      msgContainer.style.display = '';
david@8931
    77
    } else if (type === 'Warning') {
david@8931
    78
      alert(text.replace(/<br>/g, '\n'));
asier@8910
    79
    }
asier@8910
    80
  }
asier@8921
    81
asier@8921
    82
  function resetMessage(){
asier@8921
    83
    var msgContainer = document.getElementById('errorMsg');
david@8931
    84
    msgContainer.innerHTML = '';
david@8931
    85
    msgContainer.style.display = 'none';
asier@8921
    86
  }
david@8918
    87
</script>
david@8918
    88
<script type="text/javascript">
david@8918
    89
  function buttonOK_click() {
david@8934
    90
    if (focusedWindowElement.id === "user" && document.getElementById('user').value === "") {
david@8934
    91
      return true;
david@8934
    92
    } else if (focusedWindowElement.id === "user" && document.getElementById('password').value === "") {
david@8934
    93
      setTimeout(function() { // To manage browser autocomplete feature
david@8934
    94
       if (focusedWindowElement.id === "user" && document.getElementById('password').value === "") {
david@8934
    95
         setWindowElementFocus(document.getElementById('password')) 
david@8934
    96
       } else {
david@8934
    97
         return true;
david@8934
    98
       }
david@8934
    99
      }, 10);
david@8934
   100
    } else if (focusedWindowElement.id === "password" && document.getElementById('password').value === "") {
david@8934
   101
      return true;
david@8934
   102
    } else if (focusedWindowElement.id === "password" && document.getElementById('user').value === "") {
david@8934
   103
      setWindowElementFocus(document.getElementById('user'))
david@8934
   104
    } else {
david@8934
   105
      disableButton('buttonOK');
david@8934
   106
      submitXmlHttpRequest(loginResult, document.frmIdentificacion, 'DEFAULT', '../secureApp/LoginHandler.html', false, null, null);
david@8934
   107
    }
david@8918
   108
    return false;
david@8918
   109
  }
asier@8919
   110
asier@8919
   111
  function loginResult(paramXMLParticular, XMLHttpRequestObj) {
david@8931
   112
     var strText = '';
david@8931
   113
     if (getReadyStateHandler(XMLHttpRequestObj, null, false)) {
asier@8919
   114
       if (XMLHttpRequestObj.responseText) {
asier@8919
   115
         strText = XMLHttpRequestObj.responseText;
asier@8919
   116
       }
asier@8919
   117
       strText = strText.toString();
david@8931
   118
       var result = eval('('+strText+')');
asier@8919
   119
       processResult(result);
asier@8919
   120
     }
asier@8919
   121
  }
asier@8919
   122
asier@8919
   123
  function processResult(result){
asier@8919
   124
    if (result.showMessage) {
david@8931
   125
      setLoginMessage(result.messageType, result.messageTitle + '\n' + result.messageText);
david@8934
   126
      document.getElementById('password').value = '';
david@8934
   127
      setWindowElementFocus('password', 'id');
asier@8919
   128
    }
asier@8919
   129
david@8931
   130
    if (!result.showMessage || result.messageType === 'Warning') {
david@8931
   131
      var target;
asier@8936
   132
      try {
asier@8936
   133
        if (parent.frameMenu) {
asier@8936
   134
          target = '_parent';
asier@8936
   135
        } else {
asier@8936
   136
          target = '_self';
asier@8936
   137
        }
asier@8936
   138
      } catch (e) {
asier@8936
   139
        target = '_self';
david@8931
   140
      }
asier@8935
   141
      submitCommandForm('DEFAULT', false, null, result.target, target, true);
asier@8923
   142
    } else {
david@8931
   143
      enableButton('buttonOK');
asier@8923
   144
    }
asier@8919
   145
  }
david@8918
   146
</script>
david@8918
   147
<script type="text/javascript">
asier@8910
   148
  function beforeLoadDo() {
asier@8910
   149
    redirectWhenPopup();
asier@8910
   150
    redirectWhenInsideMDI();
asier@8910
   151
    hideMenuFrame();
asier@8910
   152
  }
asier@8910
   153
asier@8910
   154
  function onLoadDo() {
david@8918
   155
    this.windowTables = new Array(
david@8918
   156
      new windowTableId('client', 'buttonOK')
david@8918
   157
    );
david@8918
   158
    setWindowTableParentElement();
david@8918
   159
    enableShortcuts('edition');
david@8934
   160
    setWindowElementFocus('user', 'id');
asier@8923
   161
asier@8923
   162
    if ((!revisionControl('8847')) || (isOpsInstance() != isOpsInstanceCached())) {
david@8931
   163
      setLoginMessage('Warning', cacheMsg);
asier@8923
   164
    }
asier@8923
   165
asier@8923
   166
    if (!checkBrowserCompatibility()) {
david@8931
   167
      setLoginMessage('Warning', browserMsg);
asier@8923
   168
    }
asier@8910
   169
  }
asier@8910
   170
</script>
david@8918
   171
<script type="text/javascript">
david@8918
   172
  beforeLoadDo();
david@8918
   173
</script>
asier@8910
   174
</head>
david@8918
   175
<body onload="onLoadDo();">
asier@8910
   176
david@8918
   177
  <div class="Login_Main" id="client">
asier@8910
   178
david@8918
   179
    <div class="container">
asier@8910
   180
david@8918
   181
      <div class="logbox">
david@8918
   182
        <form method="post" action="../secureApp/LoginHandler.html" name="frmIdentificacion" id="frmFormulario" autocomplete="off">
asier@8935
   183
            <input type="hidden" name="Command" value="" />
asier@8935
   184
            
david@8918
   185
            <div style="height: 115px; text-align: center;">
david@8918
   186
              <div style="padding-top: 25px;"><a href="#" class="Login_Img_Link"><img class="Login_Logo_Company" src="../../../../../web/images/blank.gif" /></a></div>
david@8918
   187
            </div>
david@8918
   188
            <div style="height: 162px !important;">
david@8918
   189
              <dl>
david@8918
   190
                <dt>
david@8918
   191
                  <label for="user" class="LabelText Login_LabelText">User name</label>
david@8918
   192
                </dt>
david@8918
   193
                <dd>
david@8934
   194
                  <input class="dojoValidateValid Login_TextBox" type="text" maxlength="60" name="user" onKeyDown="resetMessage(); return true;" id="user"/>
david@8918
   195
                </dd>
david@8918
   196
                <dt>
david@8918
   197
                  <label for="password" class="LabelText Login_LabelText">Password</label>
david@8918
   198
                </dt>
david@8918
   199
                <dd>
david@8934
   200
                  <input class="dojoValidateValid Login_TextBox" type="password" maxlength="40" name="password" onKeyDown="resetMessage(); return true;" id="password"/>
david@8918
   201
                </dd>
david@8918
   202
              </dl>
david@8918
   203
              <div id="errorMsg" class="LabelText Login_ErrorMsg_LabelText" style="display: none;">The username or password you entered is not correct.</div>
david@8918
   204
            </div>
david@8918
   205
            <div class="button">
david@8918
   206
              <div>
david@8918
   207
                <button type="button" 
david@8918
   208
                  id="buttonOK" 
david@8918
   209
                  class="ButtonLink" 
david@8918
   210
                  onclick="buttonOK_click();" 
david@8918
   211
                  onfocus="buttonEvent('onfocus', this); window.status='Login'; return true;" 
david@8918
   212
                  onblur="buttonEvent('onblur', this);" 
david@8918
   213
                  onkeyup="buttonEvent('onkeyup', this);" 
david@8918
   214
                  onkeydown="buttonEvent('onkeydown', this);" 
david@8918
   215
                  onkeypress="buttonEvent('onkeypress', this);" 
david@8918
   216
                  onmouseup="buttonEvent('onmouseup', this);" 
david@8918
   217
                  onmousedown="buttonEvent('onmousedown', this);" 
david@8918
   218
                  onmouseover="buttonEvent('onmouseover', this); window.status='Login'; return true;" 
david@8918
   219
                  onmouseout="buttonEvent('onmouseout', this);">
david@8918
   220
                  <table class="Button" id="fieldTable">
david@8918
   221
                    <tr>
david@8918
   222
                      <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@8918
   223
                      <td class="Button_text Button_width">Login</td>
david@8918
   224
                      <td class="Button_right"></td>
david@8918
   225
                    </tr>
david@8918
   226
                  </table>
david@8918
   227
                </button>
david@8918
   228
              </div>
david@8918
   229
            </div>
david@8918
   230
david@8918
   231
        </form>
david@8918
   232
      </div>
david@8918
   233
          
david@8918
   234
      <div class="login-top">
david@8918
   235
        <div>
david@8918
   236
          <img class="Main_NavBar_logo" src="../../../../../web/images/blank.gif" />
david@8918
   237
          <span style="margin-left: 520px; font-size: 70px; font-style: italic; font-weight: bold; color: #7F7F7F; font-family:'lucida sans',sans-serif;">3.0</span>
asier@8910
   238
        </div>
david@8918
   239
        <span style="display: block; margin-top: 215px; color: #afafaf; font-size: .9em;line-height: 0.9em; width: 14em; text-align: center; padding-bottom: 34px;">&copy; Copyright Openbravo <br />
david@8918
   240
        2001-2010</span>
david@8918
   241
      </div>
david@8918
   242
david@8918
   243
      <div style="position: relative; left: 110px; text-align: center; width: 100%;">
david@8918
   244
        <div style="width: 260px; position: relative; float: left;">
david@8918
   245
          <div style="text-align: center;" class="LabelText Login_LabelText">For support, contact:</div>
david@8918
   246
          <div style="text-align: center;"><a href="#" class="Login_Img_Link"><img class="Login_Logo_Support" src="../../../../../web/images/blank.gif" /></a></div>
asier@8910
   247
        </div>
david@8918
   248
        <div style="width: 350px; position: relative; float: left;">
david@8918
   249
          <div style="text-align: center;" class="LabelText Login_LabelText">Project hosted at:</div>
david@8918
   250
          <div style="text-align: center;"><a href="#" class="Login_Img_Link"><img class="Login_Logo_OBForge" src="../../../../../web/images/blank.gif" /></a></div>
david@8918
   251
        </div>
david@8918
   252
      </div>
asier@8910
   253
david@8918
   254
    </div>
asier@8910
   255
david@8918
   256
  </div>
asier@8910
   257
david@8918
   258
</body>
david@8918
   259
</html>