server_status_variables.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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').off('change');
  12. $('#filterText').off('keyup');
  13. $('#filterCategory').off('change');
  14. $('#dontFormat').off('change');
  15. });
  16. AJAX.registerOnload('server_status_variables.js', function () {
  17. // Filters for status variables
  18. var textFilter = null;
  19. var alertFilter = $('#filterAlert').prop('checked');
  20. var categoryFilter = $('#filterCategory').find(':selected').val();
  21. var text = ''; // Holds filter text
  22. /* 3 Filtering functions */
  23. $('#filterAlert').change(function () {
  24. alertFilter = this.checked;
  25. filterVariables();
  26. });
  27. $('#filterCategory').change(function () {
  28. categoryFilter = $(this).val();
  29. filterVariables();
  30. });
  31. $('#dontFormat').change(function () {
  32. // Hiding the table while changing values speeds up the process a lot
  33. $('#serverstatusvariables').hide();
  34. $('#serverstatusvariables').find('td.value span.original').toggle(this.checked);
  35. $('#serverstatusvariables').find('td.value span.formatted').toggle(! this.checked);
  36. $('#serverstatusvariables').show();
  37. }).trigger('change');
  38. $('#filterText').keyup(function (e) {
  39. var word = $(this).val().replace(/_/g, ' ');
  40. if (word.length === 0) {
  41. textFilter = null;
  42. } else {
  43. try {
  44. textFilter = new RegExp('(^| )' + word, 'i');
  45. $(this).removeClass('error');
  46. } catch (e) {
  47. if (e instanceof SyntaxError) {
  48. $(this).addClass('error');
  49. textFilter = null;
  50. }
  51. }
  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').find('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. $('#serverstatusvariables').find('th.name').each(function () {
  79. if ((textFilter === null || textFilter.exec($(this).text())) &&
  80. (! alertFilter || $(this).next().find('span.attention').length > 0) &&
  81. (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
  82. ) {
  83. $(this).parent().css('display', '');
  84. } else {
  85. $(this).parent().css('display', 'none');
  86. }
  87. });
  88. }
  89. });