1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
<!DOCTYPE HTML>
<html>
<head>
<title>Radio Helsinki - Automation Import</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Importtool for Radio Helsinki">
<meta name="author" content="Christian Pointner <equinox@ffgraz.net>">
<link href="/javascript/twitter-bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/styles/signin.css" rel="stylesheet">
<style type="text/css">
body {
background-color: #eee;
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<link href="/javascript/twitter-bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<script src="/javascript/jquery/jquery.min.js"></script>
<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 = 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="#">×</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="#">×</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="#">×</a><h4 class="alert-heading">' + heading + '</h4>' + message + '</div>');
}
function authSuccess(data) {
if (data.status == 'OK') {
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);
sessionStorage.removeItem("username");
delete username;
sessionStorage.removeItem("token");
delete token;
}
}
function authError(req, status, error) {
message = req.status + ': ' + error;
if(req.status == 401) {
message = "Benutzer und/oder Passwort sind falsch!";
}
alertbox.error("Fehler beim Login", message);
}
function login()
{
$.ajax("/authtoken.json",
{ cache: false,
username: $("#username").val(),
password: $("#password").val(),
dataType: "json",
error: authError,
success: authSuccess
});
$("#password").val('');
}
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>
<body>
<div class="container">
<div id="loginbox">
<form id="loginform" class="form-signin" role="form">
<img src="/img/helsinki.png" />
<h1 class="form-signin-heading">Radio Helsinki - Import</h1>
<div id="alertbox"></div>
<input id="username" type="text" class="form-control" placeholder="Benutzername" required autofocus>
<input id="password" type="password" class="form-control" placeholder="Passwort" required>
<button class="btn btn-primary btn-large" type="submit"><i class="icon-user icon-white"></i> Einloggen</button>
</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) { login(); event.preventDefault(); });
if(token && username) {
$("#loginbox").hide();
} else {
$("#mainwindow").hide();
}
</script>
</body>
</html>
|