1(function($, window, document) { 2 3 jQuery.fn.dataTableExt.oSort['remove-special-chars-asc'] = function( a, b ) 4 { 5 var a = $(a).text().replace(/[^\w\s]/g, "").toLowerCase(); 6 var b = $(b).text().replace(/[^\w\s]/g, "").toLowerCase(); 7 return ((a < b) ? -1 : ((a > b) ? 1 : 0)); 8 } 9 10 jQuery.fn.dataTableExt.oSort['remove-special-chars-desc'] = function( a, b ) 11 { 12 var a = $(a).text().replace(/[^\w\s]/g, "").toLowerCase(); 13 var b = $(b).text().replace(/[^\w\s]/g, "").toLowerCase(); 14 return ((a < b) ? 1 : ((a > b) ? -1 : 0)); 15 } 16 17 /* 18 * hidden span data numeric sorting 19 * requires the td to contain span element with custom data tag containing the value to sort on 20 * see ajax_at_a_glance_exception_matrix.cfm as example 21 * [email protected] - 2014-02-25 22 */ 23 jQuery.fn.dataTableExt.oSort['span-data-numeric-asc'] = function ( a, b ) 24 { 25 var a = $(a).text(); 26 var b = $(b).text(); 27 a = parseFloat(a.match(/data="*(-?[0-9\.]+)/)[1]); 28 b = parseFloat(b.match(/data="*(-?[0-9\.]+)/)[1]); 29 return ((a < b) ? -1 : ((a > b) ? 1 : 0)); 30 }; 31 32 jQuery.fn.dataTableExt.oSort['span-data-numeric-desc'] = function ( a, b ) 33 { 34 var a = $(a).text(); 35 var b = $(b).text(); 36 a = parseFloat(a.match(/data="*(-?[0-9\.]+)/)[1]); 37 b = parseFloat(b.match(/data="*(-?[0-9\.]+)/)[1]); 38 return ((a < b) ? 1 : ((a > b) ? -1 : 0)); 39 }; 40 41 // these functions tell it to ignore commas and dollar signs when sorting numeric data ("numeric-comma" sType) 42 // because CF dollarFormat uses parens to indicate negative, check for those and convert to -X 43 jQuery.fn.dataTableExt.oSort['html-numeric-comma-asc'] = function(a,b) { 44 var x = $(a).text(); 45 var y = $(b).text(); 46 x = (x == "-") ? 0 : x.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 47 y = (y == "-") ? 0 : y.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 48 49 x = parseFloat( x ); 50 y = parseFloat( y ); 51 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 52 }; 53 54 jQuery.fn.dataTableExt.oSort['html-numeric-comma-desc'] = function(a,b) { 55 var x = $(a).text(); 56 var y = $(b).text(); 57 x = (x == "-") ? 0 : x.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 58 y = (y == "-") ? 0 : y.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 59 x = parseFloat( x ); 60 y = parseFloat( y ); 61 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 62 }; 63 64 jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) { 65 x = (a == "-") ? 0 : a.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 66 y = (b == "-") ? 0 : b.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 67 68 x = parseFloat( x ); 69 y = parseFloat( y ); 70 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 71 }; 72 73 jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) { 74 x = (a == "-") ? 0 : a.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 75 y = (b == "-") ? 0 : b.replace( /[,]/, "" ).replace( /[\$]/, "" ).replace(/[(]/,"-").replace(/[)]/, "" ); 76 x = parseFloat( x ); 77 y = parseFloat( y ); 78 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 79 }; 80 81 // Custom Sort for DateTime Columns (mm/dd/yyyy hh:ii am/pm) - [email protected] 82 jQuery.fn.dataTableExt.oSort['datetime-us-asc'] = function(a,b) { 83 var a = a.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4}) (\d{1,2}):(\d{1,2}) (am|pm|AM|PM|Am|Pm)/), 84 month = a[1], 85 day = a[2], 86 year = a[3], 87 hour = a[4], 88 min = a[5], 89 ap = a[6]; 90 91 if(hour == '12') hour = '0'; 92 if(ap == 'pm') hour = parseInt(hour, 10)+12; 93 94 if(year.length == 2){ 95 if(parseInt(year, 10)<70) year = '20'+year; 96 else year = '19'+year; 97 } 98 if(month.length == 1) month = '0'+month; 99 if(day.length == 1) day = '0'+day; 100 if(hour.length == 1) hour = '0'+hour; 101 if(min.length == 1) min = '0'+min; 102 103 var a = year+month+day+hour+min; 104 //-------------------------// 105 var b = b.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4}) (\d{1,2}):(\d{1,2}) (am|pm|AM|PM|Am|Pm)/),
106 month = b[1], 107 day = b[2], 108 year = b[3], 109 hour = b[4], 110 min = b[5], 111 ap = b[6]; 112 113 if(hour == '12') hour = '0'; 114 if(ap == 'pm') hour = parseInt(hour, 10)+12; 115 116 if(year.length == 2){ 117 if(parseInt(year, 10)<70) year = '20'+year; 118 else year = '19'+year; 119 } 120 if(month.length == 1) month = '0'+month; 121 if(day.length == 1) day = '0'+day; 122 if(hour.length == 1) hour = '0'+hour; 123 if(min.length == 1) min = '0'+min; 124 125 var b = year+month+day+hour+min; 126 return a-b; 127 }; 128 129 jQuery.fn.dataTableExt.oSort['datetime-us-desc'] = function(a,b) { 130 var a = a.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4}) (\d{1,2}):(\d{1,2}) (am|pm|AM|PM|Am|Pm)/), 131 month = a[1], 132 day = a[2], 133 year = a[3], 134 hour = a[4], 135 min = a[5], 136 ap = a[6]; 137 138 if(hour == '12') hour = '0'; 139 if(ap == 'pm') hour = parseInt(hour, 10)+12; 140 141 if(year.length == 2){ 142 if(parseInt(year, 10)<70) year = '20'+year; 143 else year = '19'+year; 144 } 145 if(month.length == 1) month = '0'+month; 146 if(day.length == 1) day = '0'+day; 147 if(hour.length == 1) hour = '0'+hour; 148 if(min.length == 1) min = '0'+min; 149 150 var a = year+month+day+hour+min; 151 //-------------------------// 152 var b = b.match(/(\d{1,2})\/(\d{1,2})\/(\d{2,4}) (\d{1,2}):(\d{1,2}) (am|pm|AM|PM|Am|Pm)/), 153 month = b[1], 154 day = b[2], 155 year = b[3], 156 hour = b[4], 157 min = b[5], 158 ap = b[6]; 159 160 if(hour == '12') hour = '0'; 161 if(ap == 'pm') hour = parseInt(hour, 10)+12; 162 163 if(year.length == 2){ 164 if(parseInt(year, 10)<70) year = '20'+year; 165 else year = '19'+year; 166 } 167 if(month.length == 1) month = '0'+month; 168 if(day.length == 1) day = '0'+day; 169 if(hour.length == 1) hour = '0'+hour; 170 if(min.length == 1) min = '0'+min; 171 172 var b = year+month+day+hour+min; 173 return b-a; 174 }; 175 176 if (navigator.userAgent.indexOf("Firefox")!=-1) { 177 // this spoofs the outerHTML element for Firefox 178 HTMLElement.prototype.__defineGetter__("outerHTML", function() { 179 var span = document.createElement("span"); span.appendChild(this.cloneNode(true)); 180 return span.innerHTML; 181 }); 182 183 HTMLElement.prototype.__defineSetter__("outerHTML", function(html) { 184 var range = document.createRange(); 185 this.innerHTML = html; 186 range.selectNodeContents(this); 187 var frag = range.extractContents(); 188 this.parentNode.insertBefore(frag, this); 189 this.parentNode.removeChild(this); 190 }); 191 } 192 193 jQuery.fn.dataTableExt.oApi.fnGetFilteredNodes = function ( oSettings ) 194 { 195 var anRows = []; 196 for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) 197 { 198 var nRow = oSettings.aoData[ oSettings.aiDisplay[i] ].nTr; 199 anRows.push( nRow ); 200 } 201 return anRows; 202 }; 203 204 205})(jQuery, window, document);
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.