]> err.no Git - scalable-opengroupware.org/blobdiff - UI/WebServerResources/SOGoRootPage.js
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1261 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / WebServerResources / SOGoRootPage.js
index dd93cb3b2e593f913ae87a244965dc8946fd77c3..6f4392d0a88ba5f45d72b8064b95bcceb879282d 100644 (file)
@@ -1,15 +1,41 @@
 function initLogin() {
+  var date = new Date();
+  date.setTime(date.getTime() - 86400000);
+  document.cookie = ("0xHIGHFLYxSOGo-0.9=discard; path=/"
+                    + "; expires=" + date.toGMTString());
   var submit = $("submit");
+  Event.observe(submit, "click", onLoginClick);
+
   var userName = $("userName");
   userName.focus();
-  Event.observe(submit, "click", onLoginClick);
+
+  var image = $("preparedAnimation");
+  image.parentNode.removeChild(image);
 }
 
 function onLoginClick(event) {
   startAnimation($("loginButton"), $("submit"));
 
-  var loginString = $("userName").value + ":" + $("password").value;
-  document.cookie = "0xHIGHFLYxSOGo-0.9 = basic" + loginString.base64encode();
+  var userName = $("userName").value;
+  var password = $("password").value;
+
+  if (userName.length > 0) {
+    var url = ($("connectForm").getAttribute("action")
+              + "?userName=" + userName
+              + "&password=" + password);
+    document.cookie = "";
+    triggerAjaxRequest(url, onLoginCallback);
+  }
+
+  preventDefault(event);
+}
+
+function onLoginCallback(http) {
+  if (http.readyState == 4) {
+    if (isHttpStatus204(http.status)) {
+      window.location.href = ApplicationBaseURL + $("userName").value;
+    }
+  }
 }
 
 addEvent(window, 'load', initLogin);