Skip to content

Commit

Permalink
Updating documentation for the new configuration variables introduced
Browse files Browse the repository at this point in the history
and adding comments for some code handleing new js files.
Signed-off-by: Piyush Vijay <piyushvijay.1997@gmail.com>
  • Loading branch information
Piyush3079 committed Jul 15, 2018
1 parent 5efef3f commit 83f46fb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Expand Up @@ -5,6 +5,9 @@
// Globals
"jquery" : true,

// ES6
"esversion": 6,

// Stricter checking
"curly" : true,
"immed" : true,
Expand Down
15 changes: 15 additions & 0 deletions doc/config.rst
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions js/ajax.js
Expand Up @@ -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/';
Expand All @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions libraries/classes/Scripts.php
Expand Up @@ -54,15 +54,18 @@ private function _includeFiles(array $files)
. "type='text/javascript' src='js/" . $file_name
. "'></script>\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'){
$src = "";
}
$result .= '<script data-cfasync="false" type="text/javascript" src="' . $src . 'js/dist/'
. $value['filename'] . '?' . Header::getVersionParameter() . '"></script>' . "\n";
/* new directory */
} else {
$result .= '<script data-cfasync="false" type="text/javascript" src="js/'
. $value['filename'] . '?' . Header::getVersionParameter() . '"></script>' . "\n";
Expand Down

0 comments on commit 83f46fb

Please sign in to comment.