3 ms·
Wish it was sortable by date
by droidist2 7y ago
Wish it was sortable by date
- bendiksolheim 7y agoThis is doable with some JavaScript. Paste the JavaScript from this gist [1] in your console while on the web page, and the table will be sorted descending by year. Swap `bValue - aValue` on line 4 with `aValue - bValue` to sort ascending. [1] - https://gist.github.com/bendiksolheim/307a6af9aba2c4360c75b900e484dd58 https://gist.github.com/bendiksolheim/307a6af9aba2c4360c75b9...
- fireattack 7y agoIt breaks/stops at rows with blank "appeared".
- tuespetre 7y agoFloop document.querySelector('tbody').append(...Array.from(document.querySelector('tbody').rows).map(row => ({ row, year: parseInt(row.cells[2].textContent) || 9000 })).sort((a, b) => a.year < b.year ? -1 : a.year > b.year ? 1 : 0).map(x => x.row))
- sim_card_map 7y agoAnd by users.
- ravenstine 7y agoClosest I could get: `Array.from(document.querySelectorAll('table tbody tr')).sort((a, b) => { const yearA = parseInt(a.querySelector('td:nth-child(3)').innerText) || 2019, yearB = parseInt(b.querySelector('td:nth-child(3)').innerText) || 2019; return yearB - yearA; }).forEach(tr => { tr.remove(); document.querySelector('table tbody').insertAdjacentElement('afterbegin', tr) });`
- stephen82 7y agoYeah, I find it quite difficult to navigate without sorting them in chronological order...
- codelani 7y agoJust added. Hope it doesn't break anything as that's the first Javascript I've added to an otherwise static site. Please let me know if that works!