1 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * Unbind all event handlers before tearing down a page
11 AJAX.registerTeardown('server_status_variables.js', function () {
12 $('#filterAlert').unbind('change');
13 $('#filterText').unbind('keyup');
14 $('#filterCategory').unbind('change');
15 $('#dontFormat').unbind('change');
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();
25 var text = ''; // Holds filter text
27 /* 3 Filtering functions */
28 $('#filterAlert').change(function () {
29 alertFilter = this.checked;
33 $('#filterCategory').change(function () {
34 categoryFilter = $(this).val();
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();
46 $('#filterText').keyup(function (e) {
47 var word = $(this).val().replace(/_/g, ' ');
48 if (word.length === 0) {
52 textFilter = new RegExp("(^| )" + word, 'i');
53 $(this).removeClass('error');
55 if (e instanceof SyntaxError) {
56 $(this).addClass('error');
65 /* Filters the status variables by name/category/alert in the variables tab */
66 function filterVariables() {
70 if (categoryFilter.length > 0) {
71 section = categoryFilter;
74 if (section.length > 1) {
75 $('#linkSuggestions').find('span').each(function () {
76 if ($(this).attr('class').indexOf('status_' + section) != -1) {
78 $(this).css('display', '');
80 $(this).css('display', 'none');
85 if (useful_links > 0) {
86 $('#linkSuggestions').css('display', '');
88 $('#linkSuggestions').css('display', 'none');
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))
98 $(this).parent().css('display', '');
100 $(this).parent().addClass('odd');
101 $(this).parent().removeClass('even');
103 $(this).parent().addClass('even');
104 $(this).parent().removeClass('odd');
107 $(this).parent().css('display', 'none');