Commit 6fce2711 authored by tleb's avatar tleb

/pedagogy/uv/create use quick notif

parent 53a76337
Pipeline #2115 passed with stage
in 51 minutes and 23 seconds
...@@ -38,7 +38,14 @@ $( function() { ...@@ -38,7 +38,14 @@ $( function() {
$("#quick_notif li").click(function () { $("#quick_notif li").click(function () {
$(this).hide(); $(this).hide();
}) })
} ); });
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() { function display_notif() {
$('#header_notif').toggle().parent().toggleClass("white"); $('#header_notif').toggle().parent().toggleClass("white");
...@@ -52,4 +59,4 @@ function display_notif() { ...@@ -52,4 +59,4 @@ function display_notif() {
// https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true // https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true
function getCSRFToken() { function getCSRFToken() {
return $("[name=csrfmiddlewaretoken]").val(); return $("[name=csrfmiddlewaretoken]").val();
} }
\ No newline at end of file
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
url: url, url: url,
success: function(data, _, xhr) { success: function(data, _, xhr) {
if (xhr.status != 200) { if (xhr.status != 200) {
alert("{% trans %}Unknown UV code{% endtrans %}") createQuickNotif("{% trans %}Unknown UV code{% endtrans %}")
return return
} }
for (let key in data) { for (let key in data) {
...@@ -73,10 +73,10 @@ ...@@ -73,10 +73,10 @@
} }
} }
alert('{% trans %}Successful autocomplete{% endtrans %}') createQuickNotif('{% trans %}Successful autocomplete{% endtrans %}')
}, },
error: function(_, _, statusMessage) { error: function(_, _, statusMessage) {
alert('{% trans %}An error occured: {% endtrans %}' + statusMessage) createQuickNotif('{% trans %}An error occured: {% endtrans %}' + statusMessage)
}, },
}) })
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment