yarn.dt.plugins.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. if (!jQuery.fn.dataTableExt.fnVersionCheck("1.7.5")) {
  2. alert("These plugins requires dataTables 1.7.5+");
  3. }
  4. // don't filter on hidden html elements for an sType of title-numeric
  5. $.fn.dataTableExt.ofnSearch['title-numeric'] = function ( sData ) {
  6. return sData.replace(/\n/g," ").replace( /<.*?>/g, "" );
  7. }
  8. // 'title-numeric' sort type
  9. jQuery.fn.dataTableExt.oSort['title-numeric-asc'] = function(a,b) {
  10. var x = a.match(/title=["']?(-?\d+\.?\d*)/)[1];
  11. var y = b.match(/title=["']?(-?\d+\.?\d*)/)[1];
  12. x = parseFloat( x );
  13. y = parseFloat( y );
  14. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  15. };
  16. jQuery.fn.dataTableExt.oSort['title-numeric-desc'] = function(a,b) {
  17. var x = a.match(/title=["']?(-?\d+\.?\d*)/)[1];
  18. var y = b.match(/title=["']?(-?\d+\.?\d*)/)[1];
  19. x = parseFloat( x );
  20. y = parseFloat( y );
  21. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  22. };
  23. jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
  24. var
  25. _that = this,
  26. iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay;
  27. this.each( function ( i ) {
  28. $.fn.dataTableExt.iApiIndex = i;
  29. var
  30. $this = this,
  31. oTimerId = null,
  32. sPreviousSearch = null,
  33. anControl = $( 'input', _that.fnSettings().aanFeatures.f );
  34. anControl.unbind( 'keyup' ).bind( 'keyup', function() {
  35. var $$this = $this;
  36. if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
  37. window.clearTimeout(oTimerId);
  38. sPreviousSearch = anControl.val();
  39. oSettings.oApi._fnProcessingDisplay(oSettings, true);
  40. oTimerId = window.setTimeout(function() {
  41. $.fn.dataTableExt.iApiIndex = i;
  42. _that.fnFilter( anControl.val() );
  43. oSettings.oApi._fnProcessingDisplay(oSettings, false);
  44. }, iDelay);
  45. }
  46. });
  47. return this;
  48. } );
  49. return this;
  50. }
  51. function renderHadoopDate(data, type, full) {
  52. if (type === 'display') {
  53. return new Date(parseInt(data)).toUTCString();
  54. }
  55. // 'filter', 'sort', 'type' and undefined all just use the number
  56. return data;
  57. }
  58. function renderHadoopElapsedTime(data, type, full) {
  59. if (type === 'display') {
  60. var timeDiff = parseInt(data);
  61. if(timeDiff < 0)
  62. return "N/A";
  63. var hours = Math.floor(timeDiff / (60*60*1000));
  64. var rem = (timeDiff % (60*60*1000));
  65. var minutes = Math.floor(rem / (60*1000));
  66. rem = rem % (60*1000);
  67. var seconds = Math.floor(rem / 1000);
  68. var toReturn = "";
  69. if (hours != 0){
  70. toReturn += hours;
  71. toReturn += "hrs, ";
  72. }
  73. if (minutes != 0){
  74. toReturn += minutes;
  75. toReturn += "mins, ";
  76. }
  77. toReturn += seconds;
  78. toReturn += "sec";
  79. return toReturn;
  80. }
  81. // 'filter', 'sort', 'type' and undefined all just use the number
  82. return data;
  83. }
  84. function parseHadoopID(data, type, full) {
  85. if (type === 'display' || type === 'filter') {
  86. return data;
  87. }
  88. //Parse the ID for 'sort', 'type' and undefined
  89. //The number after the last '_' and before the end tag '<'
  90. var splits = data.split('_');
  91. return splits[parseInt(splits.length-1)].split('<')[0];
  92. }