Log in/log out

main
Thomas Ba. 10 years ago
parent ff38490238
commit cdaee7d09e

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 691 B

@ -29,6 +29,18 @@
<div class="container">
<div class="row">
<div class="navigation col-md-3">
<h4>User</h4>
<p>
<img src="images/user.png" alt="user">
Current user: <span id="username">unknown!</span>
</p>
<p>
<a href="javascript:logout()">
<img src="images/log-out.png" alt="log out">
Log out
</a>
</p>
<h4>Calendar</h4>
<div class="list-group">
<a class="list-group-item" href="#" onclick="showCategory(0)">
<img src="images/view-calendar-list.png" alt=""> Show appointments
@ -41,7 +53,7 @@
<input type="checkbox" id="showPastAppointments" onclick="getListItems()">
Show appointments from the past
</label>
<h3>Categories:</h3>
<h4>Categories:</h4>
<div class="list-group" id="categoryList"></div>
<form method="get" action="javascript:createNewCategory()" id="createCategory">
<div class="input-group">

@ -1,8 +1,8 @@
var username = "root";
var username = "";
var appointments;
var categories;
var filter = 0;
var host = "://dhbw.t-battermann.de/calendar/rewrite.php";
var host = "//dhbw.t-battermann.de/calendar/redirect.php";
function getListItems() {
var request = new XMLHttpRequest();
@ -594,6 +594,44 @@ function deleteCategoryFromEventOnReadyStatusChangeEventHandler( request, eventI
}
}
}
function getCookie(name) {
var cname = name + "=";
var cookies = document.cookie.split(';');
for(var i=0;i<cookies.length; i++) {
var cookie = cookies[i];
while(cookie.charAt(0) == ' ')
cookie = cookie.substring(1);
if(cookie.indexOf(cname) == 0)
return cookie.substring(cname.length, cookie.length);
}
return "";
}
function setCookie(name, value) {
var d = new Date();
d.setTime( d.getTime() + 31536000000 );
document.cookie = name + "=" + value + "; expires=" + d.toUTCString();
}
function logout() {
var d = new Date();
d.setTime( d.getTime() - 86400000 );
document.cookie = "username=; expires=" + d.toUTCString();
location.reload();
}
function login() {
r = /[a-zA-Z0-9_ äöüÄÖÜß-]{1,10}/;
if (!r.exec(username) && !r.exec(getCookie("username")) ) {
do{
username = prompt("Please enter your username", "root");
}while(! r.exec(username) );
}else{
if( !r.exec(username) ){
username = getCookie("username");
}
}
setCookie("username", username);
document.getElementById("username").innerHTML = username;
}
login();
showCategory(0);
getCategories();

Loading…
Cancel
Save