/* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Server Status Advisor * * @package PhpMyAdmin */ /** * Unbind all event handlers before tearing down a page */ AJAX.registerTeardown('server_status_advisor.js', function () { $('a[href="#openAdvisorInstructions"]').unbind('click'); $('#statustabs_advisor').html(''); $('#advisorDialog').remove(); $('#instructionsDialog').remove(); }); AJAX.registerOnload('server_status_advisor.js', function () { /**** Server config advisor ****/ var $dialog = $('
').attr('id', 'advisorDialog'); var $instructionsDialog = $('
') .attr('id', 'instructionsDialog') .html($('#advisorInstructionsDialog').html()); $('a[href="#openAdvisorInstructions"]').click(function () { var dlgBtns = {}; dlgBtns[PMA_messages.strClose] = function () { $(this).dialog('close'); }; $instructionsDialog.dialog({ title: PMA_messages.strAdvisorSystem, width: 700, buttons: dlgBtns }); }); var $cnt = $('#statustabs_advisor'); var $tbody, $tr, str, even = true; data = $.parseJSON($('#advisorData').text()); $cnt.html(''); if (data.parse.errors.length > 0) { $cnt.append('Rules file not well formed, following errors were found:
- '); $cnt.append(data.parse.errors.join('
- ')); $cnt.append('

'); } if (data.run.errors.length > 0) { $cnt.append('Errors occurred while executing rule expressions:
- '); $cnt.append(data.run.errors.join('
- ')); $cnt.append('

'); } if (data.run.fired.length > 0) { $cnt.append('

' + PMA_messages.strPerformanceIssues + '

'); $cnt.append('' + '
' + PMA_messages.strIssuse + '' + PMA_messages.strRecommendation + '
'); $tbody = $cnt.find('table#rulesFired'); var rc_stripped; $.each(data.run.fired, function (key, value) { // recommendation may contain links, don't show those in overview table (clicking on them redirects the user) rc_stripped = $.trim($('
').html(value.recommendation).text()); $tbody.append($tr = $('' + value.issue + '' + rc_stripped + ' ')); even = !even; $tr.data('rule', value); $tr.click(function () { var rule = $(this).data('rule'); $dialog .dialog({title: PMA_messages.strRuleDetails}) .html( '

' + PMA_messages.strIssuse + ':
' + rule.issue + '

' + '

' + PMA_messages.strRecommendation + ':
' + rule.recommendation + '

' + '

' + PMA_messages.strJustification + ':
' + rule.justification + '

' + '

' + PMA_messages.strFormula + ':
' + rule.formula + '

' + '

' + PMA_messages.strTest + ':
' + rule.test + '

' ); var dlgBtns = {}; dlgBtns[PMA_messages.strClose] = function () { $(this).dialog('close'); }; $dialog.dialog({ width: 600, buttons: dlgBtns }); }); }); } });