Translated using Weblate (Bengali)
[phpmyadmin.git] / js / server_status_variables.js
blobc06952c4ee4982d1476bcf8149033b58aac8f5ba
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 text = ''; // Holds filter text
26     /* 3 Filtering functions */
27     $('#filterAlert').change(function () {
28         alertFilter = this.checked;
29         filterVariables();
30     });
32     $('#filterCategory').change(function () {
33         categoryFilter = $(this).val();
34         filterVariables();
35     });
37     $('#dontFormat').change(function () {
38         // Hiding the table while changing values speeds up the process a lot
39         $('#serverstatusvariables').hide();
40         $('#serverstatusvariables').find('td.value span.original').toggle(this.checked);
41         $('#serverstatusvariables').find('td.value span.formatted').toggle(! this.checked);
42         $('#serverstatusvariables').show();
43     }).trigger('change');
45     $('#filterText').keyup(function (e) {
46         var word = $(this).val().replace(/_/g, ' ');
47         if (word.length === 0) {
48             textFilter = null;
49         } else {
50             try {
51                 textFilter = new RegExp("(^| )" + word, 'i');
52                 $(this).removeClass('error');
53             } catch(e) {
54                 if (e instanceof SyntaxError) {
55                     $(this).addClass('error');
56                     textFilter = null;
57                 }
58             }
59         }
60         text = word;
61         filterVariables();
62     }).trigger('keyup');
64     /* Filters the status variables by name/category/alert in the variables tab */
65     function filterVariables() {
66         var useful_links = 0;
67         var section = text;
69         if (categoryFilter.length > 0) {
70             section = categoryFilter;
71         }
73         if (section.length > 1) {
74             $('#linkSuggestions').find('span').each(function () {
75                 if ($(this).attr('class').indexOf('status_' + section) != -1) {
76                     useful_links++;
77                     $(this).css('display', '');
78                 } else {
79                     $(this).css('display', 'none');
80                 }
81             });
82         }
84         if (useful_links > 0) {
85             $('#linkSuggestions').css('display', '');
86         } else {
87             $('#linkSuggestions').css('display', 'none');
88         }
90         $('#serverstatusvariables').find('th.name').each(function () {
91             if ((textFilter === null || textFilter.exec($(this).text())) &&
92                 (! alertFilter || $(this).next().find('span.attention').length > 0) &&
93                 (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
94             ) {
95                 $(this).parent().css('display', '');
96             } else {
97                 $(this).parent().css('display', 'none');
98             }
99         });
100     }