Відмінності між версіями «Шаблони заяв та клопотань»
Перейти до навігації
Перейти до пошуку
Tviggy (обговорення | внесок) м Мітка: Скасовано |
Tviggy (обговорення | внесок) м Мітка: Ручний відкіт |
||
Рядок 4: | Рядок 4: | ||
</head> | </head> | ||
<body> | <body> | ||
<script> | |||
document.addEventListener('DOMContentLoaded', () => { | |||
const getSort = ({ target }) => { | |||
const order = (target.dataset.order = -(target.dataset.order || -1)); | |||
const index = [...target.parentNode.cells].indexOf(target); | |||
const collator = new Intl.Collator(['en', 'ru'], { numeric: true }); | |||
const comparator = (index, order) => (a, b) => order * collator.compare( | |||
a.children[index].innerHTML, | |||
b.children[index].innerHTML | |||
); | |||
for(const tBody of target.closest('table').tBodies) | |||
tBody.append(...[...tBody.rows].sort(comparator(index, order))); | |||
for(const cell of target.parentNode.cells) | |||
cell.classList.toggle('sorted', cell === target); | |||
}; | |||
document.querySelectorAll('.table_sort thead').forEach(tableTH => tableTH.addEventListener('click', () => getSort(event))); | |||
}); | |||
</script> | |||
<input type="text" id="name-search" onkeyup="nameSearch()" placeholder="Назва шаблону.." class="table-search-filters"> | <input type="text" id="name-search" onkeyup="nameSearch()" placeholder="Назва шаблону.." class="table-search-filters"> | ||
<input type="text" id="age-search" onkeyup="ageSearch()" placeholder="Інстанція.." class="table-search-filters"> | <input type="text" id="age-search" onkeyup="ageSearch()" placeholder="Інстанція.." class="table-search-filters"> |