From b5029f8191b159bb196e04938b4f1c99414a8068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 29 Nov 2017 17:07:20 +0100 Subject: [PATCH 1/2] Declare i variable just once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- js/ajax.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/ajax.js b/js/ajax.js index da1e37e892..bcf5e60abc 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -565,6 +565,7 @@ var AJAX = { */ load: function (files, callback) { var self = this; + var i; // 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) { @@ -575,13 +576,13 @@ var AJAX = { } self._scriptsCompleted = false; self._scriptsToBeFired = []; - for (var i in files) { + for (i in files) { self._scriptsToBeLoaded.push(files[i].name); if (files[i].fire) { self._scriptsToBeFired.push(files[i].name); } } - for (var i in files) { + for (i in files) { var script = files[i].name; // Only for scripts that we don't already have if ($.inArray(script, self._scripts) === -1) { From df96bb0fb1933e54f7cc7c3427baa5e811d56333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 29 Nov 2017 17:08:30 +0100 Subject: [PATCH 2/2] Document why there are two loops are needed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- js/ajax.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/ajax.js b/js/ajax.js index bcf5e60abc..ede529433e 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -576,6 +576,10 @@ var AJAX = { } self._scriptsCompleted = false; self._scriptsToBeFired = []; + // We need to first complete list of files to load + // as next loop will directly fire requests to load them + // and that triggers removal of them from + // self._scriptsToBeLoaded for (i in files) { self._scriptsToBeLoaded.push(files[i].name); if (files[i].fire) { @@ -592,7 +596,7 @@ var AJAX = { self.done(script, callback); } } - // Trigger callback if there is nothing to load + // Trigger callback if there is nothing else to load self.done(null, callback); }, /**