Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2022-06-20 00:42:40 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2022-06-20 21:52:22 +0300
commit3e672740f396b5c4a2fa7038ed3b23b9f1a481a2 (patch)
tree470eb75117cd9624ac9c28f4015b716b9d501fbf
parent196dad277706f483e7e32cc0133a094efc6cc7db (diff)
Improve type of some functions.js variables
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
-rw-r--r--js/src/functions.js94
-rw-r--r--templates/login/form.twig2
-rw-r--r--test/classes/Plugins/Auth/AuthenticationCookieTest.php2
-rw-r--r--test/selenium/TestBase.php2
4 files changed, 66 insertions, 34 deletions
diff --git a/js/src/functions.js b/js/src/functions.js
index 58753cc567..868777463b 100644
--- a/js/src/functions.js
+++ b/js/src/functions.js
@@ -9,72 +9,84 @@
/* global zxcvbnts */ // js/vendor/zxcvbn-ts.js
/**
- * general function, usually for data manipulation pages
- *
+ * General functions, usually for data manipulation pages.
+ * @type {object}
*/
var Functions = {};
/**
- * @var {number} ajaxMessageCount Number of AJAX messages shown since page load
+ * Number of AJAX messages shown since page load.
+ * @type {number}
*/
-var ajaxMessageCount = 0;
+let ajaxMessageCount = 0;
/**
- * @var codeMirrorEditor object containing CodeMirror editor of the query editor in SQL tab
+ * Object containing CodeMirror editor of the query editor in SQL tab.
+ * @type {(object|boolean|null)}
*/
var codeMirrorEditor = false;
/**
- * @var codeMirrorInlineEditor object containing CodeMirror editor of the inline query editor
+ * Object containing CodeMirror editor of the inline query editor.
+ * @type {(object|boolean|null)}
*/
-var codeMirrorInlineEditor = false;
+let codeMirrorInlineEditor = false;
/**
- * @var {boolean} sqlAutoCompleteInProgress shows if Table/Column name autocomplete AJAX is in progress
+ * Shows if Table/Column name autocomplete AJAX is in progress.
+ * @type {boolean}
*/
-var sqlAutoCompleteInProgress = false;
+let sqlAutoCompleteInProgress = false;
/**
- * @var sqlAutoComplete object containing list of columns in each table
+ * Object containing list of columns in each table.
+ * @type {(array|boolean)}
*/
-var sqlAutoComplete = false;
+let sqlAutoComplete = false;
/**
- * @var {string} sqlAutoCompleteDefaultTable string containing default table to autocomplete columns
+ * String containing default table to autocomplete columns.
+ * @type {string}
*/
-var sqlAutoCompleteDefaultTable = '';
+let sqlAutoCompleteDefaultTable = '';
/**
- * @var {array} centralColumnList array to hold the columns in central list per db.
+ * Array to hold the columns in central list per db.
+ * @type {array}
*/
var centralColumnList = [];
/**
- * @var {array} primaryIndexes array to hold 'Primary' index columns.
+ * Array to hold 'Primary' index columns.
+ * @type {array}
*/
// eslint-disable-next-line no-unused-vars
var primaryIndexes = [];
/**
- * @var {array} uniqueIndexes array to hold 'Unique' index columns.
+ * Array to hold 'Unique' index columns.
+ * @type {array}
*/
// eslint-disable-next-line no-unused-vars
var uniqueIndexes = [];
/**
- * @var {array} indexes array to hold 'Index' columns.
+ * Array to hold 'Index' columns.
+ * @type {array}
*/
// eslint-disable-next-line no-unused-vars
var indexes = [];
/**
- * @var {array} fulltextIndexes array to hold 'Fulltext' columns.
+ * Array to hold 'Fulltext' columns.
+ * @type {array}
*/
// eslint-disable-next-line no-unused-vars
var fulltextIndexes = [];
/**
- * @var {array} spatialIndexes array to hold 'Spatial' columns.
+ * Array to hold 'Spatial' columns.
+ * @type {array}
*/
// eslint-disable-next-line no-unused-vars
var spatialIndexes = [];
@@ -93,6 +105,13 @@ $.ajaxPrefilter(function (options, originalOptions) {
});
/**
+ * @return {number}
+ */
+Functions.getAjaxMessageCount = function () {
+ return ajaxMessageCount;
+};
+
+/**
* Adds a date/time picker to an element
*
* @param {object} $thisElement a jQuery object pointing to the element
@@ -860,23 +879,29 @@ Functions.checkTableEditForm = function (theForm, fieldsCnt) {
/**
* True if last click is to check a row.
+ * @type {boolean}
*/
-var lastClickChecked = false;
+let lastClickChecked = false;
/**
- * Zero-based index of last clicked row.
- * Used to handle the shift + click event in the code above.
+ * Zero-based index of last clicked row. Used to handle the shift + click event in the code above.
+ * @type {number}
*/
-var lastClickedRow = -1;
+let lastClickedRow = -1;
/**
* Zero-based index of last shift clicked row.
+ * @type {number}
*/
-var lastShiftClickedRow = -1;
+let lastShiftClickedRow = -1;
+
+/** @type {number} */
+let idleSecondsCounter = 0;
+/** @type {number} */
+let incInterval;
+/** @type {number} */
+let updateTimeout;
-var idleSecondsCounter = 0;
-var incInterval;
-var updateTimeout;
AJAX.registerTeardown('functions.js', function () {
clearTimeout(updateTimeout);
clearInterval(incInterval);
@@ -981,6 +1006,7 @@ AJAX.registerOnload('functions.js', function () {
updateTimeout = window.setTimeout(UpdateIdleTime, interval);
}
});
+
/**
* Unbind all event handlers before tearing down a page
*/
@@ -2426,7 +2452,6 @@ AJAX.registerOnload('functions.js', function () {
});
});
-
/**
* Validates the password field in a form
*
@@ -2623,6 +2648,7 @@ AJAX.registerTeardown('functions.js', function () {
$(document).off('change', 'input.allow_null');
$(document).off('change', '.create_table_form select[name=tbl_storage_engine]');
});
+
/**
* Toggle the hiding/showing of the "Open in ENUM/SET editor" message when
* the page loads and when the selected data type changes
@@ -3073,6 +3099,7 @@ Functions.checkIndexName = function (formId) {
AJAX.registerTeardown('functions.js', function () {
$(document).off('click', '#index_frm input[type=submit]');
});
+
AJAX.registerOnload('functions.js', function () {
/**
* Handler for adding more columns to an index in the editor
@@ -3112,6 +3139,7 @@ AJAX.registerOnload('functions.js', function () {
}
});
});
+
Functions.indexDialogModal = function (routeUrl, url, title, callbackSuccess, callbackFailure) {
/* Remove the hidden dialogs if there are*/
var modal = $('#indexDialogModal');
@@ -3446,6 +3474,7 @@ Functions.toggleButton = function ($obj) {
AJAX.registerTeardown('functions.js', function () {
$('div.toggle-container').off('click');
});
+
/**
* Initialise all toggle buttons
*/
@@ -3634,6 +3663,7 @@ AJAX.registerOnload('functions.js', function () {
}
Functions.highlightSql($('body'));
});
+
AJAX.registerTeardown('functions.js', function () {
if (codeMirrorEditor) {
$('#sqlquery').text(codeMirrorEditor.getValue());
@@ -3641,6 +3671,7 @@ AJAX.registerTeardown('functions.js', function () {
codeMirrorEditor = false;
}
});
+
AJAX.registerOnload('functions.js', function () {
// initializes all lock-page elements lock-id and
// val-hash data property
@@ -3856,7 +3887,7 @@ $(function () {
});
});
-var checkboxesSel = 'input.checkall:checkbox:enabled';
+const checkboxesSel = 'input.checkall:checkbox:enabled';
Functions.checkboxesSel = checkboxesSel;
/**
@@ -3953,6 +3984,7 @@ $(document).on('keyup', '#filterText', function () {
}, 300);
$('#filter-rows-count').html(count);
});
+
AJAX.registerOnload('functions.js', function () {
/* Trigger filtering of the list based on incoming database name */
var $filter = $('#filterText');
@@ -4118,8 +4150,8 @@ Functions.toggleDatepickerIfInvalid = function ($td, $inputField) {
* Function to submit the login form after validation is done.
* NOTE: do NOT use a module or it will break the callback, issue #15435
*/
-// eslint-disable-next-line no-unused-vars, camelcase
-var Functions_recaptchaCallback = function () {
+// eslint-disable-next-line no-unused-vars
+var recaptchaCallback = function () {
$('#login_form').trigger('submit');
};
diff --git a/templates/login/form.twig b/templates/login/form.twig
index 0e58ec7684..2f0c915a32 100644
--- a/templates/login/form.twig
+++ b/templates/login/form.twig
@@ -118,7 +118,7 @@
</div>
</div>
{% else %}
- <input class="btn btn-primary {{ captcha_req }}" data-sitekey="{{ captcha_key }}" data-callback="Functions_recaptchaCallback" value="{% trans 'Log in' %}" type="submit" id="input_go">
+ <input class="btn btn-primary {{ captcha_req }}" data-sitekey="{{ captcha_key }}" data-callback="recaptchaCallback" value="{% trans 'Log in' %}" type="submit" id="input_go">
{% endif %}
{% else %}
<input class="btn btn-primary" value="{% trans 'Log in' %}" type="submit" id="input_go">
diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php
index 15aa5ad1f4..e773354609 100644
--- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php
+++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php
@@ -301,7 +301,7 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase
$this->assertStringContainsString(
'<input class="btn btn-primary g-recaptcha" data-sitekey="testpubkey"'
- . ' data-callback="Functions_recaptchaCallback" value="Log in" type="submit" id="input_go">',
+ . ' data-callback="recaptchaCallback" value="Log in" type="submit" id="input_go">',
$result
);
}
diff --git a/test/selenium/TestBase.php b/test/selenium/TestBase.php
index b0700c9d82..f1d94b304e 100644
--- a/test/selenium/TestBase.php
+++ b/test/selenium/TestBase.php
@@ -1089,7 +1089,7 @@ JS;
public function waitAjaxMessage(): void
{
/* Get current message count */
- $ajax_message_count = $this->webDriver->executeScript('return ajaxMessageCount;');
+ $ajax_message_count = $this->webDriver->executeScript('return Functions.getAjaxMessageCount();');
/* Ensure the popup is gone */
$this->waitForElementNotPresent('id', 'ajax_message_num_' . $ajax_message_count);
}