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').off('change');
13 $('#filterText').off('keyup');
14 $('#filterCategory').off('change');
15 $('#dontFormat').off('change');
18 AJAX.registerOnload('server_status_variables.js', function () {
19 // Filters for status variables
20 var textFilter = null;
21 var alertFilter = $('#filterAlert').prop('checked');
22 var categoryFilter = $('#filterCategory').find(':selected').val();
23 var text = ''; // Holds filter text
25 /* 3 Filtering functions */
26 $('#filterAlert').change(function () {
27 alertFilter = this.checked;
31 $('#filterCategory').change(function () {
32 categoryFilter = $(this).val();
36 $('#dontFormat').change(function () {
37 // Hiding the table while changing values speeds up the process a lot
38 $('#serverstatusvariables').hide();
39 $('#serverstatusvariables').find('td.value span.original').toggle(this.checked);
40 $('#serverstatusvariables').find('td.value span.formatted').toggle(! this.checked);
41 $('#serverstatusvariables').show();
44 $('#filterText').keyup(function (e) {
45 var word = $(this).val().replace(/_/g, ' ');
46 if (word.length === 0) {
50 textFilter = new RegExp('(^| )' + word, 'i');
51 $(this).removeClass('error');
53 if (e instanceof SyntaxError) {
54 $(this).addClass('error');
63 /* Filters the status variables by name/category/alert in the variables tab */
64 function filterVariables () {
68 if (categoryFilter.length > 0) {
69 section = categoryFilter;
72 if (section.length > 1) {
73 $('#linkSuggestions').find('span').each(function () {
74 if ($(this).attr('class').indexOf('status_' + section) !== -1) {
76 $(this).css('display', '');
78 $(this).css('display', 'none');
83 if (useful_links > 0) {
84 $('#linkSuggestions').css('display', '');
86 $('#linkSuggestions').css('display', 'none');
89 $('#serverstatusvariables').find('th.name').each(function () {
90 if ((textFilter === null || textFilter.exec($(this).text())) &&
91 (! alertFilter || $(this).next().find('span.attention').length > 0) &&
92 (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter))
94 $(this).parent().css('display', '');
96 $(this).parent().css('display', 'none');