Revert "Login screen improvements and added favicon (#227)"
[openemr.git] / phpmyadmin / js / server_status_variables.js
blob47956f84643ac217b037d67b0395068c2f4789a6
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             try {
52                 textFilter = new RegExp("(^| )" + word, 'i');
53                 $(this).removeClass('error');
54             } catch(e) {
55                 if (e instanceof SyntaxError) {
56                     $(this).addClass('error');
57                     textFilter = null;
58                 }
59             }
60         }
61         text = word;
62         filterVariables();
63     }).trigger('keyup');
65     /* Filters the status variables by name/category/alert in the variables tab */
66     function filterVariables() {
67         var useful_links = 0;
68         var section = text;
70         if (categoryFilter.length > 0) {
71             section = categoryFilter;
72         }
74         if (section.length > 1) {
75             $('#linkSuggestions').find('span').each(function () {
76                 if ($(this).attr('class').indexOf('status_' + section) != -1) {
77                     useful_links++;
78                     $(this).css('display', '');
79                 } else {
80                     $(this).css('display', 'none');
81                 }
82             });
83         }
85         if (useful_links > 0) {
86             $('#linkSuggestions').css('display', '');
87         } else {
88             $('#linkSuggestions').css('display', 'none');
89         }
91         odd_row = false;
92         $('#serverstatusvariables').find('th.name').each(function () {
93             if ((textFilter === null || textFilter.exec($(this).text())) &&
94                 (! alertFilter || $(this).next().find('span.attention').length > 0) &&
95                 (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
96             ) {
97                 odd_row = ! odd_row;
98                 $(this).parent().css('display', '');
99                 if (odd_row) {
100                     $(this).parent().addClass('odd');
101                     $(this).parent().removeClass('even');
102                 } else {
103                     $(this).parent().addClass('even');
104                     $(this).parent().removeClass('odd');
105                 }
106             } else {
107                 $(this).parent().css('display', 'none');
108             }
109         });
110     }