Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
CipMap
CipMap
Commits
89e22e7a
Commit
89e22e7a
authored
Dec 08, 2017
by
Stefan Kraus
Committed by
Tom Kunze
Jan 17, 2018
Browse files
server/script.js: only allow new requests after five minutes
parent
9cba3a4f
Changes
1
Hide whitespace changes
Inline
Side-by-side
django/server/static/server/js/script.js
View file @
89e22e7a
...
...
@@ -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
:
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment