7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2012 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Login = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pUseLastLogin = 1; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
var login = {}; |
7604 |
25 Feb 19 |
nicklas |
31 |
|
7604 |
25 Feb 19 |
nicklas |
login.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
33 |
{ |
7604 |
25 Feb 19 |
nicklas |
// If there is no requested login form, we try to use the last one that was used |
7604 |
25 Feb 19 |
nicklas |
var requestedForm = Data.get(document.body, 'requested-form'); |
7604 |
25 Feb 19 |
nicklas |
if (!requestedForm) |
7604 |
25 Feb 19 |
nicklas |
37 |
{ |
7604 |
25 Feb 19 |
nicklas |
var lastLoginForm = login.getLastLoginForm(); |
7604 |
25 Feb 19 |
nicklas |
var selectedLoginForm = Data.get(document.body, 'login-form'); |
7604 |
25 Feb 19 |
nicklas |
if (lastLoginForm && selectedLoginForm && lastLoginForm != selectedLoginForm) |
7604 |
25 Feb 19 |
nicklas |
41 |
{ |
7604 |
25 Feb 19 |
nicklas |
login.switchLoginForm(lastLoginForm); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
44 |
} |
7604 |
25 Feb 19 |
nicklas |
45 |
} |
7604 |
25 Feb 19 |
nicklas |
46 |
|
7604 |
25 Feb 19 |
nicklas |
// Information links |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('aboutServer', login.showAbout); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('getAccount', login.showGetAccount); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('forgotPassword', login.showForgotPassword); |
7604 |
25 Feb 19 |
nicklas |
51 |
|
7604 |
25 Feb 19 |
nicklas |
// Login buttons |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter('login', login.setFocus); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnLogin', login.doLogin); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnLoginAnyway', login.enableLogin); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
57 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('loginForm', 'change', login.loginFormOnChange); |
7604 |
25 Feb 19 |
nicklas |
59 |
|
7604 |
25 Feb 19 |
nicklas |
var extraField = Doc.element('extraField'); |
7604 |
25 Feb 19 |
nicklas |
if (extraField == null) |
7604 |
25 Feb 19 |
nicklas |
62 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Password field should login if 'ENTER' is pressed |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter('password', login.doLogin); |
7604 |
25 Feb 19 |
nicklas |
65 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
67 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Password field should move focus to the 'extraField' if 'ENTER' is pressed |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter('password', login.setFocus); |
7604 |
25 Feb 19 |
nicklas |
Events.doOnEnter(extraField, login.doLogin); |
7604 |
25 Feb 19 |
nicklas |
71 |
} |
7604 |
25 Feb 19 |
nicklas |
72 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.show('the-login-form', 'table'); |
7604 |
25 Feb 19 |
nicklas |
login.initForm(); |
7604 |
25 Feb 19 |
nicklas |
75 |
|
7604 |
25 Feb 19 |
nicklas |
var footNoteFrame = App.topWindow().frames['footnote']; |
7604 |
25 Feb 19 |
nicklas |
if (footNoteFrame) |
7604 |
25 Feb 19 |
nicklas |
78 |
{ |
7604 |
25 Feb 19 |
nicklas |
setTimeout(login.reloadFootnote, 500); |
7604 |
25 Feb 19 |
nicklas |
80 |
} |
7604 |
25 Feb 19 |
nicklas |
81 |
} |
7604 |
25 Feb 19 |
nicklas |
82 |
|
7604 |
25 Feb 19 |
nicklas |
83 |
|
7604 |
25 Feb 19 |
nicklas |
login.loginFormOnChange = function(event) |
7604 |
25 Feb 19 |
nicklas |
85 |
{ |
7604 |
25 Feb 19 |
nicklas |
login.switchLoginForm(event.currentTarget.value); |
7604 |
25 Feb 19 |
nicklas |
87 |
} |
7604 |
25 Feb 19 |
nicklas |
88 |
|
7604 |
25 Feb 19 |
nicklas |
login.switchLoginForm = function(loginForm) |
7604 |
25 Feb 19 |
nicklas |
90 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
var url = location.pathname+'?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&loginForm='+encodeURIComponent(loginForm); |
7604 |
25 Feb 19 |
nicklas |
if (frm.again) url += '&again='+encodeURIComponent(frm.again.value); |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
96 |
} |
7604 |
25 Feb 19 |
nicklas |
97 |
|
7604 |
25 Feb 19 |
nicklas |
login.reloadFootnote = function() |
7604 |
25 Feb 19 |
nicklas |
99 |
{ |
7604 |
25 Feb 19 |
nicklas |
var footNoteFrame = App.topWindow().frames['footnote']; |
7604 |
25 Feb 19 |
nicklas |
footNoteFrame.location.reload(); |
7604 |
25 Feb 19 |
nicklas |
102 |
} |
7604 |
25 Feb 19 |
nicklas |
103 |
|
7604 |
25 Feb 19 |
nicklas |
104 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the login form by populating it with the last used login |
7604 |
25 Feb 19 |
nicklas |
and setting focus to either the login or password field. |
7604 |
25 Feb 19 |
nicklas |
107 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.initForm = function() |
7604 |
25 Feb 19 |
nicklas |
109 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
if (!frm.login) return; |
7604 |
25 Feb 19 |
nicklas |
pUseLastLogin = Data.int(frm.login, 'use-last-login', 1); |
7604 |
25 Feb 19 |
nicklas |
if (pUseLastLogin) |
7604 |
25 Feb 19 |
nicklas |
114 |
{ |
7604 |
25 Feb 19 |
nicklas |
var lastLogin = login.getLastLogin(); |
7604 |
25 Feb 19 |
nicklas |
if (!frm.login.value && lastLogin) |
7604 |
25 Feb 19 |
nicklas |
117 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.login.value = lastLogin; |
7604 |
25 Feb 19 |
nicklas |
119 |
} |
7604 |
25 Feb 19 |
nicklas |
120 |
} |
7604 |
25 Feb 19 |
nicklas |
login.setFocus(); |
7604 |
25 Feb 19 |
nicklas |
122 |
} |
7604 |
25 Feb 19 |
nicklas |
123 |
|
7604 |
25 Feb 19 |
nicklas |
124 |
|
7604 |
25 Feb 19 |
nicklas |
125 |
/* |
7604 |
25 Feb 19 |
nicklas |
Save the last login. If local storage is available we use that, |
7604 |
25 Feb 19 |
nicklas |
otherwise we simply save it on the top frameset. |
7604 |
25 Feb 19 |
nicklas |
128 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.saveLastLogin = function(lastLogin) |
7604 |
25 Feb 19 |
nicklas |
130 |
{ |
7604 |
25 Feb 19 |
nicklas |
var storage = App.localStorage(); |
7604 |
25 Feb 19 |
nicklas |
if (storage) |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
App.setLocal('last-login', lastLogin); |
7604 |
25 Feb 19 |
nicklas |
135 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
App.topWindow().lastLogin = lastLogin; |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
140 |
} |
7604 |
25 Feb 19 |
nicklas |
141 |
|
7604 |
25 Feb 19 |
nicklas |
142 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get the last used login. If local storage is available we |
7604 |
25 Feb 19 |
nicklas |
use that, otherwise we use the top frameset. |
7604 |
25 Feb 19 |
nicklas |
145 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.getLastLogin = function() |
7604 |
25 Feb 19 |
nicklas |
147 |
{ |
7604 |
25 Feb 19 |
nicklas |
var lastLogin; |
7604 |
25 Feb 19 |
nicklas |
var storage = App.localStorage(); |
7604 |
25 Feb 19 |
nicklas |
if (storage) |
7604 |
25 Feb 19 |
nicklas |
151 |
{ |
7604 |
25 Feb 19 |
nicklas |
lastLogin = App.getLocal('last-login'); |
7604 |
25 Feb 19 |
nicklas |
153 |
} |
7604 |
25 Feb 19 |
nicklas |
if (!lastLogin) |
7604 |
25 Feb 19 |
nicklas |
155 |
{ |
7604 |
25 Feb 19 |
nicklas |
lastLogin = App.topWindow().lastLogin; |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
return lastLogin; |
7604 |
25 Feb 19 |
nicklas |
159 |
} |
7604 |
25 Feb 19 |
nicklas |
160 |
|
7604 |
25 Feb 19 |
nicklas |
161 |
|
7604 |
25 Feb 19 |
nicklas |
162 |
/* |
7604 |
25 Feb 19 |
nicklas |
Save the last login form. If local storage is available we use that, |
7604 |
25 Feb 19 |
nicklas |
otherwise we simply save it on the top frameset. |
7604 |
25 Feb 19 |
nicklas |
165 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.saveLastLoginForm = function(lastLoginForm) |
7604 |
25 Feb 19 |
nicklas |
167 |
{ |
7604 |
25 Feb 19 |
nicklas |
var storage = App.localStorage(); |
7604 |
25 Feb 19 |
nicklas |
if (storage) |
7604 |
25 Feb 19 |
nicklas |
170 |
{ |
7604 |
25 Feb 19 |
nicklas |
App.setLocal('last-login-form', lastLoginForm); |
7604 |
25 Feb 19 |
nicklas |
172 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
174 |
{ |
7604 |
25 Feb 19 |
nicklas |
App.topWindow().lastLoginForm = lastLoginForm; |
7604 |
25 Feb 19 |
nicklas |
176 |
} |
7604 |
25 Feb 19 |
nicklas |
177 |
} |
7604 |
25 Feb 19 |
nicklas |
178 |
|
7604 |
25 Feb 19 |
nicklas |
179 |
/** |
7604 |
25 Feb 19 |
nicklas |
Get the last used login form. If local storage is available we |
7604 |
25 Feb 19 |
nicklas |
use that, otherwise we use the top frameset. |
7604 |
25 Feb 19 |
nicklas |
182 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.getLastLoginForm = function() |
7604 |
25 Feb 19 |
nicklas |
184 |
{ |
7604 |
25 Feb 19 |
nicklas |
var lastLoginForm; |
7604 |
25 Feb 19 |
nicklas |
var storage = App.localStorage(); |
7604 |
25 Feb 19 |
nicklas |
if (storage) |
7604 |
25 Feb 19 |
nicklas |
188 |
{ |
7604 |
25 Feb 19 |
nicklas |
lastLoginForm = App.getLocal('last-login-form'); |
7604 |
25 Feb 19 |
nicklas |
190 |
} |
7604 |
25 Feb 19 |
nicklas |
if (!lastLoginForm) |
7604 |
25 Feb 19 |
nicklas |
192 |
{ |
7604 |
25 Feb 19 |
nicklas |
lastLoginForm = App.topWindow().lastLoginForm; |
7604 |
25 Feb 19 |
nicklas |
194 |
} |
7604 |
25 Feb 19 |
nicklas |
return lastLoginForm; |
7604 |
25 Feb 19 |
nicklas |
196 |
} |
7604 |
25 Feb 19 |
nicklas |
197 |
|
7604 |
25 Feb 19 |
nicklas |
198 |
|
7604 |
25 Feb 19 |
nicklas |
199 |
/** |
7604 |
25 Feb 19 |
nicklas |
Set focus on the login field if empty, otherwise the password field |
7604 |
25 Feb 19 |
nicklas |
or the extraField |
7604 |
25 Feb 19 |
nicklas |
202 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.setFocus = function() |
7604 |
25 Feb 19 |
nicklas |
204 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
var fieldToFocus = null; |
7604 |
25 Feb 19 |
nicklas |
if (!frm.login.value) |
7604 |
25 Feb 19 |
nicklas |
208 |
{ |
7604 |
25 Feb 19 |
nicklas |
fieldToFocus = frm.login; |
7604 |
25 Feb 19 |
nicklas |
210 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (frm.password.value && frm.extraField) |
7604 |
25 Feb 19 |
nicklas |
212 |
{ |
7604 |
25 Feb 19 |
nicklas |
fieldToFocus = frm.extraField; |
7604 |
25 Feb 19 |
nicklas |
214 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
216 |
{ |
7604 |
25 Feb 19 |
nicklas |
fieldToFocus = frm.password; |
7604 |
25 Feb 19 |
nicklas |
218 |
} |
7604 |
25 Feb 19 |
nicklas |
fieldToFocus.focus(); |
7604 |
25 Feb 19 |
nicklas |
fieldToFocus.select(); |
7604 |
25 Feb 19 |
nicklas |
221 |
} |
7604 |
25 Feb 19 |
nicklas |
222 |
|
7604 |
25 Feb 19 |
nicklas |
223 |
/** |
7604 |
25 Feb 19 |
nicklas |
Enable the (disabled) login form. |
7604 |
25 Feb 19 |
nicklas |
225 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.enableLogin = function() |
7604 |
25 Feb 19 |
nicklas |
227 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
frm.login.disabled = false; |
7604 |
25 Feb 19 |
nicklas |
frm.password.disabled = false; |
7604 |
25 Feb 19 |
nicklas |
if (frm.extraField) frm.extraField.disabled = false; |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('btnLoginAnyway'); |
7604 |
25 Feb 19 |
nicklas |
Doc.removeClass('btnLogin', 'disabled'); |
7604 |
25 Feb 19 |
nicklas |
login.setFocus(); |
7604 |
25 Feb 19 |
nicklas |
235 |
} |
7604 |
25 Feb 19 |
nicklas |
236 |
|
7604 |
25 Feb 19 |
nicklas |
237 |
/** |
7604 |
25 Feb 19 |
nicklas |
Send the login form. |
7604 |
25 Feb 19 |
nicklas |
239 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.doLogin = function(event) |
7604 |
25 Feb 19 |
nicklas |
241 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
// Check if login has been disabled |
7604 |
25 Feb 19 |
nicklas |
if (frm.login && frm.login.disabled) return; |
7604 |
25 Feb 19 |
nicklas |
245 |
|
7604 |
25 Feb 19 |
nicklas |
// Disable start page extension if special key is used |
7604 |
25 Feb 19 |
nicklas |
var specialKey = event.altKey || event.ctrlKey || event.shiftKey; |
7604 |
25 Feb 19 |
nicklas |
248 |
|
7604 |
25 Feb 19 |
nicklas |
// Check if the login is not recommended |
7604 |
25 Feb 19 |
nicklas |
var denyLogin = Doc.element('denyLogin'); |
7604 |
25 Feb 19 |
nicklas |
if (denyLogin) |
7604 |
25 Feb 19 |
nicklas |
252 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!confirm('Login has been disabled by an administrator. Do you want to continue anyway?')) |
7604 |
25 Feb 19 |
nicklas |
254 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
256 |
} |
7604 |
25 Feb 19 |
nicklas |
257 |
} |
7604 |
25 Feb 19 |
nicklas |
258 |
|
7604 |
25 Feb 19 |
nicklas |
// On the impersonate form, check that a user has been selected |
7604 |
25 Feb 19 |
nicklas |
if (frm.user_id && !frm.user_id.value) |
7604 |
25 Feb 19 |
nicklas |
261 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('user_id.select', 'Please select a user'); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
264 |
} |
7604 |
25 Feb 19 |
nicklas |
265 |
|
7604 |
25 Feb 19 |
nicklas |
// Store the last login |
7604 |
25 Feb 19 |
nicklas |
if (pUseLastLogin && frm.login) |
7604 |
25 Feb 19 |
nicklas |
268 |
{ |
7604 |
25 Feb 19 |
nicklas |
Login.saveLastLogin(frm.login.value); |
7604 |
25 Feb 19 |
nicklas |
270 |
} |
7604 |
25 Feb 19 |
nicklas |
if (frm.loginForm) |
7604 |
25 Feb 19 |
nicklas |
272 |
{ |
7604 |
25 Feb 19 |
nicklas |
Login.saveLastLoginForm(frm.loginForm.value); |
7604 |
25 Feb 19 |
nicklas |
274 |
} |
7604 |
25 Feb 19 |
nicklas |
275 |
|
7604 |
25 Feb 19 |
nicklas |
// Check 'remain on page' and 'redirect' options |
7604 |
25 Feb 19 |
nicklas |
if (frm.remainOnPage && frm.redirect) |
7604 |
25 Feb 19 |
nicklas |
278 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (frm.remainOnPage.checked) |
7604 |
25 Feb 19 |
nicklas |
280 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.redirect.value = window.opener ? window.opener.location.href : ''; |
7604 |
25 Feb 19 |
nicklas |
282 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
284 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.useAutoStartPage.value = '1'; |
7604 |
25 Feb 19 |
nicklas |
frm.redirect.value = App.getRoot()+'my_base/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
287 |
} |
7604 |
25 Feb 19 |
nicklas |
288 |
} |
7604 |
25 Feb 19 |
nicklas |
289 |
|
7604 |
25 Feb 19 |
nicklas |
if (specialKey && frm.useAutoStartPage) frm.useAutoStartPage.value = '0'; |
7604 |
25 Feb 19 |
nicklas |
291 |
|
7604 |
25 Feb 19 |
nicklas |
if (frm.target) Dialogs.openPopup('', frm.target, 300, 200); |
7604 |
25 Feb 19 |
nicklas |
// Set the deviceToken if we have it in local storage |
7604 |
25 Feb 19 |
nicklas |
if (frm.deviceToken) |
7604 |
25 Feb 19 |
nicklas |
295 |
{ |
7604 |
25 Feb 19 |
nicklas |
var deviceToken = App.getLocal('deviceToken'); |
7815 |
05 Jun 20 |
nicklas |
if (deviceToken) |
7815 |
05 Jun 20 |
nicklas |
298 |
{ |
7815 |
05 Jun 20 |
nicklas |
frm.deviceToken.value = deviceToken; |
7815 |
05 Jun 20 |
nicklas |
300 |
} |
7815 |
05 Jun 20 |
nicklas |
else |
7815 |
05 Jun 20 |
nicklas |
302 |
{ |
7815 |
05 Jun 20 |
nicklas |
// Otherwise we save the auto-generated value |
7815 |
05 Jun 20 |
nicklas |
App.setLocal('deviceToken', frm.deviceToken.value); |
7815 |
05 Jun 20 |
nicklas |
305 |
} |
7604 |
25 Feb 19 |
nicklas |
306 |
} |
8045 |
03 Jun 22 |
nicklas |
307 |
|
8045 |
03 Jun 22 |
nicklas |
// Send custom event to let extensions do stuff before submitting |
8045 |
03 Jun 22 |
nicklas |
Doc.hide('login-error'); |
8045 |
03 Jun 22 |
nicklas |
var evt = new CustomEvent('before-login', { cancelable: true, bubbles: true }); |
8045 |
03 Jun 22 |
nicklas |
if (frm.dispatchEvent(evt)) |
8045 |
03 Jun 22 |
nicklas |
312 |
{ |
8045 |
03 Jun 22 |
nicklas |
login.submitLoginForm(); |
8045 |
03 Jun 22 |
nicklas |
314 |
} |
8045 |
03 Jun 22 |
nicklas |
315 |
} |
8045 |
03 Jun 22 |
nicklas |
316 |
|
8045 |
03 Jun 22 |
nicklas |
317 |
/** |
8045 |
03 Jun 22 |
nicklas |
Submit the login form with no questions asked. |
8045 |
03 Jun 22 |
nicklas |
319 |
*/ |
8045 |
03 Jun 22 |
nicklas |
login.submitLoginForm = function() |
8045 |
03 Jun 22 |
nicklas |
321 |
{ |
8045 |
03 Jun 22 |
nicklas |
var frm = document.forms['login']; |
7604 |
25 Feb 19 |
nicklas |
if (!pUseLastLogin) |
7604 |
25 Feb 19 |
nicklas |
324 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Duplicate in hidden form |
7604 |
25 Feb 19 |
nicklas |
var frm2 = Forms.cloneAsHidden(frm); |
7604 |
25 Feb 19 |
nicklas |
document.body.appendChild(frm2); |
7604 |
25 Feb 19 |
nicklas |
frm2.submit(); |
7604 |
25 Feb 19 |
nicklas |
document.body.removeChild(frm2); |
7604 |
25 Feb 19 |
nicklas |
330 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
332 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
334 |
} |
7604 |
25 Feb 19 |
nicklas |
335 |
} |
7604 |
25 Feb 19 |
nicklas |
336 |
|
7604 |
25 Feb 19 |
nicklas |
337 |
/** |
7604 |
25 Feb 19 |
nicklas |
Show popup dialog with information about this server. |
7604 |
25 Feb 19 |
nicklas |
339 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.showAbout = function() |
7604 |
25 Feb 19 |
nicklas |
341 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot()+'info/about.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&page=about'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'About', 600, 400); |
7604 |
25 Feb 19 |
nicklas |
345 |
} |
7604 |
25 Feb 19 |
nicklas |
346 |
|
7604 |
25 Feb 19 |
nicklas |
347 |
/** |
7604 |
25 Feb 19 |
nicklas |
Show popup dialog with information about how to get an account on this server. |
7604 |
25 Feb 19 |
nicklas |
349 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.showGetAccount = function() |
7604 |
25 Feb 19 |
nicklas |
351 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot()+'info/get_account.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'GetAccount', 450, 300); |
7604 |
25 Feb 19 |
nicklas |
354 |
} |
7604 |
25 Feb 19 |
nicklas |
355 |
|
7604 |
25 Feb 19 |
nicklas |
356 |
/** |
7604 |
25 Feb 19 |
nicklas |
Show popup dialog with information about what to do if a password has been lost. |
7604 |
25 Feb 19 |
nicklas |
358 |
*/ |
7604 |
25 Feb 19 |
nicklas |
login.showForgotPassword = function() |
7604 |
25 Feb 19 |
nicklas |
360 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = App.getRoot()+'info/forgot_password.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'ForgotPassword', 450, 300); |
7604 |
25 Feb 19 |
nicklas |
363 |
} |
7604 |
25 Feb 19 |
nicklas |
364 |
|
7604 |
25 Feb 19 |
nicklas |
return login; |
7604 |
25 Feb 19 |
nicklas |
366 |
}(); |
7604 |
25 Feb 19 |
nicklas |
367 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Login.initPage); |
7604 |
25 Feb 19 |
nicklas |
369 |
|