1$(document).ready(function () { 2 const table = $('.tx-institutsseminarverwaltung #no-more-tables #event-table') 3 $('#event-table tbody tr').addClass('filtered'); 4 // Title filter 5 const titleDropdown = $('#ext-seminar-titles .dropdown-list') 6 addOptions($('[itemprop="topic"] [itemprop="name"]'), titleDropdown) 7 addFilter(titleDropdown, table, 'tableDataCategory') 8 9 // Speaker filter 10 const speakerDropdown = $('#ext-seminar-speaker .dropdown-list') 11 addFilter(speakerDropdown, table, 'tableDataSpeaker') 12 13 // Location filter 14 const locationDropdown = $('#ext-seminar-location .dropdown-list') 15 addOptions($('[itemprop="location"] [itemprop="name"]'), locationDropdown) 16 addFilter(locationDropdown, table, 'tableDataLocation') 17 18 // Language filter 19 const languageDropdown = $('#event-table-language .dropdown-list') 20 addOptions($('[itemprop="inLanguage"]'), languageDropdown) 21 addFilter(languageDropdown, table, 'tableDataLanguage') 22 23 // Date sort 24 sort(table, 0, function (current, next) { 25 current = convertToTime($(current.cells[0]).text().trim()) 26 next = convertToTime($(next.cells[0]).text().trim()) 27 if (current > next) 28 return 1 29 if (current < next) 30 return -1 31 return 0 32 }, false) 33 34 // Title sort 35 sort(table, 1, function (current, next) { 36 current = $(current.cells[1]).text().trim() 37 next = $(next.cells[1]).text().trim() 38 if (current > next) 39 return 1 40 if (current < next) 41 return -1 42 return 0 43 }) 44 45 // Topic sort 46 sort(table, 2, function (current, next) { 47 current = $(current.cells[2]).text().trim() 48 next = $(next.cells[2]).text().trim() 49 if (current > next) 50 return 1 51 if (current < next) 52 return -1 53 return 0 54 }) 55 56 initPagination(); 57}) 58 59let addFilter = function (selector, table, cell) { 60 selector.children().click(function (option) { 61 const selected = $(option.target).data('value') 62 const rows = table.find('> tbody > tr') 63 64 resetOtherSelect(selector) 65 $(option.target).addClass('selected') 66 67 if (selector.parent().find('.dropdown-select').length) { 68 selector.parent().find('.dropdown-select').text($(option.target).text()) 69 } 70 71 rows.each(function (i, row) { 72 const values = Array.from(row.cells).filter(el => el.hasAttribute(cell)).at(0).innerText.trim(); 73 74 if (selected === 'all' || values.includes(selected)) { 75 $(row).addClass('filtered'); 76 } else { 77 $(row).removeClass('filtered'); 78 } 79 $(row).hide(); 80 }); 81 updatePagination(); 82 }); 83} 84 85let sort = function (table, cell, comparer, asc) { 86 asc = asc || true; 87 table.find('> thead > tr > th').eq(cell).click(function (event) { 88 asc = !asc 89 rotateIcon($(event.target)) 90 let rows = table.find('tbody > tr').toArray().sort(comparer) 91 if (asc) { 92 rows = rows.reverse() 93 } 94 rows.map(function (e) { 95 table.append(e) 96 }) 97 updatePagination(); 98 }) 99} 100 101let addOptions = function (selector, element) { 102 let set = new Set() 103 selector.map(function (i, option) { 104 set.add($(option).text().trim()) 105 }) 106 set = Array.from(set).sort() 107 set.forEach(function (option) { 108 element.append("<p data-value=\"".concat(option, "\">").concat(option, "</p>")) 109 }) 110} 111 112let convertToTime = function (string) { 113 string = string.replace(/\s/g, '').replace(/-.{5}/g, '') 114 return new Date(string.replace(/(\d{2})\.(\d{2})\.(\d{4})/, '$3-$2-$1')) 115} 116 117let rotateIcon = function (element) { 118 const hasRotation = element.hasClass('rotate') 119 $('.rotate').removeClass('rotate') 120 if (!hasRotation) { 121 element.addClass('rotate') 122 } 123} 124 125/** 126 * 127 * check ustid 128 * 129 * if ustid is required add * behind the placeholder 130 * and set ustid field to required 131 * 132 */ 133 134 135let resetOtherSelect = function (element) { 136 $('.tx-institutsseminarverwaltung').find('.dropdown-list .selected').removeClass('selected') 137 $(document).find('.dropdown-list [data-value="all"]').not(element.children()).addClass('selected') 138} 139 140function initPagination() { 141 const table = $('#event-table'); 142 let rowsPerPage = parseInt($('#rowsPerPageSelect').val(), 10); 143 let currentPage = 1; 144 145 function getFilteredRows() { 146 return table.find('tbody > tr.filtered').toArray(); 147 } 148 149 function renderTablePage(page) { 150 const filteredRows = getFilteredRows(); 151 152 $(filteredRows).show(); 153 154 const start = (page - 1) * rowsPerPage; 155 const end = start + rowsPerPage; 156 157 $(filteredRows).slice(0, start).hide(); 158 $(filteredRows).slice(end).hide(); 159 160 currentPage = page; 161 renderPagination(filteredRows.length); 162 } 163 164 function renderPagination(totalVisible) { 165 const container = $('#pagination-container').empty();
166 const pageCount = Math.ceil(totalVisible / rowsPerPage); 167 if (pageCount <= 1) return; 168 169 for (let i = 1; i <= pageCount; i++) { 170 const btn = $('<button type="button" class="page-btn">').text(i); 171 if (i === currentPage) btn.addClass('active'); 172 btn.on('click', () => renderTablePage(i)); 173 container.append(btn); 174 } 175 } 176 177 $('#rowsPerPageSelect').on('change', function () { 178 rowsPerPage = parseInt($(this).val(), 10); 179 renderTablePage(1); 180 }); 181 182 window.updatePagination = function () { 183 renderTablePage(1); 184 }; 185 186 renderTablePage(1); 187}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.