From 583643308af1bf6b7976c814e9eed66edfcdbfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 23 Mar 2022 20:15:36 -0300 Subject: [PATCH 1/2] Move `js/src/console.js` to `js/src/modules/console.js` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- js/src/{ => modules}/console.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename js/src/{ => modules}/console.js (100%) diff --git a/js/src/console.js b/js/src/modules/console.js similarity index 100% rename from js/src/console.js rename to js/src/modules/console.js From 642762c9b828daed42ba3af2f889cf8e13bd068d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maur=C3=ADcio=20Meneghini=20Fauth?= Date: Wed, 23 Mar 2022 20:20:44 -0300 Subject: [PATCH 2/2] Extract `console.js` objects into `console` module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MaurĂ­cio Meneghini Fauth --- .eslintrc.json | 4 ++++ js/src/console.js | 6 ++++++ js/src/modules/console.js | 33 +++++++++++++++------------------ js/src/shortcuts_handler.js | 8 +++----- libraries/classes/Footer.php | 2 +- webpack.config.js | 4 ++++ 6 files changed, 33 insertions(+), 24 deletions(-) create mode 100644 js/src/console.js diff --git a/.eslintrc.json b/.eslintrc.json index 46b6bd9141..434ea753cb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,6 +5,10 @@ "plugin:compat/recommended" ], "plugins": ["no-jquery"], + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, "env": { "browser": true, "es6": true, diff --git a/js/src/console.js b/js/src/console.js new file mode 100644 index 0000000000..a132c334da --- /dev/null +++ b/js/src/console.js @@ -0,0 +1,6 @@ +import $ from 'jquery'; +import { Console } from './modules/console.js'; + +$(function () { + Console.initialize(); +}); diff --git a/js/src/modules/console.js b/js/src/modules/console.js index 4b0208fb6d..78fea70a76 100644 --- a/js/src/modules/console.js +++ b/js/src/modules/console.js @@ -1,8 +1,7 @@ -/** - * Used in or for console - * - * @package phpMyAdmin-Console - */ +import $ from 'jquery'; +import CodeMirror from 'codemirror'; + +/* global AJAX, CommonParams, Functions, Messages, Navigation */ /** * Console object @@ -49,6 +48,12 @@ var Console = { * @access private */ isInitialized: false, + + /** + * @type {Object|string|null} + */ + debugSqlInfo: null, + /** * Used for console initialize, reinit is ok, just some variable assignment * @@ -1131,11 +1136,6 @@ var ConsoleBookmarks = { }; var ConsoleDebug = { - /** - * @type {Object|string|null} - */ - debugSqlInfo: null, - config: { groupQueries: false, orderBy: 'exec', // Possible 'exec' => Execution order, 'time' => Time taken, 'count' @@ -1211,12 +1211,12 @@ var ConsoleDebug = { }); // Show SQL debug info for first page load - if (ConsoleDebug.debugSqlInfo === null) { + if (Console.debugSqlInfo === null) { return; } $('#pma_console').find('.button.debug').removeClass('hide'); - ConsoleDebug.showLog(ConsoleDebug.debugSqlInfo); + ConsoleDebug.showLog(Console.debugSqlInfo); }, formatFunctionCall: function (dbgStep) { var functionName = ''; @@ -1530,9 +1530,6 @@ var ConsoleDebug = { } }; -/** - * Executed on page load - */ -$(function () { - Console.initialize(); -}); +window.Console = Console; + +export { Console }; diff --git a/js/src/shortcuts_handler.js b/js/src/shortcuts_handler.js index bd1b661e00..b4ff6eae77 100644 --- a/js/src/shortcuts_handler.js +++ b/js/src/shortcuts_handler.js @@ -6,8 +6,6 @@ * @requires jQueryUI */ -/* global Console */ // js/console.js - /** * Register key events on load */ @@ -54,12 +52,12 @@ $(function () { return; } if (e.ctrlKey && e.altKey && e.keyCode === keyC) { - Console.toggle(); + window.Console.toggle(); } if (e.ctrlKey && e.keyCode === keyK) { e.preventDefault(); - Console.toggle(); + window.Console.toggle(); } if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'TEXTAREA' || e.target.nodeName === 'SELECT') { @@ -72,7 +70,7 @@ $(function () { databaseOp = true; } else if (e.keyCode === keyK) { e.preventDefault(); - Console.toggle(); + window.Console.toggle(); } else if (e.keyCode === keyS) { if (databaseOp === true) { isTable = CommonParams.get('table'); diff --git a/libraries/classes/Footer.php b/libraries/classes/Footer.php index af1d46caaf..9e63e64667 100644 --- a/libraries/classes/Footer.php +++ b/libraries/classes/Footer.php @@ -277,7 +277,7 @@ class Footer $url = $this->getSelfUrl(); } - $this->scripts->addCode('window.ConsoleDebug.debugSqlInfo = ' . $this->getDebugMessage() . ';'); + $this->scripts->addCode('window.Console.debugSqlInfo = ' . $this->getDebugMessage() . ';'); $errorMessages = $this->getErrorMessages(); $scripts = $this->scripts->getDisplay(); diff --git a/webpack.config.js b/webpack.config.js index eae7944aad..b6cd31b7da 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -95,6 +95,10 @@ module.exports = [ path: path.resolve(__dirname, 'js/dist'), iife: false, }, + externals: { + jquery: 'jQuery', + codemirror: 'CodeMirror', + }, module: { rules: [ {