mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 03:49:24 +00:00
Autofull UV small changes
This commit is contained in:
@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
{% if field.name == 'code' %}
|
||||
<a href="javascript:void(0)" id="autofill">Fill</a>
|
||||
<button type="button" id="autofill">{% trans %}Import from UTBM{% endtrans %}</button>
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
@ -48,13 +48,13 @@
|
||||
autofillBtn.addEventListener('click', () => {
|
||||
const today = new Date()
|
||||
let year = today.getFullYear()
|
||||
if (today.getMonth() < 7) { // student year, starts in september
|
||||
if (today.getMonth() < 7) { // student year starts in september
|
||||
year--
|
||||
}
|
||||
const url = "{{ url('api:uv_endpoint') }}?year=" + year + "&code=" + codeInput.value
|
||||
$.getJSON(url, function(data, _, xhr) {
|
||||
if (xhr.status != 200) {
|
||||
alert('{% trans %}Unknown UV code{% endtrans %}')
|
||||
alert("{% trans %}Unknown UV code{% endtrans %}")
|
||||
return
|
||||
}
|
||||
for (let key in data) {
|
||||
@ -68,9 +68,10 @@
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
alert('{% trans %}Successful autocomplete{% endtrans %}')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
Reference in New Issue
Block a user