From 83f46fbc77bcf2ba59390cb25262d40abc8e309d Mon Sep 17 00:00:00 2001 From: Piyush Vijay Date: Sat, 26 May 2018 11:35:56 +0530 Subject: [PATCH] Updating documentation for the new configuration variables introduced and adding comments for some code handleing new js files. Signed-off-by: Piyush Vijay --- .jshintrc | 3 +++ doc/config.rst | 15 +++++++++++++++ js/ajax.js | 9 ++++++--- libraries/classes/Scripts.php | 7 +++++-- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.jshintrc b/.jshintrc index 26e5b57d8a44..92a31f7998fe 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,6 +5,9 @@ // Globals "jquery" : true, + // ES6 + "esversion": 6, + // Stricter checking "curly" : true, "immed" : true, diff --git a/doc/config.rst b/doc/config.rst index 569587bf5250..cc07e4f1a17f 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -3402,6 +3402,21 @@ Developer These settings might have huge effect on performance or security. +.. config:option:: $cfg['environment'] + + :type: string + :default: `'production'` + + Enable you to set the working environment for loading js files + +.. config:option:: $cfg['webpack_port'] + + :type: integer + :default: 3307 + + Enable you to start webpack development server for serving js files + when woking in the development environment + .. config:option:: $cfg['DBG'] :type: array diff --git a/js/ajax.js b/js/ajax.js index 43c1b3dcfcbb..6ef58e278769 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -639,9 +639,13 @@ var AJAX = { var self = this; script.type = 'text/javascript'; - /* new directory */ + /** + * This piece of code is for appending the new revamped files into the + * DOM so that both new and old files can be used simultaneously + * It checks whether the file contains new in its name or not + */ var check = name.split('_'); - if (check[check.length - 1] === 'new') { + if (check[check.length - 1] === 'new.js') { var script_src = ''; if (PMA_commonParams.get('environment') === 'development') { script_src += 'http://localhost:' + PMA_commonParams.get('webpack_port') + '/js/dist/'; @@ -652,7 +656,6 @@ var AJAX = { } else { script.src = 'js/' + name + '?' + 'v=' + encodeURIComponent(PMA_commonParams.get('PMA_VERSION')); } - /* new directory */ script.async = false; script.onload = function () { self.done(name, callback); diff --git a/libraries/classes/Scripts.php b/libraries/classes/Scripts.php index fc2d26a65572..8889a776a734 100644 --- a/libraries/classes/Scripts.php +++ b/libraries/classes/Scripts.php @@ -54,7 +54,11 @@ private function _includeFiles(array $files) . "type='text/javascript' src='js/" . $file_name . "'>\n"; } else if (strpos($value['filename'], "_new") !== false) { - /* new directory */ + /** + * This piece of code is for appending the new revamped files into the + * DOM so that both new and old files can be used simultaneously + * It checks whether the file contains new in its name or not + */ if ($GLOBALS['cfg']['environment'] === 'development') { $src = "http://localhost:" . $GLOBALS['cfg']['webpack_port'] . "/"; } else if ($GLOBALS['cfg']['environment'] === 'production'){ @@ -62,7 +66,6 @@ private function _includeFiles(array $files) } $result .= '' . "\n"; - /* new directory */ } else { $result .= '' . "\n";