2007-09-04 17:00:44 +02:00
|
|
|
function initLogin() {
|
2007-09-07 00:18:08 +02:00
|
|
|
var date = new Date();
|
|
|
|
date.setTime(date.getTime() - 86400000);
|
|
|
|
document.cookie = ("0xHIGHFLYxSOGo-0.9=discard; path=/"
|
|
|
|
+ "; expires=" + date.toGMTString());
|
2007-09-04 17:00:44 +02:00
|
|
|
var submit = $("submit");
|
2007-09-07 00:18:08 +02:00
|
|
|
Event.observe(submit, "click", onLoginClick);
|
|
|
|
|
2007-09-04 17:00:44 +02:00
|
|
|
var userName = $("userName");
|
|
|
|
userName.focus();
|
2007-09-05 19:56:00 +02:00
|
|
|
|
|
|
|
var image = $("preparedAnimation");
|
|
|
|
image.parentNode.removeChild(image);
|
2007-09-04 17:00:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoginClick(event) {
|
|
|
|
startAnimation($("loginButton"), $("submit"));
|
|
|
|
|
2007-09-07 00:18:08 +02:00
|
|
|
var userName = $("userName").value;
|
|
|
|
var password = $("password").value;
|
|
|
|
|
|
|
|
if (userName.length > 0) {
|
2007-11-21 17:42:58 +01:00
|
|
|
var url = $("connectForm").getAttribute("action");
|
2008-03-26 21:49:30 +01:00
|
|
|
var parameters = ("userName=" + encodeURI(userName) + "&password=" + encodeURI(password));
|
2007-09-07 00:18:08 +02:00
|
|
|
document.cookie = "";
|
2007-11-21 17:42:58 +01:00
|
|
|
triggerAjaxRequest(url, onLoginCallback, null, parameters,
|
|
|
|
{ "Content-type": "application/x-www-form-urlencoded",
|
|
|
|
"Content-length": parameters.length,
|
|
|
|
"Connection": "close" });
|
2007-09-07 00:18:08 +02:00
|
|
|
}
|
|
|
|
|
2007-09-10 20:42:13 +02:00
|
|
|
preventDefault(event);
|
2007-09-07 00:18:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoginCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
2007-11-27 23:06:39 +01:00
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
var userName = $("userName").value;
|
|
|
|
var address = "" + window.location.href;
|
2008-03-26 21:49:30 +01:00
|
|
|
var baseAddress = ApplicationBaseURL + encodeURI(userName);
|
2007-11-27 23:06:39 +01:00
|
|
|
var altBaseAddress;
|
|
|
|
if (baseAddress[0] == "/") {
|
|
|
|
var parts = address.split("/");
|
|
|
|
var hostpart = parts[2];
|
|
|
|
var protocol = parts[0];
|
|
|
|
baseAddress = protocol + "//" + hostpart + baseAddress;
|
|
|
|
}
|
|
|
|
var altBaseAddress;
|
|
|
|
var parts = baseAddress.split("/");
|
|
|
|
parts.splice(3, 0);
|
|
|
|
altBaseAddress = parts.join("/");
|
|
|
|
|
|
|
|
var newAddress;
|
|
|
|
if ((address.startsWith(baseAddress)
|
|
|
|
|| address.startsWith(altBaseAddress))
|
|
|
|
&& !address.endsWith("/logoff"))
|
|
|
|
newAddress = address;
|
|
|
|
else
|
|
|
|
newAddress = baseAddress;
|
|
|
|
window.location.href = newAddress;
|
|
|
|
}
|
2007-09-07 00:18:08 +02:00
|
|
|
}
|
2007-09-04 17:00:44 +02:00
|
|
|
}
|
|
|
|
|
2007-11-15 20:02:23 +01:00
|
|
|
FastInit.addOnLoad(initLogin);
|