2021-11-24 17:17:56 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
$("#od-font-test").click(function(){
|
|
|
|
$("body").css("font-family", "opendyslexic3regular")
|
|
|
|
});
|
|
|
|
|
2021-11-25 23:12:20 +00:00
|
|
|
$('.test-code-input').keyup(function() {
|
2021-11-24 17:17:56 +00:00
|
|
|
var input = $(this).val().split("-").join("").split("—").join(""); // remove hyphens and mdashes
|
|
|
|
if (input.length > 0) {
|
|
|
|
input = input.match(new RegExp('.{1,4}', 'g')).join("—");
|
|
|
|
}
|
|
|
|
$(this).val(input);
|
|
|
|
});
|
2021-11-25 23:12:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$('form[name=form-quiz-start]').submit(function(event) {
|
|
|
|
|
|
|
|
var $form = $(this);
|
|
|
|
var alert = document.getElementById('alert-box');
|
|
|
|
var data = $form.serialize();
|
|
|
|
|
|
|
|
alert.innerHTML = ''
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: window.location.pathname,
|
|
|
|
type: 'POST',
|
|
|
|
data: data,
|
|
|
|
dataType: 'json',
|
|
|
|
success: function(response) {
|
|
|
|
window.location.href = "/admin/login/";
|
|
|
|
},
|
|
|
|
error: function(response) {
|
|
|
|
if (typeof response.responseJSON.error === 'string' || response.responseJSON.error instanceof String) {
|
|
|
|
alert.innerHTML = alert.innerHTML + `
|
|
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
|
|
<i class="bi bi-exclamation-triangle-fill" title="Danger"></i>
|
|
|
|
${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) {
|
|
|
|
for (var i = 0; i < response.responseJSON.error.length; i ++) {
|
|
|
|
alert.innerHTML = alert.innerHTML + `
|
|
|
|
<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>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
event.preventDefault();
|
2021-11-24 17:17:56 +00:00
|
|
|
});
|