Translated using Weblate (Interlingua)
[phpmyadmin.git] / js / server_status_variables.js
blobfa46f1fda91e1c2e57b957a56464c86a9b233c05
1 /* vim: set expandtab sw=4 ts=4 sts=4: */
2 /**
3  *
4  *
5  * @package PhpMyAdmin
6  */
8 /**
9  * Unbind all event handlers before tearing down a page
10  */
11 AJAX.registerTeardown('server_status_variables.js', function () {
12     $('#filterAlert').unbind('change');
13     $('#filterText').unbind('keyup');
14     $('#filterCategory').unbind('change');
15     $('#dontFormat').unbind('change');
16 });
18 AJAX.registerOnload('server_status_variables.js', function () {
20     // Filters for status variables
21     var textFilter = null;
22     var alertFilter = $('#filterAlert').prop('checked');
23     var categoryFilter = $('#filterCategory').find(':selected').val();
24     var odd_row = false;
25     var text = ''; // Holds filter text
27     /* 3 Filtering functions */
28     $('#filterAlert').change(function () {
29         alertFilter = this.checked;
30         filterVariables();
31     });
33     $('#filterCategory').change(function () {
34         categoryFilter = $(this).val();
35         filterVariables();
36     });
38     $('#dontFormat').change(function () {
39         // Hiding the table while changing values speeds up the process a lot
40         $('#serverstatusvariables').hide();
41         $('#serverstatusvariables').find('td.value span.original').toggle(this.checked);
42         $('#serverstatusvariables').find('td.value span.formatted').toggle(! this.checked);
43         $('#serverstatusvariables').show();
44     }).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');
57     /* Filters the status variables by name/category/alert in the variables tab */
58     function filterVariables() {
59         var useful_links = 0;
60         var section = text;
62         if (categoryFilter.length > 0) {
63             section = categoryFilter;
64         }
66         if (section.length > 1) {
67             $('#linkSuggestions').find('span').each(function () {
68                 if ($(this).attr('class').indexOf('status_' + section) != -1) {
69                     useful_links++;
70                     $(this).css('display', '');
71                 } else {
72                     $(this).css('display', 'none');
73                 }
74             });
75         }
77         if (useful_links > 0) {
78             $('#linkSuggestions').css('display', '');
79         } else {
80             $('#linkSuggestions').css('display', 'none');
81         }
83         odd_row = false;
84         $('#serverstatusvariables').find('th.name').each(function () {
85             if ((textFilter === null || textFilter.exec($(this).text())) &&
86                 (! alertFilter || $(this).next().find('span.attention').length > 0) &&
87                 (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
88             ) {
89                 odd_row = ! odd_row;
90                 $(this).parent().css('display', '');
91                 if (odd_row) {
92                     $(this).parent().addClass('odd');
93                     $(this).parent().removeClass('even');
94                 } else {
95                     $(this).parent().addClass('even');
96                     $(this).parent().removeClass('odd');
97                 }
98             } else {
99                 $(this).parent().css('display', 'none');
100             }
101         });
102     }