script pour établir une bdd Ãà partir d'un tsv avec différent format - retour accueil
git clone git://bebou.netlib.re/laradb
Log | Files | Refs |
script.js (2206B)
1 2 const rows = document.querySelectorAll('table tr'); 3 4 rows.forEach(row => { 5 row.addEventListener('click', () => { 6 row.querySelectorAll('td.hidden').forEach(td => {td.classList.toggle('show')}) 7 }) 8 }); 9 10 // https://www.w3schools.com/howto/howto_js_sort_table.asp 11 function sortTable(n) { 12 n = n-1 13 var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; 14 table = document.querySelector("table"); 15 switching = true; 16 // Set the sorting direction to ascending: 17 dir = "asc"; 18 /* Make a loop that will continue until 19 no switching has been done: */ 20 while (switching) { 21 // Start by saying: no switching is done: 22 switching = false; 23 rows = table.rows; 24 /* Loop through all table rows (except the 25 first, which contains table headers): */ 26 for (i = 1; i < (rows.length - 1); i++) { 27 // Start by saying there should be no switching: 28 shouldSwitch = false; 29 /* Get the two elements you want to compare, 30 one from current row and one from the next: */ 31 x = rows[i].getElementsByTagName("TD")[n]; 32 y = rows[i + 1].getElementsByTagName("TD")[n]; 33 /* Check if the two rows should switch place, 34 based on the direction, asc or desc: */ 35 if (dir == "asc") { 36 if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { 37 // If so, mark as a switch and break the loop: 38 shouldSwitch = true; 39 break; 40 } 41 } else if (dir == "desc") { 42 if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { 43 // If so, mark as a switch and break the loop: 44 shouldSwitch = true; 45 break; 46 } 47 } 48 } 49 if (shouldSwitch) { 50 /* If a switch has been marked, make the switch 51 and mark that a switch has been done: */ 52 rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); 53 switching = true; 54 // Each time a switch is done, increase this count by 1: 55 switchcount ++; 56 } else { 57 /* If no switching has been done AND the direction is "asc", 58 set the direction to "desc" and run the while loop again. */ 59 if (switchcount == 0 && dir == "asc") { 60 dir = "desc"; 61 switching = true; 62 } 63 } 64 } 65 }