badping_nagios_better/public/assets/js/script.js
2019-11-12 01:45:36 +03:00

23 строки
671 B
JavaScript

let d = document;
let removeModel = (id, url) => {
let formData = new FormData();
formData.append("id", id || 0);
let xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.send(formData);
xhr.onload = () => location.reload();
};
let deleteEvent = (v, message, url) => {
v.addEventListener("click", e => {
if (confirm(message))
removeModel(e.target.dataset.id, url)
});
};
d.querySelectorAll('.js-group-btn-delete').forEach(v => {
deleteEvent(v, "You're sure to delete this group?", "/groups/delete")
});
d.querySelectorAll(".js-server-btn-delete").forEach(v => {
deleteEvent(v, "You're sure to delete this server?", "/servers/delete")
});