server_status_variables.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* vim: set expandtab sw=4 ts=4 sts=4: */
  2. /**
  3. *
  4. *
  5. * @package PhpMyAdmin
  6. */
  7. /**
  8. * Unbind all event handlers before tearing down a page
  9. */
  10. AJAX.registerTeardown('server_status_variables.js', function() {
  11. $('#filterAlert').unbind('change');
  12. $('#filterText').unbind('keyup');
  13. $('#filterCategory').unbind('change');
  14. $('#dontFormat').unbind('change');
  15. });
  16. AJAX.registerOnload('server_status_variables.js', function() {
  17. /*** Table sort tooltip ***/
  18. PMA_tooltip(
  19. $('table.sortable>thead>tr:first').find('th'),
  20. 'th',
  21. PMA_messages['strSortHint']
  22. );
  23. initTableSorter('statustabs_allvars');
  24. // Filters for status variables
  25. var textFilter = null;
  26. var alertFilter = $('#filterAlert').prop('checked');
  27. var categoryFilter = $('#filterCategory').find(':selected').val();
  28. var odd_row = false;
  29. var text = ''; // Holds filter text
  30. /* 3 Filtering functions */
  31. $('#filterAlert').change(function() {
  32. alertFilter = this.checked;
  33. filterVariables();
  34. });
  35. $('#filterCategory').change(function() {
  36. categoryFilter = $(this).val();
  37. filterVariables();
  38. });
  39. $('#dontFormat').change(function() {
  40. // Hiding the table while changing values speeds up the process a lot
  41. $('#serverstatusvariables').hide();
  42. $('#serverstatusvariables td.value span.original').toggle(this.checked);
  43. $('#serverstatusvariables td.value span.formatted').toggle(! this.checked);
  44. $('#serverstatusvariables').show();
  45. }).trigger('change');
  46. $('#filterText').keyup(function(e) {
  47. var word = $(this).val().replace(/_/g, ' ');
  48. if (word.length == 0) {
  49. textFilter = null;
  50. } else {
  51. textFilter = new RegExp("(^| )" + word, 'i');
  52. }
  53. text = word;
  54. filterVariables();
  55. }).trigger('keyup');
  56. /* Filters the status variables by name/category/alert in the variables tab */
  57. function filterVariables() {
  58. var useful_links = 0;
  59. var section = text;
  60. if (categoryFilter.length > 0) {
  61. section = categoryFilter;
  62. }
  63. if (section.length > 1) {
  64. $('#linkSuggestions span').each(function() {
  65. if ($(this).attr('class').indexOf('status_' + section) != -1) {
  66. useful_links++;
  67. $(this).css('display', '');
  68. } else {
  69. $(this).css('display', 'none');
  70. }
  71. });
  72. }
  73. if (useful_links > 0) {
  74. $('#linkSuggestions').css('display', '');
  75. } else {
  76. $('#linkSuggestions').css('display', 'none');
  77. }
  78. odd_row = false;
  79. $('#serverstatusvariables th.name').each(function() {
  80. if ((textFilter == null || textFilter.exec($(this).text()))
  81. && (! alertFilter || $(this).next().find('span.attention').length>0)
  82. && (categoryFilter.length == 0 || $(this).parent().hasClass('s_' + categoryFilter))
  83. ) {
  84. odd_row = ! odd_row;
  85. $(this).parent().css('display', '');
  86. if (odd_row) {
  87. $(this).parent().addClass('odd');
  88. $(this).parent().removeClass('even');
  89. } else {
  90. $(this).parent().addClass('even');
  91. $(this).parent().removeClass('odd');
  92. }
  93. } else {
  94. $(this).parent().css('display', 'none');
  95. }
  96. });
  97. }
  98. });