Commit 89e22e7a authored by Stefan Kraus's avatar Stefan Kraus Committed by Tom Kunze
Browse files

server/script.js: only allow new requests after five minutes

parent 9cba3a4f
......@@ -120,6 +120,22 @@ function toggleLectureMode() {
populateMap();
}
//Set timecookie from lastRequest
function setLastTutorRequestTime(){
var requestWaitTime = 0 * 60 * 1000; // Wait 5 minutes before a tutor can be requested again.
var date = new Date();
date.setTime(date.getTime() + requestWaitTime);
// Safe time and not date directly, otherwise he saves a string (?) representing this date...
$.cookie('lastTutorRequest', date.getTime());
}
function waitedEnoughTime(){
var lastReq = $.cookie('lastTutorRequest');
return lastReq === undefined || lastReq < (new Date());
}
//sends a request for a tutor and draws tutordata afterwards
function requestTutor(){
if (!isHostInRoom(getHostname(), currentRoom())) {
......@@ -127,6 +143,12 @@ function requestTutor(){
return;
}
if(!waitedEnoughTime()){
displayErrorPopup("Du hast erst vor kurzem nach einem Tutor gefragt");
return;
}
// FIXME
var lecture = $("#lectureSelector").val();
if (lecture === undefined) {
return;
......@@ -153,6 +175,8 @@ function cancelTutorRequest(){
return;
}
setLastTutorRequestTime();
$.ajax(server+"/request", {
type: "DELETE",
data: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment