Commit 8939c7f2 authored by Mat's avatar Mat

plus besoin

parent 261c9892
// 1
// Modale de confirmation avant effacement
let modal_boutons = document.querySelectorAll("table.table a.btn-modal:not(.disabled)");
for (let bouton of modal_boutons)
{
let gid = bouton.getAttribute('id');
if (gid !== null) {
bouton.addEventListener("click", function() {
id = gid.replace("dup-", "");
$('#dupmodal-' + id ).modal({
focus: true
});
id = gid.replace("del-", "");
$('#delmodal-' + id ).modal({
focus: true
});
});
}
}
// 2
// Tri par colonnes
function ASC (a, b) {
a = a[1]; b = b[1];
if (a > b) { return 1; }
else if (a < b) { return -1; }
else { return 0; }
}
function DESC (a, b) {
a = a[1]; b = b[1];
if (a > b) { return -1; }
else if (a < b) { return 1; }
else { return 0; }
}
function sortTable(table, col, tri)
{
let tbody = document.getElementById(table).getElementsByTagName('tbody')[0];
let rows = tbody.getElementsByTagName('tr');
let resort = new Array();
for (let row of rows)
{
let sortcol = row.getElementsByTagName('td')[col].innerHTML;
resort.push([row, sortcol]);
}
if (tri === 'ASC') { resort.sort(ASC); }
if (tri === 'DESC') { resort.sort(DESC); }
for (var i = 0; i < resort.length; i++) {
tbody.appendChild(resort[i][0]);
}
}
let buttons = document.querySelectorAll('a.btn-tri');
for (let btn of buttons)
{
btn.addEventListener("click", function()
{
let col = btn.getAttribute('id').replace("btncol","").split("_")[0];
let tri = btn.getAttribute('id').replace("btncol","").split("_")[1].toUpperCase();
sortTable('maintab', col, tri);
});
}
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