1(function ($, app) { 2 // Custom Natural Sort Function 3 // see https://datatables.net/plug-ins/sorting/natural 4 function naturalSort (a, b, html) { 5 var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?%?$|^0x[0-9a-f]+$|[0-9]+)/gi, 6 sre = /(^[ ]*|[ ]*$)/g, 7 dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/, 8 hre = /^0x[0-9a-f]+$/i, 9 ore = /^0/, 10 htmre = /(<([^>]+)>)/ig, 11 // convert all to strings and trim() 12 x = a.toString().replace(sre, '') || '', 13 y = b.toString().replace(sre, '') || ''; 14 // remove html from strings if desired 15 if (!html) { 16 x = x.replace(htmre, ''); 17 y = y.replace(htmre, ''); 18 } 19 // chunk/tokenize 20 var xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), 21 yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'), 22 // numeric, hex or date detection 23 xD = parseInt(x.match(hre), 10) || (xN.length !== 1 && x.match(dre) && Date.parse(x)), 24 yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null; 25 26 // first try and sort Hex codes or Dates 27 if (yD) { 28 if ( xD < yD ) { 29 return -1; 30 } 31 else if ( xD > yD ) { 32 return 1; 33 } 34 } 35 36 // natural sorting through split numeric strings and default strings 37 for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) { 38 // find floats not starting with '0', string or 0 if not defined (Clint Priest) 39 40 /*supsystic*/ 41 //var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc], 10) || xN[cLoc] || 0; 42 //var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc], 10) || yN[cLoc] || 0; 43 var oFxNcL = parseFloat(xN[cLoc], 10) || xN[cLoc] || undefined; 44 var oFyNcL = parseFloat(yN[cLoc], 10) || yN[cLoc] || undefined; 45 /*****/ 46 47 // handle numeric vs string comparison - number < string - (Kyle Adams) 48 if (isNaN(oFxNcL) !== isNaN(oFyNcL)) { 49 return (isNaN(oFxNcL)) ? 1 : -1; 50 } 51 // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2' 52 else if (typeof oFxNcL !== typeof oFyNcL) { 53 oFxNcL += ''; 54 oFyNcL += ''; 55 } 56 if (oFxNcL < oFyNcL) { 57 return -1; 58 } 59 if (oFxNcL > oFyNcL) { 60 return 1; 61 } 62 } 63 return 0; 64 } 65 66 $.fn.dataTableExt.oApi.fnFakeRowspan = function (oSettings) { 67 if(oSettings) { 68 var cells; 69 $.each(oSettings.aoData, function(index, rowData) { 70 app.setCellAttributes(rowData.anCells); 71 }); 72 if (oSettings.aoHeader.length) { 73 cells = []; 74 $.each(oSettings.aoHeader, function(index, rowData) { 75 $.each(rowData, function(index, cellData) { 76 cells.push(cellData.cell); 77 }); 78 }); 79 app.setCellAttributes(cells); 80 } 81 if (oSettings.aoFooter.length) { 82 cells = []; 83 $.each(oSettings.aoFooter, function(index, rowData) { 84 $.each(rowData, function(index, cellData) { 85 cells.push(cellData.cell); 86 }); 87 }); 88 app.setCellAttributes(cells); 89 } 90 } 91 return this; 92 }; 93 $.fn.dataTableExt.oApi.fnResetFakeRowspan = function (oSettings) { 94 if(oSettings) { 95 var displayRows = oSettings.aiDisplay, 96 mergedData = $(oSettings.nTable).data('merged'); 97 if(!mergedData || mergedData.length == 0 || displayRows.length == 0) return this; 98 99 var rows = oSettings.aoData, 100 table = $(oSettings.nTable), 101 autoHiding = table.attr('data-auto-hiding'), 102 rowNums = {}, 103 first = table.attr('data-auto-index') == 'new' ? 1 : 0; 104 autoHiding = (typeof(autoHiding) != 'undefined' && autoHiding.length > 0) ? autoHiding.split(',').map(Number) : []; 105 106 $.each(displayRows, function(index, rowNum) { 107 var cells = rows[rowNum].anCells; 108 rowNums[cells[first].getAttribute('data-y')] = rowNum; 109 for(var i = 0; i < cells.length; i++) { 110 if(cells[i].getAttribute('data-hide') == "true" && (autoHiding.length <= i || autoHiding[i] == 1)) { 111 $(cells[i]).css('display', ''); 112 } 113 cells[i].setAttribute('rowspan', 1); 114 cells[i].setAttribute('colspan', 1); 115 } 116 }); 117 $.each(mergedData, function(index, value) { 118 var firstRow = Number(value.row) + 1, 119 lastRow = firstRow + Number(value.rowspan) - 1, 120 colspan = Number(value.colspan), 121 firstCol = Number(value.col) + first, 122 lastCol = firstCol + colspan - 1, 123 rowspan = 0; 124 for(var r = firstRow; r <= lastRow; r++) { 125 if(r in rowNums) { 126 if(rowspan == 0) { 127 firstRow = r; 128 } 129 for(var c = firstCol + (firstRow == r ? 1 : 0); c <= lastCol; c++) { 130 var cell = rows[rowNums[r]].anCells[c]; 131 cell.style.display = 'none'; 132 if(autoHiding[c] === 0) { 133 colspan--; 134 } 135 } 136 rowspan++; 137 } 138 } 139 if(rowspan > 0) { 140 var mergedCell = rows[rowNums[firstRow]].anCells[firstCol]; 141 if(rowspan > 1) { 142 mergedCell.setAttribute('rowspan', rowspan); 143 } 144 if(colspan > 1) { 145 mergedCell.setAttribute('colspan', colspan); 146 } 147 } 148 }); 149 } 150 return this; 151 }; 152 153 $.extend( $.fn.dataTableExt.oSort, { 154 "natural-asc": function ( a, b ) { 155 return naturalSort(a,b,true); 156 }, 157 "natural-desc": function ( a, b ) { 158 return naturalSort(a,b,true) * -1; 159 }, 160 "natural-nohtml-asc": function( a, b ) { 161 return naturalSort(a,b,false); 162 }, 163 "natural-nohtml-desc": function( a, b ) { 164 return naturalSort(a,b,false) * -1; 165 }, 166 "natural-ci-asc": function( a, b ) { 167 a = a.toString().toLowerCase(); 168 b = b.toString().toLowerCase(); 169 170 return naturalSort(a,b,true); 171 }, 172 "natural-ci-desc": function( a, b ) { 173 a = a.toString().toLowerCase(); 174 b = b.toString().toLowerCase(); 175 176 return naturalSort(a,b,true) * -1; 177 }, 178 "natural-nohtml-ci-asc": function( a, b ) { 179 a = a.toString().toLowerCase(); 180 b = b.toString().toLowerCase(); 181 182 return naturalSort(a,b,false); 183 }, 184 "natural-nohtml-ci-desc": function( a, b ) { 185 a = a.toString().toLowerCase(); 186 b = b.toString().toLowerCase(); 187 188 return naturalSort(a,b,false) * -1; 189 } 190 } ); 191 192}(window.jQuery, window.supsystic.Tables));
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.