/pedagogy/uv/create use quick notif

This commit is contained in:
tleb 2019-10-21 16:52:51 +02:00
parent 53a7633700
commit 6fce27113a
2 changed files with 12 additions and 5 deletions

View File

@ -40,6 +40,13 @@ $( function() {
})
});
function createQuickNotif(msg) {
const el = document.createElement('li')
el.textContent = msg
el.addEventListener('click', () => el.parentNode.removeChild(el))
document.getElementById('quick_notif').appendChild(el)
}
function display_notif() {
$('#header_notif').toggle().parent().toggleClass("white");
}

View File

@ -58,7 +58,7 @@
url: url,
success: function(data, _, xhr) {
if (xhr.status != 200) {
alert("{% trans %}Unknown UV code{% endtrans %}")
createQuickNotif("{% trans %}Unknown UV code{% endtrans %}")
return
}
for (let key in data) {
@ -73,10 +73,10 @@
}
}
alert('{% trans %}Successful autocomplete{% endtrans %}')
createQuickNotif('{% trans %}Successful autocomplete{% endtrans %}')
},
error: function(_, _, statusMessage) {
alert('{% trans %}An error occured: {% endtrans %}' + statusMessage)
createQuickNotif('{% trans %}An error occured: {% endtrans %}' + statusMessage)
},
})
})