From 91340d18e5e5c550ece72d23ef6f473bf1a5f80b Mon Sep 17 00:00:00 2001 From: Piyush Vijay Date: Wed, 27 Jun 2018 21:02:34 +0530 Subject: [PATCH 1/3] Test files changed as per the new chages in FormDisplayTemplate. Js code is stuctured properly with comments. Signed-Off-By: Piyush Vijay --- js/src/export.js | 107 +++++++++----- js/src/import.js | 32 +++- js/src/server_plugins.js | 19 ++- js/src/server_status_advisor.js | 53 ++++--- js/src/server_status_processes.js | 27 +++- js/src/server_status_queries.js | 28 +++- js/src/server_status_variables.js | 71 ++++----- js/src/server_user_groups.js | 27 +++- js/src/server_variables.js | 117 +++------------ js/src/variables/common_params.js | 48 ++++-- js/src/variables/export_variables.js | 39 ++++- js/src/variables/get_config.js | 34 ++++- js/src/variables/global_variables.js | 209 ++++++++++++++------------- js/src/variables/import_variables.js | 51 +++++-- 14 files changed, 520 insertions(+), 342 deletions(-) diff --git a/js/src/export.js b/js/src/export.js index db61680d13..a0724010c8 100644 --- a/js/src/export.js +++ b/js/src/export.js @@ -1,19 +1,45 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -import { createTemplate, loadTemplate, updateTemplate, - deleteTemplate, toggle_save_to_file, toggle_structure_data_opts, - check_table_select_all, handleAddProcCheckbox, check_table_select_struture_or_data, - check_table_selected, toggle_table_select, toggle_table_select_all_str, - check_selected_tables, toggle_table_select_all_data, setup_table_structure_or_data, - toggle_quick_or_custom, toggle_sql_include_comments, disable_dump_some_rows_sub_options, - enable_dump_some_rows_sub_options, aliasToggleRow, addAlias, createAliasModal, check_time_out +/** + * Module import + */ +import { + createTemplate, + loadTemplate, + updateTemplate, + deleteTemplate, + toggle_save_to_file, + toggle_structure_data_opts, + check_table_select_all, + handleAddProcCheckbox, + check_table_select_struture_or_data, + check_table_selected, + toggle_table_select, + toggle_table_select_all_str, + check_selected_tables, + toggle_table_select_all_data, + setup_table_structure_or_data, + toggle_quick_or_custom, + toggle_sql_include_comments, + disable_dump_some_rows_sub_options, + enable_dump_some_rows_sub_options, + aliasToggleRow, + addAlias, + createAliasModal } from './functions/export'; -import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_commonParams } from './variables/common_params'; +import { PMA_Messages as messages } from './variables/export_variables'; +import CommonParams from './variables/common_params'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; + +/** + * @package PhpMyAdmin + * + * Export + */ + /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownExport () { $('#plugins').off('change'); $('input[type=\'radio\'][name=\'sql_structure_or_data\']').off('change'); $('input[type=\'radio\'][name$=\'_structure_or_data\']').off('change'); @@ -38,7 +64,7 @@ export function teardown1 () { $('form[name=\'dump\']').off('submit'); } -export function onload1 () { +function onloadExportTemplate () { /** * Export template handling code */ @@ -84,26 +110,26 @@ export function onload1 () { */ $('#plugins').on('change', function () { $('#format_specific_opts').find('div.format_specific_options').hide(); - var selected_plugin_name = $('#plugins').find('option:selected').val(); - $('#' + selected_plugin_name + '_options').show(); + var selectedPluginName = $('#plugins').find('option:selected').val(); + $('#' + selectedPluginName + '_options').show(); }); /** * Toggles the enabling and disabling of the SQL plugin's comment options that apply only when exporting structure */ $('input[type=\'radio\'][name=\'sql_structure_or_data\']').on('change', function () { - var comments_are_present = $('#checkbox_sql_include_comments').prop('checked'); + var commentsArePresent = $('#checkbox_sql_include_comments').prop('checked'); var show = $('input[type=\'radio\'][name=\'sql_structure_or_data\']:checked').val(); if (show === 'data') { // disable the SQL comment options - if (comments_are_present) { + if (commentsArePresent) { $('#checkbox_sql_dates').prop('disabled', true).parent().fadeTo('fast', 0.4); } $('#checkbox_sql_relation').prop('disabled', true).parent().fadeTo('fast', 0.4); $('#checkbox_sql_mime').prop('disabled', true).parent().fadeTo('fast', 0.4); } else { // enable the SQL comment options - if (comments_are_present) { + if (commentsArePresent) { $('#checkbox_sql_dates').prop('disabled', false).parent().fadeTo('fast', 1); } $('#checkbox_sql_relation').prop('disabled', false).parent().fadeTo('fast', 1); @@ -137,22 +163,22 @@ export function onload1 () { }); } -export function onload2 () { +function onloadSaveToFile () { toggle_save_to_file(); $('input[type=\'radio\'][name=\'output_format\']').on('change', toggle_save_to_file); } -export function onload3 () { +function onloadExportOptions () { /** * For SQL plugin, if "CREATE TABLE options" is checked/unchecked, check/uncheck each of its sub-options */ var $create = $('#checkbox_sql_create_table_statements'); - var $create_options = $('#ul_create_table_statements').find('input'); + var $createOptions = $('#ul_create_table_statements').find('input'); $create.on('change', function () { - $create_options.prop('checked', $(this).prop('checked')); + $createOptions.prop('checked', $(this).prop('checked')); }); - $create_options.on('change', function () { - if ($create_options.is(':checked')) { + $createOptions.on('change', function () { + if ($createOptions.is(':checked')) { $create.prop('checked', true); } }); @@ -161,9 +187,9 @@ export function onload3 () { * Disables the view output as text option if the output must be saved as a file */ $('#plugins').on('change', function () { - var active_plugin = $('#plugins').find('option:selected').val(); - var force_file = $('#force_file_' + active_plugin).val(); - if (force_file === 'true') { + var activePlugin = $('#plugins').find('option:selected').val(); + var forceFile = $('#force_file_' + activePlugin).val(); + if (forceFile === 'true') { if ($('#radio_dump_asfile').prop('checked') !== true) { $('#radio_dump_asfile').prop('checked', true); toggle_save_to_file(); @@ -219,11 +245,11 @@ export function onload3 () { var $this = $(this); var name = $this.prop('name'); var val = $('input[name="' + name + '"]:checked').val(); - var name_default = name + '_default'; - if (!$('input[name="' + name_default + '"]').length) { + var nameDefault = name + '_default'; + if (!$('input[name="' + nameDefault + '"]').length) { $this .after( - $('') + $('') ) .after( $('') @@ -257,7 +283,7 @@ export function onload3 () { $('#plugins').on('change', setup_table_structure_or_data); } -export function onload4 () { +function onloadExportSubmit () { $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggle_quick_or_custom); $('#scroll_to_options_msg').hide(); @@ -300,7 +326,7 @@ export function onload4 () { $('#db_alias_select').on('change', function () { aliasToggleRow($(this)); // var db = $(this).val(); - var table = PMA_commonParams.get('table'); + var table = CommonParams.get('table'); if (table) { var option = $(''); option.text(table); @@ -309,7 +335,7 @@ export function onload4 () { } else { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), + server : CommonParams.get('server'), db : $(this).val(), type: 'list-tables' }; @@ -331,7 +357,7 @@ export function onload4 () { aliasToggleRow($(this)); var params = { ajax_request : true, - server : PMA_commonParams.get('server'), + server : CommonParams.get('server'), db : $('#db_alias_select').val(), table: $(this).val(), type: 'list-columns' @@ -356,7 +382,7 @@ export function onload4 () { e.preventDefault(); var db = $('#db_alias_select').val(); addAlias( - PMA_messages.strAliasDatabase, + messages.strAliasDatabase, db, 'aliases[' + db + '][alias]', $('#db_alias_name').val() @@ -368,7 +394,7 @@ export function onload4 () { var db = $('#db_alias_select').val(); var table = $('#table_alias_select').val(); addAlias( - PMA_messages.strAliasTable, + messages.strAliasTable, db + '.' + table, 'aliases[' + db + '][tables][' + table + '][alias]', $('#table_alias_name').val() @@ -381,7 +407,7 @@ export function onload4 () { var table = $('#table_alias_select').val(); var column = $('#column_alias_select').val(); addAlias( - PMA_messages.strAliasColumn, + messages.strAliasColumn, db + '.' + table + '.' + column, 'aliases[' + db + '][tables][' + table + '][colums][' + column + ']', $('#column_alias_name').val() @@ -389,3 +415,14 @@ export function onload4 () { $('#column_alias_name').val(''); }); } + +/** + * Module export + */ +export { + teardownExport, + onloadExportOptions, + onloadExportSubmit, + onloadExportTemplate, + onloadSaveToFile +}; diff --git a/js/src/import.js b/js/src/import.js index 1d0cfec98e..9fd8c27ab3 100644 --- a/js/src/import.js +++ b/js/src/import.js @@ -1,11 +1,22 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ import { changePluginOpts, matchFile } from './functions/import'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; -import { PMA_Messages as PMA_messages } from './variables/export_variables'; +import { PMA_Messages as messages } from './variables/export_variables'; + +/** + * @package PhpMyAdmin + * + * Import + */ + /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownImport () { $('#plugins').off('change'); $('#input_import_file').off('change'); $('#select_local_import_file').off('change'); @@ -14,12 +25,15 @@ export function teardown1 () { $('#text_csv_enclosed').add('#text_csv_escaped').off('keyup'); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadImport () { // import_file_form validation. $(document).on('submit', '#import_file_form', function () { var radioLocalImport = $('#radio_local_import_file'); var radioImport = $('#radio_import_file'); - var fileMsg = '
' + PMA_messages.strImportDialogMessage + '
'; + var fileMsg = '
' + messages.strImportDialogMessage + '
'; if (radioLocalImport.length !== 0) { // remote upload. @@ -32,7 +46,7 @@ export function onload1 () { if (radioLocalImport.is(':checked')) { if ($('#select_local_import_file').length === 0) { - PMA_ajaxShowMessage('
' + PMA_messages.strNoImportFile + '
', false); + PMA_ajaxShowMessage('
' + messages.strNoImportFile + '
', false); return false; } @@ -113,3 +127,11 @@ export function onload1 () { return true; }); } + +/** + * Module export + */ +export { + teardownImport, + onloadImport +}; diff --git a/js/src/server_plugins.js b/js/src/server_plugins.js index 97f153c719..c02c2c4528 100644 --- a/js/src/server_plugins.js +++ b/js/src/server_plugins.js @@ -1,9 +1,15 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Functions used in server plugins pages + * @package PhpMyAdmin + * + * Server Plugins */ -// import { jQuery as $ } from './utils/extend_jquery'; -export function onload1 () { + +/** + * Binding event handlers on page load. + */ +function onloadServerPlugins () { // Make columns sortable, but only for tables with more than 1 data row var $tables = $('#plugins_plugins table:has(tbody tr + tr)'); $tables.tablesorter({ @@ -15,3 +21,10 @@ export function onload1 () { $tables.find('thead th') .append('
'); } + +/** + * Module export + */ +export { + onloadServerPlugins +}; diff --git a/js/src/server_status_advisor.js b/js/src/server_status_advisor.js index f3eb162d21..af2bd63982 100644 --- a/js/src/server_status_advisor.js +++ b/js/src/server_status_advisor.js @@ -1,23 +1,30 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -/** - * Server Status Advisor - * - * @package PhpMyAdmin - */ -import { PMA_Messages as PMA_messages } from './variables/export_variables'; +/** + * Module import + */ +import { PMA_Messages as messages } from './variables/export_variables'; + +/** + * @package PhpMyAdmin + * + * Server Status Advisor + */ /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusAdvisor () { $('a[href="#openAdvisorInstructions"]').off('click'); $('#statustabs_advisor').html(''); $('#advisorDialog').remove(); $('#instructionsDialog').remove(); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadServerStatusAdvisor () { // if no advisor is loaded if ($('#advisorData').length === 0) { return; @@ -31,11 +38,11 @@ export function onload1 () { $('a[href="#openAdvisorInstructions"]').click(function () { var dlgBtns = {}; - dlgBtns[PMA_messages.strClose] = function () { + dlgBtns[messages.strClose] = function () { $(this).dialog('close'); }; $instructionsDialog.dialog({ - title: PMA_messages.strAdvisorSystem, + title: messages.strAdvisorSystem, width: 700, buttons: dlgBtns }); @@ -62,9 +69,9 @@ export function onload1 () { } if (data.run.fired.length > 0) { - $cnt.append('

' + PMA_messages.strPerformanceIssues + '

'); + $cnt.append('

' + messages.strPerformanceIssues + '

'); $cnt.append('' + - '
' + PMA_messages.strIssuse + '' + PMA_messages.strRecommendation + + '' + messages.strIssuse + '' + messages.strRecommendation + '
'); $tbody = $cnt.find('table#rulesFired'); @@ -81,17 +88,17 @@ export function onload1 () { $tr.click(function () { var rule = $(this).data('rule'); $dialog - .dialog({ title: PMA_messages.strRuleDetails }) + .dialog({ title: 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 + '

' + '

' + messages.strIssuse + ':
' + rule.issue + '

' + + '

' + messages.strRecommendation + ':
' + rule.recommendation + '

' + + '

' + messages.strJustification + ':
' + rule.justification + '

' + + '

' + messages.strFormula + ':
' + rule.formula + '

' + + '

' + messages.strTest + ':
' + rule.test + '

' ); var dlgBtns = {}; - dlgBtns[PMA_messages.strClose] = function () { + dlgBtns[messages.strClose] = function () { $(this).dialog('close'); }; @@ -100,3 +107,11 @@ export function onload1 () { }); } } + +/** + * Module export + */ +export { + teardownServerStatusAdvisor, + onloadServerStatusAdvisor +}; diff --git a/js/src/server_status_processes.js b/js/src/server_status_processes.js index d880907f5c..a873d58127 100644 --- a/js/src/server_status_processes.js +++ b/js/src/server_status_processes.js @@ -1,11 +1,20 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Server Status Processes - * - * @package PhpMyAdmin + * Module import */ import processList from './classes/Server/ProcessList'; -export function onload1 () { + +/** + * @package PhpMyAdmin + * + * Server Status Processes + */ + +/** + * Binding event handlers on page load + */ +function onloadServerStatusProcesses () { processList.init(); // Bind event handler for kill_process $('#tableprocesslist').on('click', 'a.kill_process', function (event) { @@ -31,7 +40,7 @@ export function onload1 () { /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusProcesses () { $('#tableprocesslist').off('click', 'a.kill_process'); $('a#toggleRefresh').off('click'); $('#id_refreshRate').off('change'); @@ -39,3 +48,11 @@ export function teardown1 () { // stop refreshing further processList.abortRefresh(); } + +/** + * Module export + */ +export { + teardownServerStatusProcesses, + onloadServerStatusProcesses +}; diff --git a/js/src/server_status_queries.js b/js/src/server_status_queries.js index e2086f5c10..f5b151dd96 100644 --- a/js/src/server_status_queries.js +++ b/js/src/server_status_queries.js @@ -1,21 +1,29 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + /** + * Module import */ -import { PMA_createProfilingChart } from './functions/chart'; +import { createProfilingChart } from './functions/chart'; import { jQuery as $ } from './utils/JqueryExtended'; +import { initTableSorter } from './server_status_sorter'; + +/** + * @package PhpMyAdmin + * + * Server Status Queries + */ + /** * Unbind all event handlers before tearing down a page */ -import { initTableSorter } from './server_status_sorter'; - -export function teardown1 () { +function teardownServerStatusQueries () { var queryPieChart = $('#serverstatusquerieschart').data('queryPieChart'); if (queryPieChart) { queryPieChart.destroy(); } } -export function onload1 () { +function onloadServerStatusQueries () { // Build query statistics chart var cdata = []; try { @@ -24,7 +32,7 @@ export function onload1 () { }); $('#serverstatusquerieschart').data( 'queryPieChart', - PMA_createProfilingChart( + createProfilingChart( 'serverstatusquerieschart', cdata ) @@ -35,3 +43,11 @@ export function onload1 () { initTableSorter('statustabs_queries'); } + +/** + * Module export + */ +export { + teardownServerStatusQueries, + onloadServerStatusQueries +}; diff --git a/js/src/server_status_variables.js b/js/src/server_status_variables.js index b2db6e80b4..0082a96f8d 100644 --- a/js/src/server_status_variables.js +++ b/js/src/server_status_variables.js @@ -1,21 +1,30 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { filterVariables } from './functions/Server/ServerStatusVariables'; + /** - * - * * @package PhpMyAdmin + * + * Server Status Variables */ /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerStatusVariables () { $('#filterAlert').off('change'); $('#filterText').off('keyup'); $('#filterCategory').off('change'); $('#dontFormat').off('change'); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadServerStatusVariables () { // Filters for status variables var textFilter = null; var alertFilter = $('#filterAlert').prop('checked'); @@ -25,12 +34,12 @@ export function onload1 () { /* 3 Filtering functions */ $('#filterAlert').change(function () { alertFilter = this.checked; - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }); $('#filterCategory').change(function () { categoryFilter = $(this).val(); - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }); $('#dontFormat').change(function () { @@ -41,7 +50,7 @@ export function onload1 () { $('#serverstatusvariables').show(); }).trigger('change'); - $('#filterText').keyup(function (e) { + $('#filterText').keyup(function () { var word = $(this).val().replace(/_/g, ' '); if (word.length === 0) { textFilter = null; @@ -57,44 +66,14 @@ export function onload1 () { } } text = word; - filterVariables(); + filterVariables(textFilter, alertFilter, categoryFilter, text); }).trigger('keyup'); - - /* Filters the status variables by name/category/alert in the variables tab */ - function filterVariables () { - var useful_links = 0; - var section = text; - - if (categoryFilter.length > 0) { - section = categoryFilter; - } - - if (section.length > 1) { - $('#linkSuggestions').find('span').each(function () { - if ($(this).attr('class').indexOf('status_' + section) !== -1) { - useful_links++; - $(this).css('display', ''); - } else { - $(this).css('display', 'none'); - } - }); - } - - if (useful_links > 0) { - $('#linkSuggestions').css('display', ''); - } else { - $('#linkSuggestions').css('display', 'none'); - } - - $('#serverstatusvariables').find('th.name').each(function () { - if ((textFilter === null || textFilter.exec($(this).text())) && - (! alertFilter || $(this).next().find('span.attention').length > 0) && - (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter)) - ) { - $(this).parent().css('display', ''); - } else { - $(this).parent().css('display', 'none'); - } - }); - } } + +/** + * Module export + */ +export { + teardownServerStatusVariables, + onloadServerStatusVariables +}; diff --git a/js/src/server_user_groups.js b/js/src/server_user_groups.js index 4f71e1161c..1c0dec0758 100644 --- a/js/src/server_user_groups.js +++ b/js/src/server_user_groups.js @@ -1,18 +1,29 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + /** - * Unbind all event handlers before tearing down a page + * Module import */ import { PMA_Messages as PMA_messages } from './variables/export_variables'; import { PMA_sprintf } from './utils/sprintf'; import { escapeHtml } from './utils/Sanitise'; -export function teardown1 () { +/** + * @package PhpMyAdmin + * + * Server User Groups + */ + +/** + * Unbind all event handlers before tearing down a page + */ +function teardownServerUserGroups () { $(document).off('click', 'a.deleteUserGroup.ajax'); } /** - * Bind event handlers + * Bind event handlers on page load. */ -export function onload1 () { +function onloadServerUserGroups () { // update the checkall checkbox on Edit user group page $(checkboxes_sel).trigger('change'); @@ -43,3 +54,11 @@ export function onload1 () { }); }); } + +/** + * Module export + */ +export { + teardownServerUserGroups, + onloadServerUserGroups +}; diff --git a/js/src/server_variables.js b/js/src/server_variables.js index 4507963e08..c49fcb29a0 100644 --- a/js/src/server_variables.js +++ b/js/src/server_variables.js @@ -1,15 +1,28 @@ /* vim: set expandtab sw=4 ts=4 sts=4: */ -import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages'; + /** - * Unbind all event handlers before tearing down a page + * Module import */ -export function teardown1 () { +import { editVariable } from './functions/Server/ServerVariables'; + +/** + * @package PhpMyAdmin + * + * Server Variables + */ + +/** + * Unbind all event handlers before tearing down a page. + */ +function teardownServerVariables () { $(document).off('click', 'a.editLink'); $('#serverVariables').find('.var-name').find('a img').remove(); } -export function onload1 () { +/** + * Binding event handlers on page load. + */ +function onloadServerVariables () { // var $editLink = $('a.editLink'); var $saveLink = $('a.saveLink'); var $cancelLink = $('a.cancelLink'); @@ -21,93 +34,11 @@ export function onload1 () { /* Launches the variable editor */ $(document).on('click', 'a.editLink', function (event) { event.preventDefault(); - editVariable(this); + editVariable(this, $saveLink, $cancelLink); }); - - /* Allows the user to edit a server variable */ - function editVariable (link) { - var $link = $(link); - var $cell = $link.parent(); - var $valueCell = $link.parents('.var-row').find('.var-value'); - var varName = $link.data('variable'); - var $mySaveLink = $saveLink.clone().css('display', 'inline-block'); - var $myCancelLink = $cancelLink.clone().css('display', 'inline-block'); - var $msgbox = PMA_ajaxShowMessage(); - var $myEditLink = $cell.find('a.editLink'); - - $cell.addClass('edit'); // variable is being edited - $myEditLink.remove(); // remove edit link - - $mySaveLink.on('click', function () { - var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); - $.post($(this).attr('href'), { - ajax_request: true, - type: 'setval', - varName: varName, - varValue: $valueCell.find('input').val() - }, function (data) { - if (data.success) { - $valueCell - .html(data.variable) - .data('content', data.variable); - PMA_ajaxRemoveMessage($msgbox); - } else { - if (data.error === '') { - PMA_ajaxShowMessage(PMA_messages.strRequestFailed, false); - } else { - PMA_ajaxShowMessage(data.error, false); - } - $valueCell.html($valueCell.data('content')); - } - $cell.removeClass('edit').html($myEditLink); - }); - return false; - }); - - $myCancelLink.on('click', function () { - $valueCell.html($valueCell.data('content')); - $cell.removeClass('edit').html($myEditLink); - return false; - }); - - $.get($mySaveLink.attr('href'), { - ajax_request: true, - type: 'getval', - varName: varName - }, function (data) { - if (typeof data !== 'undefined' && data.success === true) { - var $links = $('
') - .append($myCancelLink) - .append('   ') - .append($mySaveLink); - var $editor = $('
', { 'class': 'serverVariableEditor' }) - .append( - $('
').append( - $('', { type: 'text' }).val(data.message) - ) - ); - // Save and replace content - $cell - .html($links) - .children() - .css('display', 'flex'); - $valueCell - .data('content', $valueCell.html()) - .html($editor) - .find('input') - .focus() - .on('keydown', function (event) { // Keyboard shortcuts - if (event.keyCode === 13) { // Enter key - $mySaveLink.trigger('click'); - } else if (event.keyCode === 27) { // Escape key - $myCancelLink.trigger('click'); - } - }); - PMA_ajaxRemoveMessage($msgbox); - } else { - $cell.removeClass('edit').html($myEditLink); - PMA_ajaxShowMessage(data.error); - } - }); - } } + +export { + teardownServerVariables, + onloadServerVariables +}; diff --git a/js/src/variables/common_params.js b/js/src/variables/common_params.js index bfbfd21ac2..0c1e81a835 100644 --- a/js/src/variables/common_params.js +++ b/js/src/variables/common_params.js @@ -1,24 +1,40 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module imports + */ import { PMA_sprintf } from '../utils/sprintf'; import { PMA_showCurrentNavigation } from '../functions/navigation'; /** + * * Holds common parameters such as server, db, table, etc * * The content for this is normally loaded from Header.php or * Response.php and executed by ajax.js + * + * @module CommonParams + * */ -export const PMA_commonParams = (function () { +const CommonParams = (function () { /** - * @var hash params An associative array of key value pairs + * @type {hash} params An associative array of key value pairs + * * @access private */ var params = {}; - // The returned object is the public part of the module + /** + * The returned object is the public part of the module. + * + * @method + * + * @access public + */ return { /** * Saves all the key value pair that * are provided in the input array * - * @param obj hash The input array + * @param {Hash} obj The input array * * @return void */ @@ -33,8 +49,8 @@ export const PMA_commonParams = (function () { } params[i] = obj[i]; } - if (updateNavigation && - $('#pma_navigation_tree').hasClass('synced') + if (updateNavigation + && $('#pma_navigation_tree').hasClass('synced') ) { PMA_showCurrentNavigation(); } @@ -43,9 +59,9 @@ export const PMA_commonParams = (function () { * Retrieves a value given its key * Returns empty string for undefined values * - * @param name string The key + * @param {string} name The key * - * @return string + * @return {string} */ get: function (name) { return params[name]; @@ -53,10 +69,11 @@ export const PMA_commonParams = (function () { /** * Saves a single key value pair * - * @param name string The key - * @param value string The value + * @param {string} name The key * - * @return self For chainability + * @param {string} value The value + * + * @return {self} For chainability */ set: function (name, value) { var updateNavigation = false; @@ -76,12 +93,12 @@ export const PMA_commonParams = (function () { /** * Returns the url query string using the saved parameters * - * @return string + * @return {string} */ getUrlQuery: function () { var common = this.get('common_query'); var separator = '?'; - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); if (common.length > 0) { separator = argsep; } @@ -96,3 +113,8 @@ export const PMA_commonParams = (function () { } }; }()); + +/** + * Module Export + */ +export default CommonParams; diff --git a/js/src/variables/export_variables.js b/js/src/variables/export_variables.js index f3a454dc85..dd9a5367c5 100644 --- a/js/src/variables/export_variables.js +++ b/js/src/variables/export_variables.js @@ -1,10 +1,39 @@ -import { Variables } from './global_variables'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ -export const PMA_Messages = Variables.getMessages(); +/** + * Module Imports + */ +import Variables from './global_variables'; -export const timePicker = Variables.getTimePickerVars(); +/** + * @type {hash} Messages Contains the message string to be used + * inside PMA. + */ +const PMA_Messages = Variables.getMessages(); -export const GlobalVariables = Variables.getGlobalVars(); +/** + * @type {hash} TimePicker Contains the strings for time and date. + */ +const timePicker = Variables.getTimePickerVars(); -export const validations = Variables.getValidatorMessages(); +/** + * @type {hash} GlobalVariables Global variables to bee used inside for PMA + * like doc template, theme etc + */ +const GlobalVariables = Variables.getGlobalVars(); +/** + * @type {hash} JqueryValidations Contains the hash for replacing the default + * jQuery validation with language specific validations. + */ +const JqueryValidations = Variables.getValidatorMessages(); + +/** + * Module Export + */ +export { + PMA_Messages, + timePicker, + GlobalVariables, + JqueryValidations +}; diff --git a/js/src/variables/get_config.js b/js/src/variables/get_config.js index ef2d6c3acb..4d4d2809be 100644 --- a/js/src/variables/get_config.js +++ b/js/src/variables/get_config.js @@ -1,16 +1,34 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Module import + */ import { validators } from '../classes/Config'; import { PMA_Messages as PMA_messages } from './export_variables'; +/** + * @type {Object} defaultValues Default values for the Settings data. + */ let defaultValues = {}; + +/** + * @type {Object} validate Validations for the settings input fields. + */ let validate = {}; /** * Registers validator for given field * + * @access private + * * @param {String} id field id + * * @param {String} type validator (key in validators object) + * * @param {boolean} onKeyUp whether fire on key up + * * @param {Array} params validation function parameters + * + * @return {void} */ function validateField (id, type, onKeyUp, params) { if (typeof validators[type] === 'undefined') { @@ -22,12 +40,26 @@ function validateField (id, type, onKeyUp, params) { validate[id].push([type, params, onKeyUp]); } +/** + * @access public + */ window.getConfigData = function () { + // Passing the arguments inside validate for validating fields. for (var i = 0; i < arguments.length - 3; i++) { validateField(...arguments[i]); } + + // Extending the Messages for validation. $.extend(PMA_messages, arguments[arguments.length - 2]); + + // Extending defaultValues object for default values of settings. $.extend(defaultValues, arguments[arguments.length - 1]); }; -export { defaultValues, validate }; +/** + * Object export + */ +export { + defaultValues, + validate +}; diff --git a/js/src/variables/global_variables.js b/js/src/variables/global_variables.js index 4f6b1807f3..78a0b2130e 100644 --- a/js/src/variables/global_variables.js +++ b/js/src/variables/global_variables.js @@ -3,113 +3,128 @@ /** * Takes parameters defined in messages.php file like messages, validations, * jquery-ui-timepicker edits + * + * @module */ -export const Variables = (function () { +class PmaVariables { /** - * @var obj params An associate array having key value pairs - * of messages to show in js files. - * - * @access private + * @constructor */ - let pmaMessages = new Array(); + constructor () { + /** + * @var obj params An associate array having key value pairs + * of messages to show in js files. + * + * @access private + */ + this.pmaMessages = new Array(); + /** + * @var obj params Associative array having global configurations + * + * @access private + */ + this.globalVariables = new Array(); + /** + * @var obj params Associative array having timepicker edits + * + * @access private + */ + this.timePickerVars = new Array(); + /** + * + * @var obj params Object having validation edits for jQuery + */ + this.validationVars = {}; + } /** - * @var obj params Associative array having global configurations + * Retrieves the messages array * - * @access private + * @return array */ - let globalVariables = new Array(); + getMessages () { + return this.pmaMessages; + } /** - * @var obj params Associative array having timepicker edits + * Retrieves the globalVars array * - * @access private + * @return array */ - let timePickerVars = new Array(); + getGlobalVars () { + return this.globalVariables; + } /** + * Retrieves the timePickerVars array * - * @var obj params Object having validation edits for jQuery + * @return array */ - let validationVars = {}; - return { - /** - * Retrieves the messages array - * - * @return array - */ - getMessages: () => { - return pmaMessages; - }, - /** - * Retrieves the globalVars array - * - * @return array - */ - getGlobalVars: () => { - return globalVariables; - }, - /** - * Retrieves the timePickerVars array - * - * @return array - */ - getTimePickerVars: () => { - return timePickerVars; - }, - /** - * Retrieves the validationVars array - * - * @return array - */ - getValidatorMessages: () => { - return validationVars; - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of messages - * - * @return void - */ - setAllMessages: (obj) => { - for (var i in obj) { - pmaMessages[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of global variables - * - * @return void - */ - setGlobalVars: (obj) => { - for (var i in obj) { - globalVariables[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array of timepicker edits - * - * @return void - */ - setTimePickerVars: (obj) => { - for (var i in obj) { - timePickerVars[i] = obj[i]; - } - }, - /** - * Saves the key value pair provided in input - * - * @param obj array The input array jQuery validation edits - * - * @return void - */ - setValidatorMessages: (obj) => { - for (var i in obj) { - validationVars[i] = obj[i]; - } - }, - }; -}()); + getTimePickerVars () { + return this.timePickerVars; + } + /** + * Retrieves the validationVars array + * + * @return array + */ + getValidatorMessages () { + return this.validationVars; + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of messages + * + * @return void + */ + setAllMessages (obj) { + for (var i in obj) { + this.pmaMessages[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of global variables + * + * @return void + */ + setGlobalVars (obj) { + for (var i in obj) { + this.globalVariables[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array of timepicker edits + * + * @return void + */ + setTimePickerVars (obj) { + for (var i in obj) { + this.timePickerVars[i] = obj[i]; + } + } + /** + * Saves the key value pair provided in input + * + * @param obj array The input array jQuery validation edits + * + * @return void + */ + setValidatorMessages (obj) { + for (var i in obj) { + this.validationVars[i] = obj[i]; + } + } +} + +/** + * @type {Object} Variables + */ +let Variables = new PmaVariables(); + +/** + * Module export + */ +export default Variables; diff --git a/js/src/variables/import_variables.js b/js/src/variables/import_variables.js index 23baf33133..6117b02bb7 100644 --- a/js/src/variables/import_variables.js +++ b/js/src/variables/import_variables.js @@ -1,20 +1,51 @@ -import { Variables } from './global_variables'; -import { PMA_commonParams } from './common_params'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ -var jqueryValidations = { - validationFormat: window.validateFormat, - validationMessage: window.validationMessage -}; +/** + * Module Imports + */ +import Variables from './global_variables'; +import CommonParams from './common_params'; + +/** + * Importing message strings from window of document which need + * to be used in the files for messages. + * + * @argument {hash} window.PMA_messages + */ Variables.setAllMessages(window.PMA_messages); + +/** + * Importing time and date rrelated strings like day, date, time + * etc for using with different languages. + * + * @argument {hash} window.timePicker + */ Variables.setTimePickerVars({ datePicker: window.datePicker, timePicker: window.timePicker }); -Variables.setValidatorMessages(jqueryValidations); + +/** + * Importing validation strings for jQuery validations for diifferent. + * language validations. + * + * @argument {hash} Object + */ +Variables.setValidatorMessages({ + validateFormat: window.validateFormat, + validationMessage: window.validationMessage +}); + +/** + * Importing global variable from window for theme and doc template. + * + * @argument {hash} window.globalVars + */ Variables.setGlobalVars(window.globalVars); /** - * This statement to be placed in the file going to be - * executed firstly like functions.js + * Importing common parameters like db, table, url etc + * + * @argument {hash} window.common_params */ -PMA_commonParams.setAll(window.common_params); +CommonParams.setAll(window.common_params); From c0810f98b29584ce5c2d51bf7bb0e124b2ae94e4 Mon Sep 17 00:00:00 2001 From: Piyush Vijay Date: Fri, 29 Jun 2018 23:15:01 +0530 Subject: [PATCH 2/3] Some more javascript files structured properly. Shortcut handler and page settings js files added in modular code. Signed-Off-By: Piyush Vijay --- js/src/ajax.js | 31 ++-- js/src/classes/ErrorReport.js | 4 +- js/src/classes/Server/ProcessList.js | 4 +- js/src/consts/files.js | 2 +- js/src/export.js | 86 ++++----- .../functions/Server/ServerStatusVariables.js | 63 +++++++ js/src/functions/Server/ServerVariables.js | 114 ++++++++++++ js/src/functions/export.js | 175 +++++++++--------- js/src/functions/get_image.js | 27 ++- js/src/functions/import.js | 48 +++-- js/src/functions/navigation.js | 48 ++--- js/src/functions/page_settings.js | 67 +++++++ js/src/index.js | 49 ++++- js/src/navigation.js | 24 +-- js/src/page_settings.js | 49 +++++ js/src/server_databases.js | 42 +++-- js/src/server_privileges.js | 129 +++++++------ js/src/shortcuts_handler.js | 112 +++++++++++ js/src/utils/Sanitise.js | 28 ++- js/src/utils/config.js | 113 +++++++++++ js/src/utils/password.js | 132 ++++++++----- js/src/utils/show_ajax_messages.js | 53 ++++-- js/src/utils/sprintf.js | 14 +- libraries/classes/Header.php | 5 +- 24 files changed, 1079 insertions(+), 340 deletions(-) create mode 100644 js/src/functions/Server/ServerStatusVariables.js create mode 100644 js/src/functions/Server/ServerVariables.js create mode 100644 js/src/functions/page_settings.js create mode 100644 js/src/page_settings.js create mode 100644 js/src/shortcuts_handler.js create mode 100644 js/src/utils/config.js diff --git a/js/src/ajax.js b/js/src/ajax.js index 0080d6f1ec..a07932eebf 100644 --- a/js/src/ajax.js +++ b/js/src/ajax.js @@ -1,12 +1,20 @@ -import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { PMA_ajaxShowMessage, + PMA_ajaxRemoveMessage +} from './utils/show_ajax_messages'; import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_commonParams } from './variables/common_params'; +import CommonParams from './variables/common_params'; import { jQuery as $ } from './utils/JqueryExtended'; import { PMA_getImage } from './functions/get_image'; -import { PMA_ensureNaviSettings, PMA_reloadNavigation, - PMA_disableNaviSettings } from './functions/navigation'; +import { PMA_ensureNaviSettings, + PMA_reloadNavigation, + PMA_disableNaviSettings +} from './functions/navigation'; import { isStorageSupported } from './functions/config'; - /** * This object handles ajax requests for pages. It also * handles the reloading of the main menu and scripts. @@ -312,7 +320,7 @@ export let AJAX = { $('html, body').animate({ scrollTop: 0 }, 'fast'); var url = isLink ? href : $(this).attr('action'); - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); var params = 'ajax_request=true' + argsep + 'ajax_page_request=true'; var dataPost = AJAX.source.getPostData(); if (! isLink) { @@ -461,7 +469,7 @@ export let AJAX = { $('#selflink').find('> a').attr('href', data._selflink); } if (data._params) { - PMA_commonParams.setAll(data._params); + CommonParams.setAll(data._params); } if (data._scripts) { AJAX.scriptHandler.load(data._scripts); @@ -590,7 +598,8 @@ export let AJAX = { if (checkNewCode(file)) { var fileImports = ['server_privileges', 'server_databases', 'error_report', 'navigation', 'server_status_advisor', 'server_status_processes', 'server_status_variables', 'server_plugins', 'server_status_sorter', 'server_status_queries', - 'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config' + 'server_status_monitor', 'server_variables', 'server_user_groups', 'replication', 'export', 'import', 'config', + 'page_settings', 'shortcuts_handler' ]; if ($.inArray(file, fileImports) !== -1) { // Dynamic import to load the files dynamically @@ -638,10 +647,10 @@ export let AJAX = { // Clear loaded scripts if they are from another version of phpMyAdmin. // Depends on common params being set before loading scripts in responseHandler if (self._scriptsVersion === null) { - self._scriptsVersion = PMA_commonParams.get('PMA_VERSION'); - } else if (self._scriptsVersion !== PMA_commonParams.get('PMA_VERSION')) { + self._scriptsVersion = CommonParams.get('PMA_VERSION'); + } else if (self._scriptsVersion !== CommonParams.get('PMA_VERSION')) { self._scripts = []; - self._scriptsVersion = PMA_commonParams.get('PMA_VERSION'); + self._scriptsVersion = CommonParams.get('PMA_VERSION'); } self._scriptsCompleted = false; self._scriptsToBeFired = []; diff --git a/js/src/classes/ErrorReport.js b/js/src/classes/ErrorReport.js index 87fd2caa2a..b490544ceb 100644 --- a/js/src/classes/ErrorReport.js +++ b/js/src/classes/ErrorReport.js @@ -4,7 +4,7 @@ */ import { AJAX } from '../ajax'; import { PMA_Messages as PMA_messages } from '../variables/export_variables'; -import { PMA_commonParams } from '../variables/common_params'; +import CommonParams from '../variables/common_params'; import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages'; import { PMA_getImage } from '../functions/get_image'; import TraceKit from 'tracekit'; @@ -45,7 +45,7 @@ var ErrorReport = { ErrorReport._last_exception = exception; $.get('error_report.php', { ajax_request: true, - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), get_settings: true, exception_type: 'js' }, function (data) { diff --git a/js/src/classes/Server/ProcessList.js b/js/src/classes/Server/ProcessList.js index dc730aac86..1a730f9423 100644 --- a/js/src/classes/Server/ProcessList.js +++ b/js/src/classes/Server/ProcessList.js @@ -1,7 +1,7 @@ import { PMA_ajaxShowMessage } from '../../utils/show_ajax_messages'; import { PMA_highlightSQL } from '../../utils/sql'; import { PMA_Messages as PMA_messages } from '../../variables/export_variables'; -import { PMA_commonParams } from '../../variables/common_params'; +import CommonParams from '../../variables/common_params'; import { PMA_getImage } from '../../functions/get_image'; import { escapeHtml } from '../../utils/Sanitise'; import { jQuery as $ } from '../../utils/JqueryExtended'; @@ -35,7 +35,7 @@ class ProcessList { this.setRefreshLabel(); if (this.refreshUrl === null) { this.refreshUrl = 'server_status_processes.php' + - PMA_commonParams.get('common_query'); + CommonParams.get('common_query'); } if (this.refreshInterval === null) { this.refreshInterval = $('#id_refreshRate').val(); diff --git a/js/src/consts/files.js b/js/src/consts/files.js index 19c8bdd002..083a0a1f78 100644 --- a/js/src/consts/files.js +++ b/js/src/consts/files.js @@ -7,7 +7,7 @@ * @type {Object} files */ const files = { - global: ['error_report', 'navigation', 'config'], + global: ['error_report', 'config', 'navigation', 'page_settings', 'shortcuts_handler'], server_privileges: ['server_privileges'], server_databases: ['server_databases'], server_status_advisor: ['server_status_advisor'], diff --git a/js/src/export.js b/js/src/export.js index a0724010c8..bfc3642e05 100644 --- a/js/src/export.js +++ b/js/src/export.js @@ -7,21 +7,21 @@ import { loadTemplate, updateTemplate, deleteTemplate, - toggle_save_to_file, - toggle_structure_data_opts, - check_table_select_all, + toggleSaveToFile, + toggleStructureDataOpts, + checkTableSelectAll, handleAddProcCheckbox, - check_table_select_struture_or_data, - check_table_selected, - toggle_table_select, - toggle_table_select_all_str, - check_selected_tables, - toggle_table_select_all_data, - setup_table_structure_or_data, - toggle_quick_or_custom, - toggle_sql_include_comments, - disable_dump_some_rows_sub_options, - enable_dump_some_rows_sub_options, + checkTableSelectStrutureOrData, + checkTableSelected, + toggleTableSelect, + toggleTableSelectAllStr, + checkSelectedTables, + toggleTableSelectAllData, + setupTableStructureOrData, + toggleQuickOrCustom, + toggleSqlIncludeComments, + disableDumpSomeRowsSubOptions, + enableDumpSomeRowsSubOptions, aliasToggleRow, addAlias, createAliasModal @@ -164,8 +164,8 @@ function onloadExportTemplate () { } function onloadSaveToFile () { - toggle_save_to_file(); - $('input[type=\'radio\'][name=\'output_format\']').on('change', toggle_save_to_file); + toggleSaveToFile(); + $('input[type=\'radio\'][name=\'output_format\']').on('change', toggleSaveToFile); } function onloadExportOptions () { @@ -192,7 +192,7 @@ function onloadExportOptions () { if (forceFile === 'true') { if ($('#radio_dump_asfile').prop('checked') !== true) { $('#radio_dump_asfile').prop('checked', true); - toggle_save_to_file(); + toggleSaveToFile(); } $('#radio_view_as_text').prop('disabled', true).parent().fadeTo('fast', 0.4); } else { @@ -201,42 +201,42 @@ function onloadExportOptions () { }); $('input[type=\'radio\'][name$=\'_structure_or_data\']').on('change', function () { - toggle_structure_data_opts(); + toggleStructureDataOpts(); }); $('input[name="table_select[]"]').on('change', function () { - toggle_table_select($(this).closest('tr')); - check_table_select_all(); + toggleTableSelect($(this).closest('tr')); + checkTableSelectAll(); handleAddProcCheckbox(); - check_table_select_struture_or_data(); + checkTableSelectStrutureOrData(); }); $('input[name="table_structure[]"]').on('change', function () { - check_table_selected($(this).closest('tr')); - check_table_select_all(); + checkTableSelected($(this).closest('tr')); + checkTableSelectAll(); handleAddProcCheckbox(); - check_table_select_struture_or_data(); + checkTableSelectStrutureOrData(); }); $('input[name="table_data[]"]').on('change', function () { - check_table_selected($(this).closest('tr')); - check_table_select_all(); + checkTableSelected($(this).closest('tr')); + checkTableSelectAll(); handleAddProcCheckbox(); - check_table_select_struture_or_data(); + checkTableSelectStrutureOrData(); }); $('#table_structure_all').on('change', function () { - toggle_table_select_all_str(); - check_selected_tables(); + toggleTableSelectAllStr(); + checkSelectedTables(); handleAddProcCheckbox(); - check_table_select_struture_or_data(); + checkTableSelectStrutureOrData(); }); $('#table_data_all').on('change', function () { - toggle_table_select_all_data(); - check_selected_tables(); + toggleTableSelectAllData(); + checkSelectedTables(); handleAddProcCheckbox(); - check_table_select_struture_or_data(); + checkTableSelectStrutureOrData(); }); if ($('input[name=\'export_type\']').val() === 'database') { @@ -274,17 +274,17 @@ function onloadExportOptions () { .parent() .fadeTo('fast', 0.4); - setup_table_structure_or_data(); + setupTableStructureOrData(); } /** * Handle force structure_or_data */ - $('#plugins').on('change', setup_table_structure_or_data); + $('#plugins').on('change', setupTableStructureOrData); } function onloadExportSubmit () { - $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggle_quick_or_custom); + $('input[type=\'radio\'][name=\'quick_or_custom\']').on('change', toggleQuickOrCustom); $('#scroll_to_options_msg').hide(); $('#format_specific_opts').find('div.format_specific_options') @@ -296,25 +296,25 @@ function onloadExportSubmit () { }) .find('h3') .remove(); - toggle_quick_or_custom(); - toggle_structure_data_opts(); - toggle_sql_include_comments(); - check_table_select_all(); + toggleQuickOrCustom(); + toggleStructureDataOpts(); + toggleSqlIncludeComments(); + checkTableSelectAll(); handleAddProcCheckbox(); /** * Initially disables the "Dump some row(s)" sub-options */ - disable_dump_some_rows_sub_options(); + disableDumpSomeRowsSubOptions(); /** * Disables the "Dump some row(s)" sub-options when it is not selected */ $('input[type=\'radio\'][name=\'allrows\']').on('change', function () { if ($('input[type=\'radio\'][name=\'allrows\']').prop('checked')) { - enable_dump_some_rows_sub_options(); + enableDumpSomeRowsSubOptions(); } else { - disable_dump_some_rows_sub_options(); + disableDumpSomeRowsSubOptions(); } }); diff --git a/js/src/functions/Server/ServerStatusVariables.js b/js/src/functions/Server/ServerStatusVariables.js new file mode 100644 index 0000000000..f270602ef4 --- /dev/null +++ b/js/src/functions/Server/ServerStatusVariables.js @@ -0,0 +1,63 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Filters the status variables by name/category/alert in the variables tab + * + * @access public + * + * @param {Object} textFilter Regular expression for filtering text + * + * @param {boolean} alertFilter For filtering alert variables + * + * @param {string} categoryFilter + * + * @param {string} text Text based filtering +*/ +function filterVariables ( + textFilter, + alertFilter, + categoryFilter, + text +) { + var usefulLinks = 0; + var section = text; + + if (categoryFilter.length > 0) { + section = categoryFilter; + } + + if (section.length > 1) { + $('#linkSuggestions').find('span').each(function () { + if ($(this).attr('class').indexOf('status_' + section) !== -1) { + usefulLinks++; + $(this).css('display', ''); + } else { + $(this).css('display', 'none'); + } + }); + } + + if (usefulLinks > 0) { + $('#linkSuggestions').css('display', ''); + } else { + $('#linkSuggestions').css('display', 'none'); + } + + $('#serverstatusvariables').find('th.name').each(function () { + if ((textFilter === null || textFilter.exec($(this).text())) && + (! alertFilter || $(this).next().find('span.attention').length > 0) && + (categoryFilter.length === 0 || $(this).parent().hasClass('s_' + categoryFilter)) + ) { + $(this).parent().css('display', ''); + } else { + $(this).parent().css('display', 'none'); + } + }); +} + +/** + * Module export + */ +export { + filterVariables +}; diff --git a/js/src/functions/Server/ServerVariables.js b/js/src/functions/Server/ServerVariables.js new file mode 100644 index 0000000000..77b5442d66 --- /dev/null +++ b/js/src/functions/Server/ServerVariables.js @@ -0,0 +1,114 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { PMA_Messages as messages } from '../../variables/export_variables'; +import { + PMA_ajaxShowMessage, + PMA_ajaxRemoveMessage +} from '../../utils/show_ajax_messages'; + +/** + * Allows the user to edit a server variable + * + * @param {Element} link Edit button element + * + * @param {Element} $saveLink Save button element + * + * @param {Element} $cancelLink Cancel button element + * + * @return {void} + */ +function editVariable (link, $saveLink, $cancelLink) { + var $link = $(link); + var $cell = $link.parent(); + var $valueCell = $link.parents('.var-row').find('.var-value'); + var varName = $link.data('variable'); + var $mySaveLink = $saveLink.clone().css('display', 'inline-block'); + var $myCancelLink = $cancelLink.clone().css('display', 'inline-block'); + var $msgbox = PMA_ajaxShowMessage(); + var $myEditLink = $cell.find('a.editLink'); + + $cell.addClass('edit'); // variable is being edited + $myEditLink.remove(); // remove edit link + + $mySaveLink.on('click', function () { + var $msgbox = PMA_ajaxShowMessage(messages.strProcessingRequest); + $.post($(this).attr('href'), { + ajax_request: true, + type: 'setval', + varName: varName, + varValue: $valueCell.find('input').val() + }, function (data) { + if (data.success) { + $valueCell + .html(data.variable) + .data('content', data.variable); + PMA_ajaxRemoveMessage($msgbox); + } else { + if (data.error === '') { + PMA_ajaxShowMessage(messages.strRequestFailed, false); + } else { + PMA_ajaxShowMessage(data.error, false); + } + $valueCell.html($valueCell.data('content')); + } + $cell.removeClass('edit').html($myEditLink); + }); + return false; + }); + + $myCancelLink.on('click', function () { + $valueCell.html($valueCell.data('content')); + $cell.removeClass('edit').html($myEditLink); + return false; + }); + + $.get($mySaveLink.attr('href'), { + ajax_request: true, + type: 'getval', + varName: varName + }, function (data) { + if (typeof data !== 'undefined' && data.success === true) { + var $links = $('
') + .append($myCancelLink) + .append('   ') + .append($mySaveLink); + var $editor = $('
', { 'class': 'serverVariableEditor' }) + .append( + $('
').append( + $('', { type: 'text' }).val(data.message) + ) + ); + // Save and replace content + $cell + .html($links) + .children() + .css('display', 'flex'); + $valueCell + .data('content', $valueCell.html()) + .html($editor) + .find('input') + .focus() + .on('keydown', function (event) { // Keyboard shortcuts + if (event.keyCode === 13) { // Enter key + $mySaveLink.trigger('click'); + } else if (event.keyCode === 27) { // Escape key + $myCancelLink.trigger('click'); + } + }); + PMA_ajaxRemoveMessage($msgbox); + } else { + $cell.removeClass('edit').html($myEditLink); + PMA_ajaxShowMessage(data.error); + } + }); +} + +/** + * Module export + */ +export { + editVariable +}; diff --git a/js/src/functions/export.js b/js/src/functions/export.js index 8b25b2590c..1ac461e32d 100644 --- a/js/src/functions/export.js +++ b/js/src/functions/export.js @@ -1,3 +1,6 @@ +import { PMA_ajaxShowMessage } from '../utils/show_ajax_messages'; +import { PMA_Messages as messages } from '../variables/export_variables'; +import CommonParams from '../variables/common_params'; /** * Functions used in the export tab * @@ -5,7 +8,7 @@ /** * Disables the "Dump some row(s)" sub-options */ -export function disable_dump_some_rows_sub_options () { +export function disableDumpSomeRowsSubOptions () { $('label[for=\'limit_to\']').fadeTo('fast', 0.4); $('label[for=\'limit_from\']').fadeTo('fast', 0.4); $('input[type=\'text\'][name=\'limit_to\']').prop('disabled', 'disabled'); @@ -15,7 +18,7 @@ export function disable_dump_some_rows_sub_options () { /** * Enables the "Dump some row(s)" sub-options */ -export function enable_dump_some_rows_sub_options () { +export function enableDumpSomeRowsSubOptions () { $('label[for=\'limit_to\']').fadeTo('fast', 1); $('label[for=\'limit_from\']').fadeTo('fast', 1); $('input[type=\'text\'][name=\'limit_to\']').prop('disabled', ''); @@ -71,9 +74,9 @@ export function createTemplate (name) { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), - db : PMA_commonParams.get('db'), - table : PMA_commonParams.get('table'), + server : CommonParams.get('server'), + db : CommonParams.get('db'), + table : CommonParams.get('table'), exportType : $('input[name="export_type"]').val(), templateAction : 'create', templateName : name, @@ -90,7 +93,7 @@ export function createTemplate (name) { $(this).prop('selected', true); } }); - PMA_ajaxShowMessage(PMA_messages.strTemplateCreated); + PMA_ajaxShowMessage(messages.strTemplateCreated); } else { PMA_ajaxShowMessage(response.error, false); } @@ -105,9 +108,9 @@ export function createTemplate (name) { export function loadTemplate (id) { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), - db : PMA_commonParams.get('db'), - table : PMA_commonParams.get('table'), + server : CommonParams.get('server'), + db : CommonParams.get('db'), + table : CommonParams.get('table'), exportType : $('input[name="export_type"]').val(), templateAction : 'load', templateId : id, @@ -137,7 +140,7 @@ export function loadTemplate (id) { } }); $('input[name="template_id"]').val(id); - PMA_ajaxShowMessage(PMA_messages.strTemplateLoaded); + PMA_ajaxShowMessage(messages.strTemplateLoaded); } else { PMA_ajaxShowMessage(response.error, false); } @@ -154,9 +157,9 @@ export function updateTemplate (id) { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), - db : PMA_commonParams.get('db'), - table : PMA_commonParams.get('table'), + server : CommonParams.get('server'), + db : CommonParams.get('db'), + table : CommonParams.get('table'), exportType : $('input[name="export_type"]').val(), templateAction : 'update', templateId : id, @@ -166,7 +169,7 @@ export function updateTemplate (id) { PMA_ajaxShowMessage(); $.post('tbl_export.php', params, function (response) { if (response.success === true) { - PMA_ajaxShowMessage(PMA_messages.strTemplateUpdated); + PMA_ajaxShowMessage(messages.strTemplateUpdated); } else { PMA_ajaxShowMessage(response.error, false); } @@ -181,9 +184,9 @@ export function updateTemplate (id) { export function deleteTemplate (id) { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), - db : PMA_commonParams.get('db'), - table : PMA_commonParams.get('table'), + server : CommonParams.get('server'), + db : CommonParams.get('db'), + table : CommonParams.get('table'), exportType : $('input[name="export_type"]').val(), templateAction : 'delete', templateId : id, @@ -193,22 +196,22 @@ export function deleteTemplate (id) { $.post('tbl_export.php', params, function (response) { if (response.success === true) { $('#template').find('option[value="' + id + '"]').remove(); - PMA_ajaxShowMessage(PMA_messages.strTemplateDeleted); + PMA_ajaxShowMessage(messages.strTemplateDeleted); } else { PMA_ajaxShowMessage(response.error, false); } }); } -export function setup_table_structure_or_data () { +export function setupTableStructureOrData () { if ($('input[name=\'export_type\']').val() !== 'database') { return; } var pluginName = $('#plugins').find('option:selected').val(); var formElemName = pluginName + '_structure_or_data'; - var force_structure_or_data = !($('input[name=\'' + formElemName + '_default\']').length); + var forceStructureOrData = !($('input[name=\'' + formElemName + '_default\']').length); - if (force_structure_or_data === true) { + if (forceStructureOrData === true) { $('input[name="structure_or_data_forced"]').val(1); $('.export_structure input[type="checkbox"], .export_data input[type="checkbox"]') .prop('disabled', true); @@ -219,16 +222,16 @@ export function setup_table_structure_or_data () { .prop('disabled', false); $('.export_structure, .export_data').fadeTo('fast', 1); - var structure_or_data = $('input[name="' + formElemName + '_default"]').val(); + var structureOrData = $('input[name="' + formElemName + '_default"]').val(); - if (structure_or_data === 'structure') { + if (structureOrData === 'structure') { $('.export_data input[type="checkbox"]') .prop('checked', false); - } else if (structure_or_data === 'data') { + } else if (structureOrData === 'data') { $('.export_structure input[type="checkbox"]') .prop('checked', false); } - if (structure_or_data === 'structure' || structure_or_data === 'structure_and_data') { + if (structureOrData === 'structure' || structureOrData === 'structure_and_data') { if (!$('.export_structure input[type="checkbox"]:checked').length) { $('input[name="table_select[]"]:checked') .closest('tr') @@ -236,7 +239,7 @@ export function setup_table_structure_or_data () { .prop('checked', true); } } - if (structure_or_data === 'data' || structure_or_data === 'structure_and_data') { + if (structureOrData === 'data' || structureOrData === 'structure_and_data') { if (!$('.export_data input[type="checkbox"]:checked').length) { $('input[name="table_select[]"]:checked') .closest('tr') @@ -245,9 +248,9 @@ export function setup_table_structure_or_data () { } } - check_selected_tables(); - check_table_select_all(); - check_table_select_struture_or_data(); + checkSelectedTables(); + checkTableSelectAll(); + checkTableSelectStrutureOrData(); } } @@ -255,7 +258,7 @@ export function setup_table_structure_or_data () { * Toggles the hiding and showing of plugin structure-specific and data-specific * options */ -export function toggle_structure_data_opts () { +export function toggleStructureDataOpts () { var pluginName = $('select#plugins').val(); var radioFormName = pluginName + '_structure_or_data'; var dataDiv = '#' + pluginName + '_data'; @@ -277,7 +280,7 @@ export function toggle_structure_data_opts () { /** * Toggles the disabling of the "save to file" options */ -export function toggle_save_to_file () { +export function toggleSaveToFile () { var $ulSaveAsfile = $('#ul_save_asfile'); if (!$('#radio_dump_asfile').prop('checked')) { $ulSaveAsfile.find('> li').fadeTo('fast', 0.4); @@ -293,7 +296,7 @@ export function toggle_save_to_file () { /** * For SQL plugin, toggles the disabling of the "display comments" options */ -export function toggle_sql_include_comments () { +export function toggleSqlIncludeComments () { $('#checkbox_sql_include_comments').on('change', function () { var $ulIncludeComments = $('#ul_include_comments'); if (!$('#checkbox_sql_include_comments').prop('checked')) { @@ -311,116 +314,116 @@ export function toggle_sql_include_comments () { }); } -export function check_table_select_all () { +export function checkTableSelectAll () { var total = $('input[name="table_select[]"]').length; - var str_checked = $('input[name="table_structure[]"]:checked').length; - var data_checked = $('input[name="table_data[]"]:checked').length; - var str_all = $('#table_structure_all'); - var data_all = $('#table_data_all'); + var strChecked = $('input[name="table_structure[]"]:checked').length; + var dataChecked = $('input[name="table_data[]"]:checked').length; + var strAll = $('#table_structure_all'); + var dataAll = $('#table_data_all'); - if (str_checked === total) { - str_all + if (strChecked === total) { + strAll .prop('indeterminate', false) .prop('checked', true); - } else if (str_checked === 0) { - str_all + } else if (strChecked === 0) { + strAll .prop('indeterminate', false) .prop('checked', false); } else { - str_all + strAll .prop('indeterminate', true) .prop('checked', false); } - if (data_checked === total) { - data_all + if (dataChecked === total) { + dataAll .prop('indeterminate', false) .prop('checked', true); - } else if (data_checked === 0) { - data_all + } else if (dataChecked === 0) { + dataAll .prop('indeterminate', false) .prop('checked', false); } else { - data_all + dataAll .prop('indeterminate', true) .prop('checked', false); } } -export function check_table_select_struture_or_data () { - var str_checked = $('input[name="table_structure[]"]:checked').length; - var data_checked = $('input[name="table_data[]"]:checked').length; - var auto_increment = $('#checkbox_sql_auto_increment'); +export function checkTableSelectStrutureOrData () { + var strChecked = $('input[name="table_structure[]"]:checked').length; + var dataChecked = $('input[name="table_data[]"]:checked').length; + var autoIncrement = $('#checkbox_sql_auto_increment'); var pluginName = $('select#plugins').val(); var dataDiv = '#' + pluginName + '_data'; var structureDiv = '#' + pluginName + '_structure'; - if (str_checked === 0) { + if (strChecked === 0) { $(structureDiv).slideUp('slow'); } else { $(structureDiv).slideDown('slow'); } - if (data_checked === 0) { + if (dataChecked === 0) { $(dataDiv).slideUp('slow'); - auto_increment.prop('disabled', true).parent().fadeTo('fast', 0.4); + autoIncrement.prop('disabled', true).parent().fadeTo('fast', 0.4); } else { $(dataDiv).slideDown('slow'); - auto_increment.prop('disabled', false).parent().fadeTo('fast', 1); + autoIncrement.prop('disabled', false).parent().fadeTo('fast', 1); } } -export function toggle_table_select_all_str () { - var str_all = $('#table_structure_all').is(':checked'); - if (str_all) { +export function toggleTableSelectAllStr () { + var strAll = $('#table_structure_all').is(':checked'); + if (strAll) { $('input[name="table_structure[]"]').prop('checked', true); } else { $('input[name="table_structure[]"]').prop('checked', false); } } -export function toggle_table_select_all_data () { - var data_all = $('#table_data_all').is(':checked'); - if (data_all) { +export function toggleTableSelectAllData () { + var dataAll = $('#table_data_all').is(':checked'); + if (dataAll) { $('input[name="table_data[]"]').prop('checked', true); } else { $('input[name="table_data[]"]').prop('checked', false); } } -export function check_selected_tables (argument) { +export function checkSelectedTables () { $('.export_table_select tbody tr').each(function () { - check_table_selected(this); + checkTableSelected(this); }); } -export function check_table_selected (row) { +export function checkTableSelected (row) { var $row = $(row); - var table_select = $row.find('input[name="table_select[]"]'); - var str_check = $row.find('input[name="table_structure[]"]'); - var data_check = $row.find('input[name="table_data[]"]'); + var tableSelect = $row.find('input[name="table_select[]"]'); + var strCheck = $row.find('input[name="table_structure[]"]'); + var dataCheck = $row.find('input[name="table_data[]"]'); - var data = data_check.is(':checked:not(:disabled)'); - var structure = str_check.is(':checked:not(:disabled)'); + var data = dataCheck.is(':checked:not(:disabled)'); + var structure = strCheck.is(':checked:not(:disabled)'); if (data && structure) { - table_select.prop({ checked: true, indeterminate: false }); + tableSelect.prop({ checked: true, indeterminate: false }); $row.addClass('marked'); } else if (data || structure) { - table_select.prop({ checked: true, indeterminate: true }); + tableSelect.prop({ checked: true, indeterminate: true }); $row.removeClass('marked'); } else { - table_select.prop({ checked: false, indeterminate: false }); + tableSelect.prop({ checked: false, indeterminate: false }); $row.removeClass('marked'); } } -export function toggle_table_select (row) { +export function toggleTableSelect (row) { var $row = $(row); - var table_selected = $row.find('input[name="table_select[]"]').is(':checked'); + var tableSelected = $row.find('input[name="table_select[]"]').is(':checked'); - if (table_selected) { + if (tableSelected) { $row.find('input[type="checkbox"]:not(:disabled)').prop('checked', true); $row.addClass('marked'); } else { @@ -442,7 +445,7 @@ export function handleAddProcCheckbox () { /** * Toggles display of options when quick and custom export are selected */ -export function toggle_quick_or_custom () { +export function toggleQuickOrCustom () { if ($('input[name=\'quick_or_custom\']').length === 0 // custom_no_form option || $('#radio_custom_export').prop('checked') // custom ) { @@ -451,8 +454,8 @@ export function toggle_quick_or_custom () { $('#output').show(); $('#format_specific_opts').show(); $('#output_quick_export').hide(); - var selected_plugin_name = $('#plugins').find('option:selected').val(); - $('#' + selected_plugin_name + '_options').show(); + var selectedPluginName = $('#plugins').find('option:selected').val(); + $('#' + selectedPluginName + '_options').show(); } else { // quick $('#databases_and_tables').hide(); $('#rows').hide(); @@ -462,12 +465,12 @@ export function toggle_quick_or_custom () { } } var time_out; -export function check_time_out (time_limit) { - if (typeof time_limit === 'undefined' || time_limit === 0) { +export function check_time_out (timeLimit) { + if (typeof timeLimit === 'undefined' || timeLimit === 0) { return true; } // margin of one second to avoid race condition to set/access session variable - time_limit = time_limit + 1; + timeLimit = timeLimit + 1; var href = 'export.php'; var params = { 'ajax_request' : true, @@ -479,13 +482,13 @@ export function check_time_out (time_limit) { if (data.message === 'timeout') { PMA_ajaxShowMessage( '
' + - PMA_messages.strTimeOutError + + messages.strTimeOutError + '
', false ); } }); - }, time_limit * 1000); + }, timeLimit * 1000); } /** @@ -534,7 +537,7 @@ export function aliasSelectHandler (event) { export function createAliasModal (event) { event.preventDefault(); var dlgButtons = {}; - dlgButtons[PMA_messages.strSaveAndClose] = function () { + dlgButtons[messages.strSaveAndClose] = function () { $(this).dialog('close'); $('#alias_modal').parent().appendTo($('form[name="dump"]')); }; @@ -546,7 +549,7 @@ export function createAliasModal (event) { buttons: dlgButtons, create: function () { $(this).css('maxHeight', $(window).height() - 150); - var db = PMA_commonParams.get('db'); + var db = CommonParams.get('db'); if (db) { var option = $(''); option.text(db); @@ -555,7 +558,7 @@ export function createAliasModal (event) { } else { var params = { ajax_request : true, - server : PMA_commonParams.get('server'), + server : CommonParams.get('server'), type: 'list-databases' }; $.post('ajax.php', params, function (response) { diff --git a/js/src/functions/get_image.js b/js/src/functions/get_image.js index 167197e84a..af11628837 100644 --- a/js/src/functions/get_image.js +++ b/js/src/functions/get_image.js @@ -1,20 +1,30 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ import { escapeHtml } from '../utils/Sanitise'; + /** * Returns an HTML IMG tag for a particular image from a theme, * which may be an actual file or an icon from a sprite * - * @param string image The name of the file to get - * @param string alternate Used to set 'alt' and 'title' attributes of the image - * @param object attributes An associative array of other attributes + * @access public * - * @return Object The requested image, this object has two methods: + * @param {string} image The name of the file to get + * + * @param {string} alternate Used to set 'alt' and 'title' attributes of the image + * + * @param {object} attributes An associative array of other attributes + * + * @return {Object} The requested image, this object has two methods: * .toString() - Returns the IMG tag for the requested image * .attr(name) - Returns a particular attribute of the IMG * tag given it's name * .attr(name, value) - Sets a particular attribute of the IMG * tag to the given value */ -export function PMA_getImage (image, alternate, attributes) { +function PMA_getImage (image, alternate, attributes) { // custom image object, it will eventually be returned by this functions var retval = { data: { @@ -76,3 +86,10 @@ export function PMA_getImage (image, alternate, attributes) { return retval; } + +/** + * Module export + */ +export { + PMA_getImage +}; diff --git a/js/src/functions/import.js b/js/src/functions/import.js index 71e4dab109..2828733c75 100644 --- a/js/src/functions/import.js +++ b/js/src/functions/import.js @@ -1,20 +1,30 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { PMA_Messages as messages } from '../variables/export_variables'; + /** * Functions used in the import tab - * */ /** * Toggles the hiding and showing of each plugin's options * according to the currently selected plugin from the dropdown list + * + * @access public + * + * @return {void} */ -export function changePluginOpts () { +function changePluginOpts () { $('#format_specific_opts').find('div.format_specific_options').each(function () { $(this).hide(); }); - var selected_plugin_name = $('#plugins').find('option:selected').val(); - $('#' + selected_plugin_name + '_options').fadeIn('slow'); - if (selected_plugin_name === 'csv') { - $('#import_notification').text(PMA_messages.strImportCSV); + var selectedPluginName = $('#plugins').find('option:selected').val(); + $('#' + selectedPluginName + '_options').fadeIn('slow'); + if (selectedPluginName === 'csv') { + $('#import_notification').text(messages.strImportCSV); } else { $('#import_notification').text(''); } @@ -23,19 +33,33 @@ export function changePluginOpts () { /** * Toggles the hiding and showing of each plugin's options and sets the selected value * in the plugin dropdown list according to the format of the selected file + * + * @access public + * + * @param {string} fname Name of the file + * + * @return {void} */ -export function matchFile (fname) { - var fname_array = fname.toLowerCase().split('.'); - var len = fname_array.length; +function matchFile (fname) { + var fnameArray = fname.toLowerCase().split('.'); + var len = fnameArray.length; if (len !== 0) { - var extension = fname_array[len - 1]; + var extension = fnameArray[len - 1]; if (extension === 'gz' || extension === 'bz2' || extension === 'zip') { len--; } // Only toggle if the format of the file can be imported - if ($('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).length === 1) { - $('select[name=\'format\'] option').filterByValue(fname_array[len - 1]).prop('selected', true); + if ($('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).length === 1) { + $('select[name=\'format\'] option').filterByValue(fnameArray[len - 1]).prop('selected', true); changePluginOpts(); } } } + +/** + * Module export + */ +export { + changePluginOpts, + matchFile +}; diff --git a/js/src/functions/navigation.js b/js/src/functions/navigation.js index 59d43e6d25..9b62c799ef 100644 --- a/js/src/functions/navigation.js +++ b/js/src/functions/navigation.js @@ -3,9 +3,12 @@ * * @returns void */ -import { PMA_commonParams } from '../variables/common_params'; +import CommonParams from '../variables/common_params'; import { setupRestoreField, setupConfigTabs, setupValidation } from './config'; - +import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from '../utils/show_ajax_messages'; +import { PMA_Messages as PMA_messages } from '../variables/export_variables'; +import { isStorageSupported } from './config'; +import { configSet, configGet } from '../utils/config'; /** * Traverse the navigation tree backwards to generate all the actual * and virtual paths, as well as the positions in the pagination at @@ -69,8 +72,8 @@ export function navTreeStateUpdate () { // content to be stored exceeds storage capacity try { storage.setItem('navTreePaths', JSON.stringify(traverseNavigationForPaths())); - storage.setItem('server', PMA_commonParams.get('server')); - storage.setItem('token', PMA_commonParams.get('token')); + storage.setItem('server', CommonParams.get('server')); + storage.setItem('token', CommonParams.get('token')); } catch (error) { // storage capacity exceeded & old navigation tree // state is no more valid, so remove it @@ -88,18 +91,17 @@ export function PMA_selectCurrentDb () { return false; } - if (PMA_commonParams.get('db')) { // db selected + if (CommonParams.get('db')) { // db selected $naviDbSelect.show(); } - $naviDbSelect.val(PMA_commonParams.get('db')); - return $naviDbSelect.val() === PMA_commonParams.get('db'); + $naviDbSelect.val(CommonParams.get('db')); + return $naviDbSelect.val() === CommonParams.get('db'); } export function PMA_showCurrentNavigation () { - var db = PMA_commonParams.get('db'); - var table = PMA_commonParams.get('table'); - + var db = CommonParams.get('db'); + var table = CommonParams.get('table'); $('#pma_navigation_tree').find('li.selected').removeClass('selected'); if (db) { var $dbItem = findLoadedItem($('#pma_navigation_tree').find('> div'), db, 'database', !table); @@ -109,7 +111,7 @@ export function PMA_showCurrentNavigation () { } // If loaded database in navigation is not same as current one if ($('#pma_navigation_tree_content').find('span.loaded_db:first').text() !== $('#navi_db_select').val()) { - loadChildNodes(false, $('option:selected', $('#navi_db_select')), function (data) { + loadChildNodes(false, $('option:selected', $('#navi_db_select')), function () { handleTableOrDb(table, $('#pma_navigation_tree_content')); var $children = $('#pma_navigation_tree_content').children('div.list_container'); $children.promise().done(navTreeStateUpdate); @@ -325,7 +327,7 @@ export function loadChildNodes (isNode, $expandElem, callback) { if (window.location.href.indexOf('?') === -1) { window.location.href += '?session_expired=1'; } else { - window.location.href += PMA_commonParams.get('arg_separator') + 'session_expired=1'; + window.location.href += CommonParams.get('arg_separator') + 'session_expired=1'; } window.location.reload(); } else { @@ -416,7 +418,7 @@ export function PMA_ensureNaviSettings (selflink) { if (!$('#pma_navigation_settings').length) { var params = { getNaviSettings: true, - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), }; var url = $('#pma_navigation').find('a.navigation_url').attr('href'); $.post(url, params, function (data) { @@ -691,7 +693,7 @@ export var PMA_fastFilter = { * at the top of this file */ events: { - focus: function (event) { + focus: function () { var $obj = $(this).closest('div.list_container'); if (! $obj.data('fastFilter')) { $obj.data( @@ -705,7 +707,7 @@ export var PMA_fastFilter = { $(this).select(); } }, - blur: function (event) { + blur: function () { if ($(this).val() === '') { $(this).val(this.defaultValue); } @@ -853,7 +855,7 @@ PMA_fastFilter.filter.prototype.request = function () { if (self.$this.find('> ul > li > form.fast_filter:first input[name=searchClause]').length === 0) { var $input = $('#pma_navigation_tree').find('li.fast_filter.db_fast_filter input.searchClause'); if ($input.length && $input.val() !== $input[0].defaultValue) { - params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val()); + params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent($input.val()); } } self.xhr = $.ajax({ @@ -1085,7 +1087,7 @@ export var ResizeHandler = function () { * * @return void */ - this.treeResize = function (event) { + this.treeResize = function () { var $nav = $('#pma_navigation'); var $nav_tree = $('#pma_navigation_tree'); var $nav_header = $('#pma_navigation_header'); @@ -1136,12 +1138,12 @@ export function PMA_reloadNavigation (callback, paths) { var params = { reload: true, no_debug: true, - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), }; paths = paths || traverseNavigationForPaths(); $.extend(params, paths); if ($('#navi_db_select').length) { - params.db = PMA_commonParams.get('db'); + params.db = CommonParams.get('db'); requestNaviReload(params); return; } @@ -1188,18 +1190,18 @@ export function PMA_navigationTreePagination ($this) { params = 'ajax_request=true'; } else { // tagName === 'SELECT' url = 'navigation.php'; - params = $this.closest('form').serialize() + PMA_commonParams.get('arg_separator') + 'ajax_request=true'; + params = $this.closest('form').serialize() + CommonParams.get('arg_separator') + 'ajax_request=true'; } var searchClause = PMA_fastFilter.getSearchClause(); if (searchClause) { - params += PMA_commonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause); + params += CommonParams.get('arg_separator') + 'searchClause=' + encodeURIComponent(searchClause); } if (isDbSelector) { - params += PMA_commonParams.get('arg_separator') + 'full=true'; + params += CommonParams.get('arg_separator') + 'full=true'; } else { var searchClause2 = PMA_fastFilter.getSearchClause2($this); if (searchClause2) { - params += PMA_commonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2); + params += CommonParams.get('arg_separator') + 'searchClause2=' + encodeURIComponent(searchClause2); } } $.post(url, params, function (data) { diff --git a/js/src/functions/page_settings.js b/js/src/functions/page_settings.js new file mode 100644 index 0000000000..ff996aac4a --- /dev/null +++ b/js/src/functions/page_settings.js @@ -0,0 +1,67 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ +import { PMA_Messages as messages } from '../variables/export_variables'; + +/** + * @param {Element} selector jQuery element for which setting need to be show + * + * @access private + * + * @returns {void} + */ +function showSettings (selector) { + var buttons = {}; + buttons[messages.strApply] = function () { + $('.config-form').submit(); + }; + + buttons[messages.strCancel] = function () { + $(this).dialog('close'); + }; + + // Keeping a clone to restore in case the user cancels the operation + var $clone = $(selector + ' .page_settings').clone(true); + $(selector) + .dialog({ + title: messages.strPageSettings, + width: 700, + minHeight: 250, + modal: true, + open: function () { + $(this).dialog('option', 'maxHeight', $(window).height() - $(this).offset().top); + }, + close: function () { + $(selector + ' .page_settings').replaceWith($clone); + }, + buttons: buttons + }); +} + +/** + * @access public + * + * @return {void} + */ +function showPageSettings () { + showSettings('#page_settings_modal'); +} + +/** + * @access public + * + * @return {void} + */ +function showNaviSettings () { + showSettings('#pma_navigation_settings'); +} + +/** + * Module export + */ +export { + showNaviSettings, + showPageSettings +}; diff --git a/js/src/index.js b/js/src/index.js index 3ba2e8f153..b6ddf95105 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -1,9 +1,22 @@ -import { AJAX } from './ajax'; +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * Module import + */ import './variables/import_variables'; -import './variables/get_config'; import { jQuery as $ } from './utils/JqueryExtended'; +import { AJAX } from './ajax'; +import './variables/get_config'; import files from './consts/files'; import Console from './console'; +import { PMA_sprintf } from './utils/sprintf'; +import { PMA_Messages as PMA_messages } from './variables/export_variables'; +import { escapeHtml } from './utils/Sanitise'; +import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; +import PMA_commonParams from './variables/common_params'; + +// console.log(PMA_messages); +// console.log(PMA_ajaxShowMessage); /** * Page load event handler @@ -69,6 +82,34 @@ $(function () { } }); +$(document).ajaxError(function (event, request, settings) { + if (AJAX._debug) { + console.log('AJAX error: status=' + request.status + ', text=' + request.statusText); + } + // Don't handle aborted requests + if (request.status !== 0 || request.statusText !== 'abort') { + var details = ''; + var state = request.state(); + + if (request.status !== 0) { + details += '
' + escapeHtml(PMA_sprintf(PMA_messages.strErrorCode, request.status)) + '
'; + } + details += '
' + escapeHtml(PMA_sprintf(PMA_messages.strErrorText, request.statusText + ' (' + state + ')')) + '
'; + if (state === 'rejected' || state === 'timeout') { + details += '
' + escapeHtml(PMA_messages.strErrorConnection) + '
'; + } + PMA_ajaxShowMessage( + '
' + + PMA_messages.strErrorProcessingRequest + + details + + '
', + false + ); + AJAX.active = false; + AJAX.xhr = null; + } +}); + /** * Adding common files for every page */ @@ -92,6 +133,10 @@ if (typeof files[firstPage] !== 'undefined' && firstPage.toLocaleLowerCase() !== for (let i in files[indexPage]) { AJAX.scriptHandler.add(files[indexPage][i], 1); } +} else if (typeof files[indexPage] !== 'undefined' && firstPage.toLocaleLowerCase() === 'index') { + for (let i in files[indexPage]) { + AJAX.scriptHandler.add(files[indexPage][i]); + } } $(function () { diff --git a/js/src/navigation.js b/js/src/navigation.js index 0095b51108..1c1df70939 100644 --- a/js/src/navigation.js +++ b/js/src/navigation.js @@ -9,7 +9,7 @@ import { expandTreeNode, PMA_reloadNavigation, PMA_navigationTreePagination } from './functions/navigation'; import { PMA_Messages as PMA_messages } from './variables/export_variables'; -import { PMA_commonParams } from './variables/common_params'; +import CommonParams from './variables/common_params'; import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage, PMA_tooltip } from './utils/show_ajax_messages'; import { isStorageSupported } from './functions/config'; @@ -74,7 +74,7 @@ $(function () { $(document).on('change', '#navi_db_select', function () { if (! $(this).val()) { - PMA_commonParams.set('db', ''); + CommonParams.set('db', ''); PMA_reloadNavigation(); } $(this).closest('form').trigger('submit'); @@ -243,7 +243,7 @@ $(function () { event.preventDefault(); var url = $(this).attr('href').substr( $(this).attr('href').indexOf('?') + 1 - ) + PMA_commonParams.get('arg_separator') + 'ajax_request=true'; + ) + CommonParams.get('arg_separator') + 'ajax_request=true'; var title = PMA_messages.strAddIndex; indexEditorDialog(url, title); }); @@ -253,7 +253,7 @@ $(function () { event.preventDefault(); var url = $(this).attr('href').substr( $(this).attr('href').indexOf('?') + 1 - ) + PMA_commonParams.get('arg_separator') + 'ajax_request=true'; + ) + CommonParams.get('arg_separator') + 'ajax_request=true'; var title = PMA_messages.strEditIndex; indexEditorDialog(url, title); }); @@ -270,9 +270,9 @@ $(function () { $.ajax({ type: 'POST', data: { - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), }, - url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true', + url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true', success: function (data) { if (typeof data !== 'undefined' && data.success === true) { PMA_reloadNavigation(); @@ -287,7 +287,7 @@ $(function () { $(document).on('click', 'a.showUnhide.ajax', function (event) { event.preventDefault(); var $msg = PMA_ajaxShowMessage(); - $.get($(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=1', function (data) { + $.get($(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=1', function (data) { if (typeof data !== 'undefined' && data.success === true) { PMA_ajaxRemoveMessage($msg); var buttonOptions = {}; @@ -321,9 +321,9 @@ $(function () { $.ajax({ type: 'POST', data: { - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), }, - url: $(this).attr('href') + PMA_commonParams.get('arg_separator') + 'ajax_request=true', + url: $(this).attr('href') + CommonParams.get('arg_separator') + 'ajax_request=true', success: function (data) { PMA_ajaxRemoveMessage($msg); if (typeof data !== 'undefined' && data.success === true) { @@ -356,7 +356,7 @@ $(function () { favorite_tables: (isStorageSupported('localStorage') && typeof window.localStorage.favorite_tables !== 'undefined') ? window.localStorage.favorite_tables : '', - server: PMA_commonParams.get('server'), + server: CommonParams.get('server'), }, success: function (data) { if (data.changes) { @@ -389,8 +389,8 @@ $(function () { typeof storage.navTreePaths === 'undefined' ) { PMA_reloadNavigation(); - } else if (PMA_commonParams.get('server') === storage.server && - PMA_commonParams.get('token') === storage.token + } else if (CommonParams.get('server').toString() === storage.server.toString() && + CommonParams.get('token').toString() === storage.token.toString() ) { // Reload the tree to the state before page refresh PMA_reloadNavigation(navFilterStateRestore, JSON.parse(storage.navTreePaths)); diff --git a/js/src/page_settings.js b/js/src/page_settings.js new file mode 100644 index 0000000000..627425d05c --- /dev/null +++ b/js/src/page_settings.js @@ -0,0 +1,49 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ + +/** + * @fileoverview function used for page-related settings + * @name Page-related settings + * + * @requires jQuery + * @requires jQueryUI + * @requires js/functions.js + */ + +/** + * Module import + */ +import { + showNaviSettings, + showPageSettings +} from './functions/page_settings'; + +/** + * @package PhpMyAdmin + * + * Page Settings + */ + +/** + * Unbind all event handlers before tearing down a page. + */ +function teardownPageSettings () { + $('#page_settings_icon').css('display', 'none'); + $('#page_settings_icon').off('click'); + $('#pma_navigation_settings_icon').off('click'); +} + +/** + * Binding event handler on page load. + */ +function onloadPageSettings () { + if ($('#page_settings_modal').length) { + $('#page_settings_icon').css('display', 'inline'); + $('#page_settings_icon').on('click', showPageSettings); + } + $('#pma_navigation_settings_icon').on('click', showNaviSettings); +} + +export { + teardownPageSettings, + onloadPageSettings +}; diff --git a/js/src/server_databases.js b/js/src/server_databases.js index af5c2c350f..f29e9f67aa 100644 --- a/js/src/server_databases.js +++ b/js/src/server_databases.js @@ -7,6 +7,10 @@ * @requires jQueryUI * @required js/functions.js */ + +/** + * Moduele import + */ import { PMA_sprintf } from './utils/sprintf'; import './variables/import_variables'; import { PMA_ajaxShowMessage } from './utils/show_ajax_messages'; @@ -14,17 +18,26 @@ import { escapeHtml } from './utils/Sanitise'; import { PMA_Messages as PMA_messages } from './variables/export_variables'; import { jQuery as $ } from './utils/JqueryExtended'; import { AJAX } from './ajax'; -import { PMA_commonParams } from './variables/common_params'; +import CommonParams from './variables/common_params'; + +/** + * @package PhpMyAdmin + * + * Server Databases + */ /** * Unbind all event handlers before tearing down a page */ -export function teardown1 () { +function teardownServerDatabases () { $(document).off('submit', '#dbStatsForm'); $(document).off('submit', '#create_database_form.ajax'); } -export function onload1 () { +/** + * Binding event handlers on page load + */ +function onloadServerDatabases () { /** * Attach Event Handler for 'Drop Databases' */ @@ -46,7 +59,7 @@ export function onload1 () { if (! selected_dbs.length) { PMA_ajaxShowMessage( $('
').text( - PMA_messages.strNoDatabasesSelected + messages.strNoDatabasesSelected ), 2000 ); @@ -55,16 +68,16 @@ export function onload1 () { /** * @var question String containing the question to be asked for confirmation */ - var question = PMA_messages.strDropDatabaseStrongWarning + ' ' + - PMA_sprintf(PMA_messages.strDoYouReally, selected_dbs.join('
')); + var question = messages.strDropDatabaseStrongWarning + ' ' + + PMA_sprintf(messages.strDoYouReally, selected_dbs.join('
')); - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); $(this).PMA_confirm( question, $form.prop('action') + '?' + $(this).serialize() + argsep + 'drop_selected_dbs=1' + argsep + 'is_js_confirmed=1' + argsep + 'ajax_request=true', function (url) { - PMA_ajaxShowMessage(PMA_messages.strProcessingRequest, false); + PMA_ajaxShowMessage(messages.strProcessingRequest, false); var params = getJSConfirmCommonParam(this); @@ -105,12 +118,12 @@ export function onload1 () { var newDbNameInput = $form.find('input[name=new_db]'); if (newDbNameInput.val() === '') { newDbNameInput.focus(); - alert(PMA_messages.strFormEmpty); + alert(messages.strFormEmpty); return; } // end remove - PMA_ajaxShowMessage(PMA_messages.strProcessingRequest); + PMA_ajaxShowMessage(messages.strProcessingRequest); PMA_prepareForAjaxRequest($form); $.post($form.attr('action'), $form.serialize(), function (data) { @@ -125,7 +138,7 @@ export function onload1 () { // make ajax request to load db structure page - taken from ajax.js var dbStruct_url = data.url_query; dbStruct_url = dbStruct_url.replace(/amp;/ig, ''); - var params = 'ajax_request=true' + PMA_commonParams.get('arg_separator') + 'ajax_page_request=true'; + var params = 'ajax_request=true' + CommonParams.get('arg_separator') + 'ajax_page_request=true'; if (! (history && history.pushState)) { params += PMA_MicroHistory.menus.getRequestParam(); } @@ -143,9 +156,14 @@ export function onload1 () { } var tableRows = $('.server_databases'); - $.each(tableRows, function (index, item) { + $.each(tableRows, function (index) { $(this).click(function () { PMA_commonActions.setDb($(this).attr('data')); }); }); } + +export { + teardownServerDatabases, + onloadServerDatabases +}; diff --git a/js/src/server_privileges.js b/js/src/server_privileges.js index eca080c5c0..e1fe4a6728 100644 --- a/js/src/server_privileges.js +++ b/js/src/server_privileges.js @@ -6,17 +6,25 @@ * @requires jQuery * @requires jQueryUI * @requires js/functions.js - * + */ + +/** + * Module import */ import { PMA_sprintf } from './utils/sprintf'; import { checkPasswordStrength, displayPasswordGenerateButton } from './utils/password'; -// import { AJAX } from './ajax'; -import { PMA_Messages as PMA_messages } from './variables/export_variables'; +import { PMA_Messages as messages } from './variables/export_variables'; import { PMA_ajaxShowMessage, PMA_ajaxRemoveMessage } from './utils/show_ajax_messages'; -import { PMA_commonParams } from './variables/common_params'; +import CommonParams from './variables/common_params'; import { jQuery as $ } from './utils/JqueryExtended'; import { PMA_getSQLEditor } from './utils/sql'; +/** + * @package PhpMyAdmin + * + * Server Privileges + */ + /** * AJAX scripts for server_privileges page. * @@ -33,9 +41,9 @@ import { PMA_getSQLEditor } from './utils/sql'; */ /** - * Unbind all event handlers before tearing down a page + * Unbind all event handlers before tearing down a page. */ -export function teardown1 () { +function teardownServerPrivileges () { $('#fieldset_add_user_login').off('change', 'input[name=\'username\']'); $(document).off('click', '#fieldset_delete_user_footer #buttonGo.ajax'); $(document).off('click', 'a.edit_user_group_anchor.ajax'); @@ -49,7 +57,10 @@ export function teardown1 () { $(document).off('change', '#select_authentication_plugin'); } -export function onload1 () { +/** + * Binding event handlers on page load. + */ +function onloadServerPrivileges () { /** * Display a warning if there is already a user by the name entered as the username. */ @@ -60,7 +71,7 @@ export function onload1 () { var href = $('form[name=\'usersForm\']').attr('action'); var params = { 'ajax_request' : true, - 'server' : PMA_commonParams.get('server'), + 'server' : CommonParams.get('server'), 'validate_username' : true, 'username' : username }; @@ -79,29 +90,29 @@ export function onload1 () { /** * Indicating password strength */ - var meter_obj; - var meter_obj_label; + var meterObj; + var meterObjLabel; var username; $(document).on('keyup', '#text_pma_pw', function () { - meter_obj = $('#password_strength_meter'); - meter_obj_label = $('#password_strength'); + meterObj = $('#password_strength_meter'); + meterObjLabel = $('#password_strength'); username = $('input[name="username"]'); username = username.val(); - checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, username); + checkPasswordStrength($(this).val(), meterObj, meterObjLabel, username); }); $(document).on('keyup', '#text_pma_change_pw', function () { - meter_obj = $('#change_password_strength_meter'); - meter_obj_label = $('#change_password_strength'); - checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, PMA_commonParams.get('user')); + meterObj = $('#change_password_strength_meter'); + meterObjLabel = $('#change_password_strength'); + checkPasswordStrength($(this).val(), meterObj, meterObjLabel, CommonParams.get('user')); }); /** * Display a notice if sha256_password is selected */ $(document).on('change', '#select_authentication_plugin', function () { - var selected_plugin = $(this).val(); - if (selected_plugin === 'sha256_password') { + var selectedPlugin = $(this).val(); + if (selectedPlugin === 'sha256_password') { $('#ssl_reqd_warning').show(); } else { $('#ssl_reqd_warning').hide(); @@ -121,19 +132,19 @@ export function onload1 () { var $thisButton = $(this); var $form = $('#usersForm'); - $thisButton.PMA_confirm(PMA_messages.strDropUserWarning, $form.attr('action'), function (url) { - var $drop_users_db_checkbox = $('#checkbox_drop_users_db'); - if ($drop_users_db_checkbox.is(':checked')) { - var is_confirmed = confirm(PMA_messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE')); - if (! is_confirmed) { + $thisButton.PMA_confirm(messages.strDropUserWarning, $form.attr('action'), function (url) { + var $dropUsersDbCheckbox = $('#checkbox_drop_users_db'); + if ($dropUsersDbCheckbox.is(':checked')) { + var isConfirmed = confirm(messages.strDropDatabaseStrongWarning + '\n' + PMA_sprintf(messages.strDoYouReally, 'DROP DATABASE')); + if (! isConfirmed) { // Uncheck the drop users database checkbox - $drop_users_db_checkbox.prop('checked', false); + $dropUsersDbCheckbox.prop('checked', false); } } - PMA_ajaxShowMessage(PMA_messages.strRemovingSelectedUsers); + PMA_ajaxShowMessage(messages.strRemovingSelectedUsers); - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); $.post(url, $form.serialize() + argsep + 'delete=' + $thisButton.val() + argsep + 'ajax_request=true', function (data) { if (typeof data !== 'undefined' && data.success === true) { PMA_ajaxShowMessage(data.message); @@ -144,12 +155,12 @@ export function onload1 () { } // Remove the revoked user from the users list $form.find('input:checkbox:checked').parents('tr').slideUp('medium', function () { - var this_user_initial = $(this).find('input:checkbox').val().charAt(0).toUpperCase(); + var thisUserInitial = $(this).find('input:checkbox').val().charAt(0).toUpperCase(); $(this).remove(); - // If this is the last user with this_user_initial, remove the link from #initials_table - if ($('#tableuserrights').find('input:checkbox[value^="' + this_user_initial + '"], input:checkbox[value^="' + this_user_initial.toLowerCase() + '"]').length === 0) { - $('#initials_table').find('td > a:contains(' + this_user_initial + ')').parent('td').html(this_user_initial); + // If this is the last user with thisUserInitial, remove the link from #initials_table + if ($('#tableuserrights').find('input:checkbox[value^="' + thisUserInitial + '"], input:checkbox[value^="' + thisUserInitial.toLowerCase() + '"]').length === 0) { + $('#initials_table').find('td > a:contains(' + thisUserInitial + ')').parent('td').html(thisUserInitial); } // Re-check the classes of each row @@ -184,12 +195,12 @@ export function onload1 () { if (typeof data !== 'undefined' && data.success === true) { PMA_ajaxRemoveMessage($msg); var buttonOptions = {}; - buttonOptions[PMA_messages.strGo] = function () { + buttonOptions[messages.strGo] = function () { var usrGroup = $('#changeUserGroupDialog') .find('select[name="userGroup"]') .val(); var $message = PMA_ajaxShowMessage(); - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); $.post( 'server_privileges.php', $('#changeUserGroupDialog').find('form').serialize() + argsep + 'ajax_request=1', @@ -211,7 +222,7 @@ export function onload1 () { ); $(this).dialog('close'); }; - buttonOptions[PMA_messages.strClose] = function () { + buttonOptions[messages.strClose] = function () { $(this).dialog('close'); }; var $dialog = $('
') @@ -249,15 +260,15 @@ export function onload1 () { event.preventDefault(); // can't export if no users checked if ($(this.form).find('input:checked').length === 0) { - PMA_ajaxShowMessage(PMA_messages.strNoAccountSelected, 2000, 'success'); + PMA_ajaxShowMessage(messages.strNoAccountSelected, 2000, 'success'); return; } var $msgbox = PMA_ajaxShowMessage(); - var button_options = {}; - button_options[PMA_messages.strClose] = function () { + var buttonOptions = {}; + buttonOptions[messages.strClose] = function () { $(this).dialog('close'); }; - var argsep = PMA_commonParams.get('arg_separator'); + var argsep = CommonParams.get('arg_separator'); $.post( $(this.form).prop('action'), $(this.form).serialize() + argsep + 'submit_mult=export' + argsep + 'ajax_request=true', @@ -268,7 +279,7 @@ export function onload1 () { .dialog({ title: data.title, width: 500, - buttons: button_options, + buttons: buttonOptions, close: function () { $(this).remove(); } @@ -289,10 +300,10 @@ export function onload1 () { event.preventDefault(); var $msgbox = PMA_ajaxShowMessage(); /** - * @var button_options Object containing options for jQueryUI dialog buttons + * @var buttonOptions Object containing options for jQueryUI dialog buttons */ - var button_options = {}; - button_options[PMA_messages.strClose] = function () { + var buttonOptions = {}; + buttonOptions[messages.strClose] = function () { $(this).dialog('close'); }; $.get($(this).attr('href'), { 'ajax_request': true }, function (data) { @@ -302,7 +313,7 @@ export function onload1 () { .dialog({ title: data.title, width: 500, - buttons: button_options, + buttons: buttonOptions, close: function () { $(this).remove(); } @@ -346,7 +357,7 @@ export function onload1 () { }); // end $.get }); // end of the paginate users table - $(document).on('change', 'input[name="ssl_type"]', function (e) { + $(document).on('change', 'input[name="ssl_type"]', function () { var $div = $('#specified_div'); if ($('#ssl_type_SPECIFIED').is(':checked')) { $div.find('input').prop('disabled', false); @@ -355,7 +366,7 @@ export function onload1 () { } }); - $(document).on('change', '#checkbox_SSL_priv', function (e) { + $(document).on('change', '#checkbox_SSL_priv', function () { var $div = $('#require_ssl_div'); if ($(this).is(':checked')) { $div.find('input').prop('disabled', false); @@ -372,10 +383,10 @@ export function onload1 () { */ var addOrUpdateSubmenu = function () { var $topmenu2 = $('#topmenu2'); - var $edit_user_dialog = $('#edit_user_dialog'); - var submenu_label; - var submenu_link; - var link_number; + var $editUserDialog = $('#edit_user_dialog'); + var submenuLabel; + var submenuLink; + var linkNumber; // if submenu exists yet, remove it first if ($topmenu2.length > 0) { @@ -386,14 +397,14 @@ export function onload1 () { $topmenu2 = $('