1 2function datatableHeaderChange() { 3 (function($) { 4 $('table.dataTable th.search input.live-search').each(function() { 5 if ($(this).val() == '') { 6 $(this).addClass('placeholder'); 7 } else { 8 $(this).removeClass('placeholder'); 9 } 10 }); 11 })(jQuery); 12} 13 14function convertToSlug(str) { 15 return str 16 .toLowerCase() 17 .replace(/[^\w ]+/g,'') 18 .replace(/ +/g,'-') 19 ; 20} 21function getParameterByName(name) { 22 name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); 23 var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), 24 results = regex.exec(decodeURIComponent(location.search)); 25 return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); 26} 27 28(function($) { 29$(document).ready(function() { 30 31 // $('#myTable').DataTable( { 32 // responsive: { 33 // details: { 34 // display: $.fn.dataTable.Responsive.display.childRowImmediate 35 // } 36 // } 37// } ); 38 // DATATABLE 39 $('.datatable').each(function() { 40 41 var currDataTable = $(this); 42 43 // Setup - add a text input to each header cell 44 /* 45 $(this).find('thead th.search').each( function () { 46 var title = $(this).text(); 47 var normalizedTitle = convertToSlug(title); 48 49 var parameterVal = ''; 50 if (getParameterByName(normalizedTitle)) { 51 var parameterVal = getParameterByName(normalizedTitle); 52 } 53 54 // console.log(normalizedTitle); 55 // console.log(parameterVal); 56 57 var searchElem = '<input type="text" rel="'+normalizedTitle+'" onchange="datatableHeaderChange()" value="'+parameterVal+'" class="form-control live-search" placeholder="'+title+'" />'; 58 if ($(this).attr('rel')) { 59 // console.log($(this).html()); 60 // rel="'+$(this).attr('id')+'" 61 // è una select! 62 var selectOpts = '<option value="">'+title+'</option>'; 63 $.each($(this).attr('rel').split('|'), function(index, value) { 64 var selectedVal = ''; 65 selectOpts += '<option value="'+value+'" '; 66 if (parameterVal == value) { 67 selectOpts += 'selected="selected"'; 68 } 69 selectOpts += '>'+value+'</option>'; 70 71 }); 72 73 searchElem = '<select class="form-control live-search" rel="'+normalizedTitle+'" onchange="datatableHeaderChange()">'+selectOpts+'</select>'; 74 } 75 76 $(this).html(searchElem); 77 }); 78 */ 79 80 var dataOptions = { 81 'ordering' : true, 82 'paging' : true, 83 'pageLength': 10, 84 'info': false, 85 'sDom': 'lrtip', 86 'bLengthChange': false, 87 88 columnDefs: [ 89 { 90 searchPanes:{ 91 show: false, 92 }, 93 targets: 'no-search', 94 }, 95 { 96 searchPanes:{ 97 threshold: 1, 98 cascadePanes: true, 99 orderable: false, 100 searching:false, 101 hideCount:true, 102 controls: false, 103 dtOpts:{ 104 select:{ 105 style: 'multi' 106 } 107 } 108 }, 109 targets: 'search', 110 }, 111 // { targets: 'no-sort', orderable: false }, 112 // { 113 // targets: 'search', 114 // searchPanes:{ 115 // show: true, 116 // orderable: false, 117 // searching:false, 118 // hideCount:true, 119 // controls: false 120 // }, 121 // }, 122 // { 123 // dtOpts:{ 124 // searching:false, 125 // info: false, 126 // }, 127 // targets: 128 // } 129 ], 130 responsive: false, 131 // responsive: { 132 // details: { 133 // display: $.fn.dataTable.Responsive.display.childRowImmediate 134 // } 135 // } 136 // columnDefs: [ 137 // { responsivePriority: 1, targets: 0 }, 138 // { responsivePriority: 2, targets: -1 } 139 // ] 140 141 drawCallback: function(settings) { 142 var pagination = $(this).closest('.dataTables_wrapper').find('.dataTables_paginate'); 143 pagination.toggle(this.api().page.info().pages > 1); 144 145 // .find('.dtsp-searchPane').each(function() { 146 // }) 147 } 148 }; 149 // console.log(dataOptions); 150 151 if ($(this).find('th.search').length) { 152 // abilito i searchpanes 153 dataOptions.searchPanes = true; 154 dataOptions.dom = 'Pfrtip'; 155 } 156 157 // searchPanes:true, 158 // dom: 'Pfrtip',
159 var extraClasses = ''; 160 if ($(this).hasClass('show-all')) { 161 dataOptions.paging = false; 162 extraClasses += ' show-all'; 163 } 164 if ($(this).hasClass('no-sort')) { 165 dataOptions.ordering = false; 166 extraClasses += ' no-sort'; 167 } 168 if ($(this).hasClass('no-search')) { 169 dataOptions.searching = false; 170 extraClasses += ' no-search'; 171 } 172 173 if ($(this).hasClass('colvis')) { // column visibility 174 dataOptions.dom = 'Bfrtip'; 175 dataOptions.buttons = [ 176 'colvis' 177 ]; 178 extraClasses += ' colvis'; 179 } 180 if (extraClasses != '') { 181 dataOptions.initComplete = function(settings, json) { 182 $(currDataTable).parents('.dataTables_wrapper').addClass(extraClasses); 183 } 184 } 185 var currTable = $(this).DataTable(dataOptions); 186 187 188 // Apply the search 189 /* 190 currTable.columns().every( function () { 191 var that = this; 192 193 $( 'input', this.header() ).on( 'keyup change', function () { 194 if ( that.search() !== this.value ) { 195 that 196 .search( this.value ) 197 .draw(); 198 } 199 }); 200 201 $( 'select', this.header() ).on( 'change', function () { 202 if ( that.search() !== $(this).val() ) { 203 that 204 .search( $(this).val() ) 205 .draw(); 206 } 207 }); 208 209 } ); 210 211 // triggero la ricerca per applicare eventuali prefiltri 212 $(currDataTable).find('th.search input, th.search select').change(); 213 */ 214 }); 215 216}) 217 218})(jQuery);
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.