mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 06:24:23 +01:00
enable max-attempts per challenge setting
This commit is contained in:
@@ -105,6 +105,12 @@ function submitkey(chal, key, nonce) {
|
||||
$('#submit-key').css('background-color', '#e18728')
|
||||
$('#submit-key').prop('disabled', true)
|
||||
}
|
||||
else if (data == 4){ // too many incorrect solves
|
||||
$('#submit-key').text('Too many attempts.')
|
||||
$('#submit-key').css('background-color', 'red')
|
||||
$('#submit-key').prop('disabled', true)
|
||||
}
|
||||
marktoomanyattempts()
|
||||
marksolves()
|
||||
updatesolves()
|
||||
setTimeout(function(){
|
||||
@@ -129,6 +135,20 @@ function marksolves() {
|
||||
});
|
||||
}
|
||||
|
||||
function marktoomanyattempts() {
|
||||
$.get('/maxattempts', function (data) {
|
||||
maxattempts = $.parseJSON(JSON.stringify(data));
|
||||
for (var i = maxattempts['maxattempts'].length - 1; i >= 0; i--) {
|
||||
id = maxattempts['maxattempts'][i].chalid
|
||||
$('#challenges button[value="' + id + '"]').addClass('secondary')
|
||||
$('#challenges button[value="' + id + '"]').css('background-color', '#FF9999')
|
||||
};
|
||||
if (window.location.hash.length > 0){
|
||||
loadchalbyname(window.location.hash.substring(1))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function updatesolves(){
|
||||
$.get('/chals/solves', function (data) {
|
||||
solves = $.parseJSON(JSON.stringify(data));
|
||||
@@ -177,6 +197,7 @@ function loadchals() {
|
||||
$('#' + challenges['game'][i].category.replace(/ /g,"-")).append($('<button value="' + challenges['game'][i].id + '">' + challenges['game'][i].value + '</button>'));
|
||||
};
|
||||
updatesolves()
|
||||
marktoomanyattempts()
|
||||
marksolves()
|
||||
|
||||
$('#challenges button').click(function (e) {
|
||||
|
||||
Reference in New Issue
Block a user