summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
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>