Assign some globals to the window object

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2022-06-30 22:34:22 -03:00
parent 4c0bb9474d
commit b9fc5d1e0f
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
5 changed files with 9 additions and 19 deletions

View File

@ -8,8 +8,6 @@
*
*/
/* global sprintf */ // js/vendor/sprintf.js
function getFormatsText () {
return {
'=': ' = \'%s\'',
@ -37,7 +35,7 @@ function generateCondition (criteriaDiv, table) {
query += '`' + Functions.escapeBacktick(table.siblings('.columnNameSelect').first().val()) + '`';
if (criteriaDiv.find('.criteria_rhs').first().val() === 'text') {
var formatsText = getFormatsText();
query += sprintf(formatsText[criteriaDiv.find('.criteria_op').first().val()], Functions.escapeSingleQuote(criteriaDiv.find('.rhs_text_val').first().val()));
query += window.sprintf(formatsText[criteriaDiv.find('.criteria_op').first().val()], Functions.escapeSingleQuote(criteriaDiv.find('.rhs_text_val').first().val()));
} else {
query += ' ' + criteriaDiv.find('.criteria_op').first().val();
query += ' `' + Functions.escapeBacktick(criteriaDiv.find('.tableNameSelect').first().val()) + '`.';

View File

@ -1,6 +1,3 @@
/* global TraceKit */ // js/vendor/tracekit.js
/**
* general function, usually for data manipulation pages
*
@ -246,7 +243,7 @@ var ErrorReport = {
try {
return func.apply(this, arguments);
} catch (x) {
TraceKit.report(x);
window.TraceKit.report(x);
}
};
newFunc.wrapped = true;
@ -299,6 +296,6 @@ var ErrorReport = {
};
window.AJAX.registerOnload('error_report.js', function () {
TraceKit.report.subscribe(ErrorReport.errorHandler);
window.TraceKit.report.subscribe(ErrorReport.errorHandler);
ErrorReport.setUpErrorReporting();
});

View File

@ -5,8 +5,6 @@
/* global mysqlDocBuiltin, mysqlDocKeyword */ // js/doclinks.js
/* global Indexes */ // js/indexes.js
/* global firstDayOfCalendar, maxInputVars, mysqlDocTemplate, themeImagePath */ // templates/javascript/variables.twig
/* global sprintf */ // js/vendor/sprintf.js
/* global zxcvbnts */ // js/vendor/zxcvbn-ts.js
/**
* General functions, usually for data manipulation pages.
@ -449,7 +447,7 @@ Functions.escapeSingleQuote = function (s) {
};
Functions.sprintf = function () {
return sprintf.apply(this, arguments);
return window.sprintf.apply(this, arguments);
};
/**
@ -527,8 +525,8 @@ Functions.checkPasswordStrength = function (value, meterObject, meterObjectLabel
customDict.push(username);
}
zxcvbnts.core.zxcvbnOptions.setOptions({ dictionary: { userInputs: customDict } });
var zxcvbnObject = zxcvbnts.core.zxcvbn(value);
window.zxcvbnts.core.zxcvbnOptions.setOptions({ dictionary: { userInputs: customDict } });
var zxcvbnObject = window.zxcvbnts.core.zxcvbn(value);
var strength = zxcvbnObject.score;
strength = parseInt(strength);
meterObject.val(strength);

View File

@ -8,7 +8,6 @@
*/
/* global Navigation */
/* global sprintf */ // js/vendor/sprintf.js
/**
* AJAX scripts for /table/structure
@ -154,7 +153,7 @@ window.AJAX.registerOnload('table/structure.js', function () {
// If Collation is changed, Warn and Confirm
if (checkIfConfirmRequired($form)) {
var question = sprintf(
var question = window.sprintf(
Messages.strChangeColumnCollation, 'https://wiki.phpmyadmin.net/pma/Garbled_data'
);
$form.confirm(question, $form.attr('action'), function () {

View File

@ -1,5 +1,3 @@
/* global u2f */ // js/vendor/u2f-api-polyfill.js
window.AJAX.registerOnload('u2f.js', function () {
var $inputReg = $('#u2f_registration_response');
if ($inputReg.length > 0) {
@ -8,7 +6,7 @@ window.AJAX.registerOnload('u2f.js', function () {
setTimeout(function () {
// A magic JS function that talks to the USB device. This function will keep polling for the USB device until it finds one.
var request = JSON.parse($inputReg.attr('data-request'));
u2f.register(request.appId, [request], JSON.parse($inputReg.attr('data-signatures')), function (data) {
window.u2f.register(request.appId, [request], JSON.parse($inputReg.attr('data-signatures')), function (data) {
// Handle returning error data
if (data.errorCode && data.errorCode !== 0) {
switch (data.errorCode) {
@ -45,7 +43,7 @@ window.AJAX.registerOnload('u2f.js', function () {
// Magic JavaScript talking to your HID
// appid, challenge, authenticateRequests
var request = JSON.parse($inputAuth.attr('data-request'));
u2f.sign(request[0].appId, request[0].challenge, request, function (data) {
window.u2f.sign(request[0].appId, request[0].challenge, request, function (data) {
// Handle returning error data
if (data.errorCode && data.errorCode !== 0) {
switch (data.errorCode) {