https://nwkfhs.org.uk/components/com_tabulizer/assets/js/datatables/jtquery.dataTables.extensions.js
1/** 2 * ========================================================================= 3 * Plugins and other extensions 4 * ========================================================================= 5 */ 6 7jtQuery.fn.dataTableExt.oApi.fnGetFilteredNodes = function ( oSettings ) 8{ 9 var anRows = []; 10 for ( var i=0, iLen=oSettings.aiDisplay.length ; i<iLen ; i++ ) 11 { 12 var nRow = oSettings.aoData[ oSettings.aiDisplay[i] ].nTr; 13 anRows.push( nRow ); 14 } 15 return anRows; 16}; 17 18/** 19 * ========================================================================= 20 * Bug fixes 21 * ========================================================================= 22 */ 23 24function datatablesFixVerticalHeaderAlignment(e){var t=jtQuery("#"+e).closest(".dataTables_scroll");if(t){var n=t.find(".dataTables_scrollHead");var r=t.find(".dataTables_scrollHeadInner");var i=t.find(".dataTables_scrollBody");var s=t.find(".dataTables_scrollHeadInner > table.dataTable");var o=t.find(".dataTables_scrollBody > table.dataTable");var u=i.innerWidth()+"px";var a=jtQuery("<div />");i.append(a);u=a.width();a.remove();s.css("width",u);o.css("width",u);r.css("width",u);s.css("table-layout","fixed");o.css("table-layout","fixed");var f=[];o.find("tr").each(function(){var e=jtQuery(this);e.find("td").each(function(e){td_width=getComputedStyle(this,null).width;if(!f[e])f[e]=td_width;else if(f[e]<td_width)f[e]=td_width})});o.find("tr").each(function(){var e=jtQuery(this);e.find("td").each(function(e){if(f[e])jtQuery(this).css("width",f[e]+"px")})});s.find("tr").each(function(){var e=jtQuery(this);e.find("td").each(function(e){if(f[e])jtQuery(this).css("width",f[e]+"px")})})}} 25function datatablesFixVerticalScroll(a){var l=jtQuery("#"+a).closest(".dataTables_scroll");if(l){var s=l.find(".dataTables_scrollHead"),t=l.find(".dataTables_scrollBody"),e=t.hasClass("sync_bound");s&&t&&(e||(t.on("scroll",function(){s.scrollLeft(jtQuery(this).scrollLeft())}),t.addClass("sync_bound"))),setInterval(function(){datatablesFixVerticalHeaderAlignment(a)},650)}} 26 27/** 28 * ========================================================================= 29 * Search/filter Highlight code 30 * ========================================================================= 31 */ 32 33function searchHTML(searchString, htmlString) { 34 var expr = new RegExp(searchString, "gi"); 35 var container = jtQuery("<div>").html(htmlString); 36 var elements = container.find("*").andSelf(); 37 var textNodes = elements.contents().not(elements); 38 textNodes.each(function() { 39 var matches = this.nodeValue.match(expr); 40 if (matches) { 41 var parts = this.nodeValue.split(expr); 42 for (var n = 0; n < parts.length; n++) { 43 if (n) { 44 jtQuery('<span class="search_highlight">').text(matches[n - 1]).insertBefore(this); 45 } 46 if (parts[n]) { 47 jtQuery(document.createTextNode(parts[n])).insertBefore(this); 48 } 49 } 50 jtQuery(this).remove(); 51 } 52 }); 53 return container.html(); 54} 55 56/** 57 * ========================================================================= 58 * DataTypes 59 * ========================================================================= 60 */ 61 62if(typeof cleanHTMLTags !== 'function') { 63 function cleanHTMLTags(html) { 64 if (html == '') return html; 65 html = html.replace(/<(?:.|\n)*?>/gm, ''); 66 return html; 67 } 68} 69 70if(typeof cleanAndTrim !== 'function') { 71 function cleanAndTrim(str) { 72 str_text = jtQuery("<div/>").html(str).text(); 73 str_text = str_text.replace(/[ ]/gm, "").trim(); 74 return str_text; 75 } 76} 77 78 79/** 80 * Text with acutes or other string that need localized comparisons 81 */ 82 83/* 84jtQuery.fn.dataTableExt.aTypes.unshift( 85 function ( sData ) 86 { 87 return 'local-str'; 88 } 89); 90*/ 91 92jtQuery.fn.dataTableExt.oSort['local-str-asc'] = function(a,b) { 93 a = cleanAndTrim(a); 94 b = cleanAndTrim(b); 95 return a.localeCompare(b); 96}; 97 98jtQuery.fn.dataTableExt.oSort['local-str-desc'] = function(a,b) { 99 a = cleanAndTrim(a); 100 b = cleanAndTrim(b); 101 return b.localeCompare(a); 102}; 103 104/** 105 * String Dates 106 * Sort properly dates similar to Monday, 15th of April 107 */ 108 109function isDateSystem(str) { 110 if (str == '') return true; 111 var d = Date.parse(str); 112 if (isNaN(d) == false) return true; 113 else return false; 114} 115 116function parseDateSystem(str) { 117 str = cleanHTMLTags(str); 118 str = str.replace(/[ ]/gmi, ""); 119 var d = Date.parse(str); 120 if (isNaN(d) == false) return 0; 121 else return d; 122} 123 124function isDDMMYY(str) { 125 if (str == '') return true; 126 var r = /^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.]\d{2}$/; 127 return r.test(str); 128} 129 130function parseDDMMYY(str) { 131 if (str == '') return 0; 132 var m = str.match(/^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.](\d{2})$/); 133 if (m) { 134 var day = parseInt(m[1]);
135 var month = parseInt(m[2])-1; 136 var year = parseInt(m[3]); 137 year = (year>30)?parseInt("19"+ m[3]):parseInt("20"+ m[3]); 138 return new Date(year, month, day).getTime();; 139 } else return 0; 140} 141 142function isMMDDYY(str) { 143 if (str == '') return true; 144 var r = /^(0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])[\/\-\.]\d{2}$/; 145 return r.test(str); 146} 147 148function parseMMDDYY(str) { 149 if (str == '') return 0; 150 var m = str.match(/^(0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])[\/\-\.](\d{2})$/); 151 if (m) { 152 var day = parseInt(m[2]); 153 var month = parseInt(m[1])-1; 154 var year = parseInt(m[3]); 155 year = (year>30)?parseInt("19"+ m[3]):parseInt("20"+ m[3]); 156 return new Date(year, month, day).getTime(); 157 } else return 0; 158} 159 160function isMMDDYYYY(str) { 161 if (str == '') return true; 162 var r = /^(0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])[\/\-\.]\d{4}$/; 163 return r.test(str); 164} 165 166function parseMMDDYYYY(str) { 167 if (str == '') return 0; 168 var m = str.match(/^(0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])[\/\-\.](\d{4})$/); 169 if (m) { 170 var day = parseInt(m[2]); 171 var month = parseInt(m[1])-1; 172 var year = parseInt(m[3]); 173 return new Date(year, month, day).getTime(); 174 } else return 0; 175} 176 177function isDDMMYYYY(str) { 178 if (str == '') return true; 179 var r = /^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.]\d{4}$/; 180 return r.test(str); 181} 182function parseDDMMYYYY(str) { 183 if (str == '') return 0; 184 var m = str.match(/^(0?[1-9]|[12][0-9]|3[01])[\/\-\.](0?[1-9]|1[012])[\/\-\.](\d{4})$/); 185 if (m) { 186 var day = parseInt(m[1]); 187 var month = parseInt(m[2])-1; 188 var year = parseInt(m[3]); 189 190 return new Date(year, month, day).getTime(); 191 } else return 0; 192} 193 194jtQuery.fn.dataTableExt.oSort['date-str-asc'] = function(a,b) { 195 var x = parseDateStrType(a, 'asc'), y = parseDateStrType(b, 'asc'); 196 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 197}; 198 199jtQuery.fn.dataTableExt.oSort['date-str-desc'] = function(a,b) { 200 var x = parseDateStrType(a, 'desc'), y = parseDateStrType(b, 'desc'); 201 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 202}; 203 204function isDateStrType(str) { 205 return isDateSystem(str); 206} 207 208function parseDateStrType(str) { 209 str = cleanAndTrim(str); 210 return parseDateSystem(str); 211} 212 213/* 214jtQuery.fn.dataTableExt.aTypes.unshift( 215 function ( sData ) { 216 sData = cleanAndTrim(sData); 217 if (sData == "") return 'date-str'; 218 if (isDateStrType(sData)) return 'date-str'; 219 else return null; 220 } 221); 222 */ 223 224/** 225 * Forced Comma Formatted Number 226 */ 227 228function getForcedCommaFormattedNumber (str) { 229 var r = /^[+-]?\d+(\.\d{3})*\,?\d*$/; 230 if (r.test(str)) { 231 x = str.replace( /\./g, "" ); 232 x = x.replace( /,/, "." ); 233 x = parseFloat( x ); 234 } else { 235 x = parseFloat ( str); 236 } 237 return x; 238} 239 240function parseForcedCommaFormattedNumber(a, sorting_order) { 241 var empty_value = (sorting_order == 'asc') ? Number.MAX_VALUE : -Number.MAX_VALUE; 242 a = jtQuery("<div/>").html(a).text(); 243 a = cleanHTMLTags(a); 244 a = a.replace(/[^0-9.,\-\+]/g, ""); 245 if (( a == "-" ) || (a == "+") || (a == "")) a = empty_value; 246 else a = getForcedCommaFormattedNumber(a); 247 return a; 248} 249 250jtQuery.fn.dataTableExt.oSort['forced-numeric-comma-asc'] = function(a,b) { 251 var x = parseForcedCommaFormattedNumber(a, 'asc'), y = parseForcedCommaFormattedNumber(b, 'asc'); 252 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 253}; 254 255jtQuery.fn.dataTableExt.oSort['forced-numeric-comma-desc'] = function(a,b) { 256 var x = parseForcedCommaFormattedNumber(a, 'desc'), y = parseForcedCommaFormattedNumber(b, 'desc'); 257 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 258}; 259 260/** 261 * Forced Period Formatted Number 262 */ 263 264function getForcedPeriodFormattedNumber (str) { 265 var r = /^[+-]?\d+(,\d{3})*\.?\d*$/; 266 if (r.test(str)) { 267 x = str.replace( /,/g, "" ); 268 x = parseFloat( x ); 269 } else { 270 x = parseFloat ( str); 271 } 272 return x; 273} 274 275function parseForcedPeriodFormattedNumber(a, sorting_order) { 276 var empty_value = (sorting_order == 'asc') ? Number.MAX_VALUE : -Number.MAX_VALUE; 277 a = jtQuery("<div/>").html(a).text(); 278 a = cleanHTMLTags(a); 279 a = a.replace(/[^0-9.,\-\+]/g, "");
280 if (( a == "-" ) || (a == "+") || (a == "")) a = empty_value; 281 else a = getForcedPeriodFormattedNumber(a); 282 return a; 283} 284 285jtQuery.fn.dataTableExt.oSort['forced-numeric-period-asc'] = function(a,b) { 286 var x = parseForcedPeriodFormattedNumber(a, 'asc'), y = parseForcedPeriodFormattedNumber(b, 'asc'); 287 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 288}; 289 290jtQuery.fn.dataTableExt.oSort['forced-numeric-period-desc'] = function(a,b) { 291 var x = parseForcedPeriodFormattedNumber(a, 'desc'), y = parseForcedPeriodFormattedNumber(b, 'desc'); 292 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 293}; 294 295/** 296 * Comma Separated Numbers 297 * Sort properly numbers with commas that may be enclosed in HTML tags, e.g. 1,000 1,100,090 1,234.56 <strong>1000</strong>, $100, 5% 3.2% 298 */ 299 300if(typeof overwriteCommaFormattedNumberWithCustom !== 'boolean') { 301 302 function isCommaFormattedNumber (str) { 303 var r1 = /^[+-]?\d+(,\d{3})*\.?\d*$/; 304 var r2 = /^[+-]?\d+(\.\d{3})*\,?\d*$/; 305 var r3 = /^[+-]?\d+(,\d+)$/; 306 if (r1.test(str)) { regex_id = 1; return true; } 307 else if (r2.test(str)) { regex_id = 2; return true; } 308 else if (r3.test(str)) { regex_id = 3; return true; } 309 else { regex_id = 0; return false; } 310 } 311 312 function getCommaFormattedNumber (str) { 313 var r1 = /^[+-]?\d+(,\d{3})*\.?\d*$/; 314 var r2 = /^[+-]?\d+(\.\d{3})*\,?\d*$/; 315 var r3 = /^[+-]?\d+(,\d+)$/; 316 var regex_id = 0; 317 if (r1.test(str)) { regex_id = 1; } 318 else if (r2.test(str)) { regex_id = 2; } 319 else if (r3.test(str)) { regex_id = 3; } 320 else { regex_id = 0; return str; } 321 322 var x = null; 323 switch (regex_id) { 324 case 1: x = str.replace( /,/g, "" ); 325 break; 326 case 2: x = str.replace( /\./g, "" ); 327 x = x.replace( /,/, "." ); 328 break; 329 case 3: x = str.replace( /,/, "." ); 330 break; 331 default: 332 // we should never reach this line! 333 return str; 334 } 335 x = parseFloat( x ); 336 return x; 337 } 338 339 function parseCommaFormattedNumber(a, sorting_order) { 340 var empty_value = (sorting_order == 'asc') ? Number.MAX_VALUE : -Number.MAX_VALUE; 341 a = jtQuery("<div/>").html(a).text(); 342 a = cleanHTMLTags(a); 343 a = a.replace(/[\s| ]/gmi, "").replace(/[\+|%|\$|\£|\â¬]/gm,""); 344 if (( a == "-" ) || (a == "+") || (a == "")) a = empty_value; 345 else a = getCommaFormattedNumber(a); 346 return a; 347 } 348 349 jtQuery.fn.dataTableExt.aTypes.unshift( 350 function ( sData ) 351 { 352 sData = jtQuery("<div/>").html(sData).text(); 353 sData = cleanHTMLTags(sData); 354 sData = sData.replace(/[\s| ]/gmi, "").replace(/[\+|%|\$|\£|\â¬]/gm,""); 355 if (sData == "") return 'numeric-comma'; 356 if (isCommaFormattedNumber(sData)) return 'numeric-comma'; 357 else return null; 358 } 359 ); 360 361 jtQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) { 362 var x = parseCommaFormattedNumber(a, 'asc'), y = parseCommaFormattedNumber(b, 'asc'); 363 return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 364 }; 365 366 jtQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) { 367 var x = parseCommaFormattedNumber(a, 'desc'), y = parseCommaFormattedNumber(b, 'desc'); 368 return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 369 }; 370 371} 372 373
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.