summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2014-09-18 12:38:58 (GMT)
committerChristian Pointner <equinox@helsinki.at>2014-09-18 12:38:58 (GMT)
commitca2d4d904b615e21dd2e197d2f9b583f9db4e8ae (patch)
tree3be14bd812ce7a6fe21ac631783bdaf6775c0c3c /index.html
parentfe521de6aa34bf2976a8bcf2f7c4ff664059f448 (diff)
login and logout work now
Diffstat (limited to 'index.html')
-rw-r--r--index.html61
1 files changed, 42 insertions, 19 deletions
diff --git a/index.html b/index.html
index f48bd37..e89b88e 100644
--- a/index.html
+++ b/index.html
@@ -25,20 +25,35 @@
<script src="/javascript/twitter-bootstrap/js/bootstrap.min.js"></script>
<script src="/javascript/twitter-bootstrap/js/bootstrap-alert.min.js"></script>
<script type="text/javascript">
- var username;
- var token;
- var logged_in = false;
+ var username = sessionStorage.getItem("username");
+ var token = sessionStorage.getItem("token");
+ alertbox = function() {}
+ alertbox.warning = function (heading, message) {
+ $('#alertbox').html('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+ }
+ alertbox.error = function (heading, message) {
+ $('#alertbox').html('<div class="alert alert-error"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+ }
+ alertbox.info = function (heading, message) {
+ $('#alertbox').html('<div class="alert alert-info"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+ }
function authSuccess(data) {
if (data.status == 'OK') {
- logged_in = true;
username = data.username;
+ sessionStorage.setItem("username", username);
token = data.token;
+ sessionStorage.setItem("token", token);
+
$('#loginbox').hide('slide');
+ $("#mainwindow").show();
} else {
alertbox.error("Fehler beim Login", data.errorstring);
- logged_in = false;
+ sessionStorage.removeItem("username");
+ delete username;
+ sessionStorage.removeItem("token");
+ delete token;
}
}
@@ -50,7 +65,7 @@
alertbox.error("Fehler beim Login", message);
}
- function auth()
+ function login()
{
$.ajax("/authtoken.json",
{ cache: false,
@@ -60,17 +75,21 @@
error: authError,
success: authSuccess
});
+ $("#password").val('');
}
- alertbox = function() {}
- alertbox.warning = function (heading, message) {
- $('#alertbox').html('<div class="alert"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
- }
- alertbox.error = function (heading, message) {
- $('#alertbox').html('<div class="alert alert-error"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
- }
- alertbox.info = function (heading, message) {
- $('#alertbox').html('<div class="alert alert-info"><a class="close" data-dismiss="alert" href="#">&times;</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
+ function logout()
+ {
+ sessionStorage.removeItem("username");
+ delete username;
+ sessionStorage.removeItem("token");
+ delete token;
+
+ $(".alert").alert('close');
+ $("#username").val('');
+ $("#password").val('');
+ $("#mainwindow").hide();
+ $('#loginbox').show('slide');
}
</script>
</head>
@@ -89,14 +108,18 @@
</form>
</div>
-
-
+ <div id="mainwindow">
+ <h1>Test</h1>
+ <button type="button" class="btn btn-primary btn-large" onclick="logout()"><i class="icon-off icon-white"></i>Ausloggen</button>
+ <div>
</div>
<script type="text/javascript">
- $("#loginform").submit(function(event) { auth(); event.preventDefault(); });
- if(logged_in == true) {
+ $("#loginform").submit(function(event) { login(); event.preventDefault(); });
+ if(token && username) {
$("#loginbox").hide();
+ } else {
+ $("#mainwindow").hide();
}
</script>