1jQuery(document).ready(function() { 2 function decodeHtml(value) { 3 const textarea = document.createElement('textarea'); 4 textarea.innerHTML = value; 5 return textarea.value; 6 } 7 8 function addJobFilter(table) { 9 const column = table.column(2); 10 const heading = $(column.header()).text().trim(); 11 if (heading !== 'Job') return; 12 if ($(table.table().container()).find('.job-filter').length) return; 13 const $select = $('<select class="job-filter"><option value="">All Jobs</option></select>'); 14 15 column 16 .data() 17 .unique() 18 .sort() 19 .each(function (value) { 20 if (value) { 21 const decodedValue = decodeHtml(value); 22 $select.append( 23 $('<option></option>') 24 .attr('value', decodedValue) 25 .text(decodedValue) 26 ); 27 } 28 }); 29 30 $select.on('change', function () { 31 const value = $.fn.dataTable.util.escapeRegex($(this).val()); 32 column 33 .search(value ? '^' + value + '$' : '', true, false) 34 .draw(); 35 }); 36 37 $(table.table().container()) 38 .find('.dataTables_filter') 39 .after( 40 $('<div class="job-filter-wrapper"><label>Job: </label></div>') 41 .append($select) 42 ); 43 } 44 45 // Catch future DataTable initialization. 46 $(document).on('init.dt', function (e, settings) { 47 addJobFilter(new $.fn.dataTable.Api(settings)); 48 }); 49 50 // Catch tables that were initialized before this script ran. 51 $(function () { 52 $('.dataTable').each(function () { 53 if ($.fn.dataTable.isDataTable(this)) { 54 addJobFilter($(this).DataTable()); 55 } 56 }); 57 }); 58});
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.