MAPG-235 timeLimit restored after reload of the page. Time limit selector usability improved
This commit is contained in:
parent
b78d564f6f
commit
aadeda05af
@ -93,6 +93,7 @@ div.mapItem>div.buttonContainer {
|
||||
#restrictions input[type=range] {
|
||||
height: 1.5em;
|
||||
margin-left: 2em;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
#timeLimitType {
|
||||
|
@ -65,6 +65,22 @@
|
||||
}
|
||||
};
|
||||
|
||||
var Util = {
|
||||
printTimeForHuman: function (time) {
|
||||
if (time < 60) {
|
||||
return '' + time + ' seconds';
|
||||
} else if (time == 60) {
|
||||
return '1 minute';
|
||||
} else if (time % 60 == 0) {
|
||||
return '' + Math.floor(time / 60) + ' minutes';
|
||||
} else if (time % 60 == 1) {
|
||||
return '' + Math.floor(time / 60) + ' minutes and 1 second';
|
||||
} else {
|
||||
return '' + Math.floor(time / 60) + ' minutes and ' + time % 60 + ' seconds';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Maps.addStaticMaps();
|
||||
|
||||
Maps.initializeDescriptionDivs();
|
||||
@ -119,7 +135,7 @@
|
||||
document.getElementById('playMode').style.visibility = 'hidden';
|
||||
|
||||
var timeLimit = document.getElementById('timeLimit').value;
|
||||
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + timeLimit + ' seconds per round';
|
||||
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + Util.printTimeForHuman(timeLimit);
|
||||
};
|
||||
}
|
||||
|
||||
@ -149,7 +165,7 @@
|
||||
|
||||
document.getElementById('timeLimit').oninput = function () {
|
||||
var timeLimit = document.getElementById('timeLimit').value;
|
||||
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + timeLimit + ' seconds per round';
|
||||
document.getElementById('timeLimitLabel').innerText = 'Time limit of ' + Util.printTimeForHuman(timeLimit);
|
||||
document.getElementById('timerEnabled').checked = true;
|
||||
}
|
||||
})();
|
||||
|
@ -239,6 +239,11 @@ class GameFlowController
|
||||
|
||||
$response = $this->prepareChallengeResponse($userId, $challenge, $currentRound, true);
|
||||
|
||||
if ($challenge->getTimeLimitType() === 'game' && $userInChallenge->getCurrentRound() > 0) {
|
||||
$timeLimit = max(10, $userInChallenge->getTimeLeft());
|
||||
$response['restrictions']['timeLimit'] = $timeLimit * 1000;
|
||||
}
|
||||
|
||||
return new JsonContent($response);
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ class UserInChallenge extends Model
|
||||
public function setTimeLeft(?int $timeLeft): void
|
||||
{
|
||||
if(isset($timeLeft)) {
|
||||
$this->timeLeft = $timeLeft;
|
||||
$this->timeLeft = max(0, $timeLeft);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ TODO: condition!
|
||||
<label id="timeLimitLabel" for="timerEnabled">Time limit measured in seconds</label>
|
||||
</div>
|
||||
<div>
|
||||
<input type="range" id="timeLimit" name="timeLimit" min="10" max="600" value="120" />
|
||||
<input type="range" id="timeLimit" name="timeLimit" min="10" max="1800" step="10" value="300" />
|
||||
</div>
|
||||
<div id="timeLimitType">
|
||||
Time limit
|
||||
|
Loading…
Reference in New Issue
Block a user