Code clean up: redundant semicolons

Made variable declaration style in for loops consistent
This commit is contained in:
2022-08-17 16:34:59 +01:00
parent 02290e968c
commit b15f76701e
5 changed files with 458 additions and 453 deletions

View File

@ -1,21 +1,21 @@
$(document).ready(function() {
$("#od-font-test").click(function(){
$("body").css("font-family", "opendyslexic3regular")
});
})
$('.test-code-input').keyup(function() {
var input = $(this).val().split("-").join("").split("—").join("");
var input = $(this).val().split("-").join("").split("—").join("")
if (input.length > 0) {
input = input.match(new RegExp('.{1,4}', 'g')).join("—");
input = input.match(new RegExp('.{1,4}', 'g')).join("—")
}
$(this).val(input);
});
});
$(this).val(input)
})
})
$('form[name=form-quiz-start]').submit(function(event) {
var $form = $(this);
var data = $form.serialize();
var $form = $(this)
var data = $form.serialize()
$.ajax({
url: window.location.pathname,
@ -24,21 +24,21 @@ $('form[name=form-quiz-start]').submit(function(event) {
dataType: 'json',
success: function(response) {
var id = response.id
window.localStorage.setItem('id', id);
window.location.href = `/quiz/`;
window.localStorage.setItem('id', id)
window.location.href = `/quiz/`
},
error: function(response) {
error_response(response);
error_response(response)
}
});
})
event.preventDefault();
});
event.preventDefault()
})
function error_response(response) {
const $alert = $("#alert-box");
$alert.html('');
const $alert = $("#alert-box")
$alert.html('')
if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
$alert.html(`
@ -47,18 +47,18 @@ function error_response(response) {
${response.responseJSON.error}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`);
`)
} else if (response.responseJSON.error instanceof Array) {
var output = ''
for (var i = 0; i < response.responseJSON.error.length; i ++) {
for (let i = 0; i < response.responseJSON.error.length; i ++) {
output += `
<div class="alert alert-danger alert-dismissible fade show" role="alert">
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
${response.responseJSON.error[i]}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
`;
$alert.html(output);
`
$alert.html(output)
}
}
}
@ -74,13 +74,13 @@ $('#dismiss-cookie-alert').click(function(event){
},
dataType: 'json',
success: function(response){
console.log(response);
console.log(response)
},
error: function(response){
console.log(response);
console.log(response)
}
})
event.preventDefault();
event.preventDefault()
})