-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
149 lines (140 loc) · 5.2 KB
/
index.html
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<title>DeTunnelMe</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<style type="text/css">
.vertical-center {
min-height: 100%;
min-height: 100vh;
display: flex;
align-items: center;
margin-bottom: 0px;
}
button {
margin: 5pt;
}
</style>
<script type="text/javascript">
function refreshContent(){
$.ajax({
url: "/getContent",
type: "get",
data: {},
success: function(response) {
//console.log(response);
if(typeof response === 'undefined' || response.length===0)
window.location.replace("/login");
$(".panel-body").html(response);
registerHandlers();
},
error: function(xhr) {
console.error(xhr);
window.location.replace("/login");
}
});
}
function registerHandlers(){
$(".wake").click(function(event){
$('<div id="dialog">'+"Wollen Sie das Aufweck-Signal wirklich senden?"+'</div>').appendTo('body');
$( "#dialog" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
"Aufwecken": function() {
$.ajax({
url: "/wakeUp",
type: "post",
data: {
user: event.target.id
},
success: function(response) {
console.log("OK");
refreshContent();
},
error: function(xhr) {
console.error(xhr);
refreshContent();
}
});
$( this ).dialog( "close" );
},
Abbrechen: function() {
$( this ).dialog( "close" );
}
},
close: function(event, ui) {
$("#dialog").remove();
}
});
});
$(".lock").click(function(event){
$('<div id="dialog">'+"Wollen Sie sich wirklich für 30 Minuten sperren?"+'</div>').appendTo('body');
$( "#dialog" ).dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
"Sperren": function() {
$.ajax({
url: "/lock",
type: "post",
data: {
user: event.target.id,
time: 30
},
success: function(response) {
console.log("OK");
refreshContent();
},
error: function(xhr) {
console.error(xhr);
refreshContent();
}
});
$( this ).dialog( "close" );
},
Abbrechen: function() {
$( this ).dialog( "close" );
}
},
close: function(event, ui) {
$("#dialog").remove();
}
});
});
$(".logout").click(function(event){
window.location.replace("/logout");
});
}
$(document).ready(function() {
registerHandlers();
setInterval(function(){
refreshContent();
}, 5000);
});
</script>
</head>
<body>
<div class="jumbotron vertical-center">
<div class="container">
<div class="panel panel-default">
<div class="panel-heading"><h3>DeTunnelMe</h3></div>
<div class="panel-body">
{{content}}
</div>
</div>
</div>
</div>
</body>
</html>