2020-10-18 05:03:26 +02:00
|
|
|
|
|
|
|
const getCellValue = (tr, idx) => tr.children[idx].innerText || tr.children[idx].textContent;
|
|
|
|
|
|
|
|
const comparer = (idx, asc) => (a, b) => ((v1, v2) =>
|
|
|
|
v1 !== '' && v2 !== '' && !isNaN(v1) && !isNaN(v2) ? v1 - v2 : v1.toString().localeCompare(v2)
|
|
|
|
)(getCellValue(asc ? a : b, idx), getCellValue(asc ? b : a, idx));
|
|
|
|
|
|
|
|
// Sort work
|
|
|
|
document.querySelectorAll('th').forEach(th => th.addEventListener('click', (() => {
|
|
|
|
const table = th.closest('table');
|
|
|
|
Array.from(table.querySelectorAll('tr:nth-child(n+2)'))
|
|
|
|
.sort(comparer(Array.from(th.parentNode.children).indexOf(th), this.asc = !this.asc))
|
|
|
|
.forEach(tr => table.appendChild(tr) );
|
|
|
|
})));
|
|
|
|
|
|
|
|
// Search
|
|
|
|
function recherche(select) {
|
|
|
|
// Declare variables
|
|
|
|
var input, filter, table, tr, td, i, txtValue;
|
|
|
|
input = document.getElementById(select);
|
|
|
|
filter = input.value.toUpperCase();
|
|
|
|
table = document.getElementById("soldes");
|
|
|
|
tr = table.getElementsByTagName("tr");
|
|
|
|
|
|
|
|
// Loop through all table rows, and hide those who don't match the search query
|
|
|
|
for (i = 0; i < tr.length; i++) {
|
|
|
|
if (select == "pseudo") { td = tr[i].getElementsByTagName("td")[2]; }
|
|
|
|
else if (select == "key") { td = tr[i].getElementsByTagName("td")[1]; }
|
|
|
|
|
|
|
|
if (td) {
|
|
|
|
txtValue = td.textContent || td.innerText;
|
|
|
|
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
|
|
|
tr[i].style.display = "";
|
|
|
|
} else {
|
|
|
|
tr[i].style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2020-10-18 06:02:13 +02:00
|
|
|
|
|
|
|
// Affichage des simples portefeuilles
|
|
|
|
|
|
|
|
var checkWallets = document.querySelector('input[value="splw"]');
|
|
|
|
|
|
|
|
checkWallets.onchange = function() {
|
|
|
|
var table, tr, td, i, txtValue;
|
|
|
|
table = document.getElementById("soldes");
|
|
|
|
tr = table.getElementsByTagName("tr");
|
|
|
|
|
|
|
|
if(checkWallets.checked) {
|
|
|
|
for (i = 0; i < tr.length; i++) {
|
|
|
|
td = tr[i].getElementsByTagName("td")[2];
|
|
|
|
if (td) {
|
|
|
|
txtValue = td.textContent || td.innerText;
|
|
|
|
if (txtValue == " ") {
|
|
|
|
tr[i].style.display = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < tr.length; i++) {
|
|
|
|
td = tr[i].getElementsByTagName("td")[2];
|
|
|
|
if (td) {
|
|
|
|
txtValue = td.textContent || td.innerText;
|
|
|
|
if (txtValue == " ") {
|
|
|
|
tr[i].style.display = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|