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();
24 var text = ''; // Holds filter text
26 /* 3 Filtering functions */
27 $('#filterAlert').change(function () {
28 alertFilter = this.checked;
32 $('#filterCategory').change(function () {
33 categoryFilter = $(this).val();
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();
45 $('#filterText').keyup(function (e) {
46 var word = $(this).val().replace(/_/g, ' ');
47 if (word.length === 0) {
51 textFilter = new RegExp("(^| )" + word, 'i');
52 $(this).removeClass('error');
54 if (e instanceof SyntaxError) {
55 $(this).addClass('error');
64 /* Filters the status variables by name/category/alert in the variables tab */
65 function filterVariables() {
69 if (categoryFilter.length > 0) {
70 section = categoryFilter;
73 if (section.length > 1) {
74 $('#linkSuggestions').find('span').each(function () {
75 if ($(this).attr('class').indexOf('status_' + section) != -1) {
77 $(this).css('display', '');
79 $(this).css('display', 'none');
84 if (useful_links > 0) {
85 $('#linkSuggestions').css('display', '');
87 $('#linkSuggestions').css('display', 'none');
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))
95 $(this).parent().css('display', '');
97 $(this).parent().css('display', 'none');