Skip to content

Commit e4ea230

Browse files
committed
Assign Messages global var to the window object
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent a55b8e8 commit e4ea230

59 files changed

Lines changed: 700 additions & 701 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"jquery": true
1616
},
1717
"globals": {
18-
"Functions": "readonly",
19-
"Messages": "readonly"
18+
"Functions": "readonly"
2019
},
2120
"rules": {
2221
"valid-jsdoc": ["error", {

js/src/ajax.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ window.AJAX = {
197197
// Show lock icon if locked targets is not empty.
198198
// otherwise remove lock icon
199199
if (!jQuery.isEmptyObject(window.AJAX.lockedTargets)) {
200-
$('#lock_page_icon').html(Functions.getImage('s_lock', Messages.strLockToolTip).toString());
200+
$('#lock_page_icon').html(Functions.getImage('s_lock', window.Messages.strLockToolTip).toString());
201201
} else {
202202
$('#lock_page_icon').html('');
203203
}
@@ -262,7 +262,7 @@ window.AJAX = {
262262
if (typeof event !== 'undefined' && event.type === 'click' &&
263263
event.isTrigger !== true &&
264264
!jQuery.isEmptyObject(window.AJAX.lockedTargets) &&
265-
confirm(Messages.strConfirmNavigation) === false
265+
confirm(window.Messages.strConfirmNavigation) === false
266266
) {
267267
return false;
268268
}
@@ -279,7 +279,7 @@ window.AJAX = {
279279
window.AJAX.xhr.abort();
280280
if (window.AJAX.xhr.status === 0 && window.AJAX.xhr.statusText === 'abort') {
281281
// If aborted
282-
window.AJAX.$msgbox = Functions.ajaxShowMessage(Messages.strAbortedRequest);
282+
window.AJAX.$msgbox = Functions.ajaxShowMessage(window.Messages.strAbortedRequest);
283283
window.AJAX.active = false;
284284
window.AJAX.xhr = null;
285285
previousLinkAborted = true;
@@ -398,11 +398,11 @@ window.AJAX = {
398398
data.stopErrorReportLoop !== '1'
399399
) {
400400
$('#pma_report_errors_form').trigger('submit');
401-
Functions.ajaxShowMessage(Messages.phpErrorsBeingSubmitted, false);
401+
Functions.ajaxShowMessage(window.Messages.phpErrorsBeingSubmitted, false);
402402
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
403403
} else if (data.promptPhpErrors) {
404404
// otherwise just prompt user if it is set so.
405-
msg = msg + Messages.phpErrorsFound;
405+
msg = msg + window.Messages.phpErrorsFound;
406406
// scroll to bottom where all the errors are displayed.
407407
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
408408
}
@@ -421,7 +421,7 @@ window.AJAX = {
421421
// reload page if user trying to login has changed
422422
if (window.CommonParams.get('user') !== data.params.user) {
423423
window.location = 'index.php';
424-
Functions.ajaxShowMessage(Messages.strLoading, false);
424+
Functions.ajaxShowMessage(window.Messages.strLoading, false);
425425
window.AJAX.active = false;
426426
window.AJAX.xhr = null;
427427
return;
@@ -581,11 +581,11 @@ window.AJAX = {
581581
data.stopErrorReportLoop !== '1'
582582
) {
583583
$('#pma_report_errors_form').trigger('submit');
584-
Functions.ajaxShowMessage(Messages.phpErrorsBeingSubmitted, false);
584+
Functions.ajaxShowMessage(window.Messages.phpErrorsBeingSubmitted, false);
585585
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
586586
} else if (data.promptPhpErrors) {
587587
// otherwise just prompt user if it is set so.
588-
msg = msg + Messages.phpErrorsFound;
588+
msg = msg + window.Messages.phpErrorsFound;
589589
// scroll to bottom where all the errors are displayed.
590590
$('html, body').animate({ scrollTop:$(document).height() }, 'slow');
591591
}
@@ -919,15 +919,15 @@ window.AJAX = {
919919
}
920920

921921
if (request.status !== 0) {
922-
details += '<div>' + Functions.escapeHtml(Functions.sprintf(Messages.strErrorCode, request.status)) + '</div>';
922+
details += '<div>' + Functions.escapeHtml(Functions.sprintf(window.Messages.strErrorCode, request.status)) + '</div>';
923923
}
924-
details += '<div>' + Functions.escapeHtml(Functions.sprintf(Messages.strErrorText, request.statusText + ' (' + state + ')')) + '</div>';
924+
details += '<div>' + Functions.escapeHtml(Functions.sprintf(window.Messages.strErrorText, request.statusText + ' (' + state + ')')) + '</div>';
925925
if (state === 'rejected' || state === 'timeout') {
926-
details += '<div>' + Functions.escapeHtml(Messages.strErrorConnection) + '</div>';
926+
details += '<div>' + Functions.escapeHtml(window.Messages.strErrorConnection) + '</div>';
927927
}
928928
Functions.ajaxShowMessage(
929929
'<div class="alert alert-danger" role="alert">' +
930-
Messages.strErrorProcessingRequest +
930+
window.Messages.strErrorProcessingRequest +
931931
details +
932932
'</div>',
933933
false

js/src/config.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ window.Config.isStorageSupported = (type, warn = false) => {
2626
} catch (error) {
2727
// Not supported
2828
if (warn) {
29-
Functions.ajaxShowMessage(Messages.strNoLocalStorage, false);
29+
Functions.ajaxShowMessage(window.Messages.strNoLocalStorage, false);
3030
}
3131
}
3232
return false;
@@ -250,7 +250,7 @@ window.validators = {
250250
return true;
251251
}
252252
var result = this.value !== '0' && window.validators.regExpNumeric.test(this.value);
253-
return result ? true : Messages.error_nan_p;
253+
return result ? true : window.Messages.error_nan_p;
254254
},
255255
/**
256256
* Validates non-negative number
@@ -264,7 +264,7 @@ window.validators = {
264264
return true;
265265
}
266266
var result = window.validators.regExpNumeric.test(this.value);
267-
return result ? true : Messages.error_nan_nneg;
267+
return result ? true : window.Messages.error_nan_nneg;
268268
},
269269
/**
270270
* Validates port number
@@ -276,7 +276,7 @@ window.validators = {
276276
return true;
277277
}
278278
var result = window.validators.regExpNumeric.test(this.value) && this.value !== '0';
279-
return result && this.value <= 65535 ? true : Messages.error_incorrect_port;
279+
return result && this.value <= 65535 ? true : window.Messages.error_incorrect_port;
280280
},
281281
/**
282282
* Validates value according to given regular expression
@@ -293,7 +293,7 @@ window.validators = {
293293
// convert PCRE regexp
294294
var parts = regexp.match(window.validators.regExpPcreExtract);
295295
var valid = this.value.match(new RegExp(parts[2], parts[3])) !== null;
296-
return valid ? true : Messages.error_invalid_value;
296+
return valid ? true : window.Messages.error_invalid_value;
297297
},
298298
/**
299299
* Validates upper bound for numeric inputs
@@ -308,7 +308,7 @@ window.validators = {
308308
if (isNaN(val)) {
309309
return true;
310310
}
311-
return val <= maxValue ? true : Functions.sprintf(Messages.error_value_lte, maxValue);
311+
return val <= maxValue ? true : Functions.sprintf(window.Messages.error_value_lte, maxValue);
312312
},
313313
// field validators
314314
field: {},
@@ -678,7 +678,7 @@ function savePrefsToLocalStorage (form) {
678678
*/
679679
function updatePrefsDate () {
680680
var d = new Date(window.localStorage.configMtimeLocal);
681-
var msg = Messages.strSavedOn.replace(
681+
var msg = window.Messages.strSavedOn.replace(
682682
'@DATE@',
683683
Functions.formatDateTime(d)
684684
);

js/src/database/central_columns.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ window.AJAX.registerOnload('database/central_columns.js', function () {
4949
event.preventDefault();
5050
var multiDeleteColumns = $('.checkall:checkbox:checked').serialize();
5151
if (multiDeleteColumns === '') {
52-
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
52+
Functions.ajaxShowMessage(window.Messages.strRadioUnchecked);
5353
return false;
5454
}
5555
Functions.ajaxShowMessage();
@@ -60,7 +60,7 @@ window.AJAX.registerOnload('database/central_columns.js', function () {
6060
event.preventDefault();
6161
var editColumnList = $('.checkall:checkbox:checked').serialize();
6262
if (editColumnList === '') {
63-
Functions.ajaxShowMessage(Messages.strRadioUnchecked);
63+
Functions.ajaxShowMessage(window.Messages.strRadioUnchecked);
6464
return false;
6565
}
6666
var argsep = window.CommonParams.get('arg_separator');
@@ -115,7 +115,7 @@ window.AJAX.registerOnload('database/central_columns.js', function () {
115115
event.preventDefault();
116116
event.stopPropagation();
117117
var $td = $(this);
118-
var question = Messages.strDeleteCentralColumnWarning;
118+
var question = window.Messages.strDeleteCentralColumnWarning;
119119
$td.confirm(question, null, function () {
120120
var rownum = $td.data('rownum');
121121
$('#del_col_name').val('selected_fld%5B%5D=' + $('#checkbox_row_' + rownum).val());
@@ -183,7 +183,7 @@ window.AJAX.registerOnload('database/central_columns.js', function () {
183183
error: function () {
184184
Functions.ajaxShowMessage(
185185
'<div class="alert alert-danger" role="alert">' +
186-
Messages.strErrorProcessingRequest +
186+
window.Messages.strErrorProcessingRequest +
187187
'</div>',
188188
false
189189
);
@@ -200,7 +200,7 @@ window.AJAX.registerOnload('database/central_columns.js', function () {
200200
'db' : window.CommonParams.get('db'),
201201
'selectedTable' : selectValue
202202
};
203-
$('#column-select').html('<option value="">' + Messages.strLoading + '</option>');
203+
$('#column-select').html('<option value="">' + window.Messages.strLoading + '</option>');
204204
if (selectValue !== '') {
205205
$.post(href, params, function (data) {
206206
$('#column-select').empty().append(defaultColumnSelect);

js/src/database/events.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const DatabaseEvents = {
4040
$elm = $('table.rte_table').last().find('input[name=item_name]');
4141
if ($elm.val() === '') {
4242
$elm.trigger('focus');
43-
alert(Messages.strFormEmpty);
43+
alert(window.Messages.strFormEmpty);
4444
return false;
4545
}
4646
$elm = $('table.rte_table').find('textarea[name=item_definition]');
@@ -50,7 +50,7 @@ const DatabaseEvents = {
5050
} else {
5151
$('textarea[name=item_definition]').last().trigger('focus');
5252
}
53-
alert(Messages.strFormEmpty);
53+
alert(window.Messages.strFormEmpty);
5454
return false;
5555
}
5656
// The validation has so far passed, so now
@@ -63,7 +63,7 @@ const DatabaseEvents = {
6363
if ($this.attr('id') === 'bulkActionExportButton') {
6464
var combined = {
6565
success: true,
66-
title: Messages.strExport,
66+
title: window.Messages.strExport,
6767
message: '',
6868
error: ''
6969
};
@@ -106,7 +106,7 @@ const DatabaseEvents = {
106106
* for jQueryUI dialog buttons
107107
*/
108108
var buttonOptions = {};
109-
buttonOptions[Messages.strClose] = function () {
109+
buttonOptions[window.Messages.strClose] = function () {
110110
$(this).dialog('close').remove();
111111
};
112112
/**
@@ -155,7 +155,7 @@ const DatabaseEvents = {
155155
Functions.ajaxRemoveMessage($msg);
156156
// Now define the function that is called when
157157
// the user presses the "Go" button
158-
that.buttonOptions[Messages.strGo] = function () {
158+
that.buttonOptions[window.Messages.strGo] = function () {
159159
// Move the data from the codemirror editor back to the
160160
// textarea, where it can be used in the form submission.
161161
if (typeof window.CodeMirror !== 'undefined') {
@@ -168,7 +168,7 @@ const DatabaseEvents = {
168168
*/
169169
var data = $('form.rte_form').last().serialize();
170170
$msg = Functions.ajaxShowMessage(
171-
Messages.strProcessingRequest
171+
window.Messages.strProcessingRequest
172172
);
173173
var url = $('form.rte_form').last().attr('action');
174174
$.post(url, data, function (data) {
@@ -270,7 +270,7 @@ const DatabaseEvents = {
270270
}); // end $.post()
271271
} // end "if (that.validate())"
272272
}; // end of function that handles the submission of the Editor
273-
that.buttonOptions[Messages.strClose] = function () {
273+
that.buttonOptions[window.Messages.strClose] = function () {
274274
$(this).dialog('close');
275275
};
276276
/**
@@ -342,7 +342,7 @@ const DatabaseEvents = {
342342
* @var msg jQuery object containing the reference to
343343
* the AJAX message shown to the user
344344
*/
345-
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
345+
var $msg = Functions.ajaxShowMessage(window.Messages.strProcessingRequest);
346346
var params = Functions.getJsConfirmCommonParam(this, $this.getPostData());
347347
$.post(url, params, function (data) {
348348
if (data.success === true) {
@@ -399,12 +399,12 @@ const DatabaseEvents = {
399399

400400
dropMultipleDialog: function ($this) {
401401
// We ask for confirmation here
402-
$this.confirm(Messages.strDropRTEitems, '', function () {
402+
$this.confirm(window.Messages.strDropRTEitems, '', function () {
403403
/**
404404
* @var msg jQuery object containing the reference to
405405
* the AJAX message shown to the user
406406
*/
407-
var $msg = Functions.ajaxShowMessage(Messages.strProcessingRequest);
407+
var $msg = Functions.ajaxShowMessage(window.Messages.strProcessingRequest);
408408

409409
// drop anchors of all selected rows
410410
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
@@ -495,15 +495,15 @@ const DatabaseEvents = {
495495
$elm = this.$ajaxDialog.find('input[name=item_interval_value]');
496496
if ($elm.val() === '') {
497497
$elm.trigger('focus');
498-
alert(Messages.strFormEmpty);
498+
alert(window.Messages.strFormEmpty);
499499
return false;
500500
}
501501
} else {
502502
// The execute_at field must not be empty for "once off" events
503503
$elm = this.$ajaxDialog.find('input[name=item_execute_at]');
504504
if ($elm.val() === '') {
505505
$elm.trigger('focus');
506-
alert(Messages.strFormEmpty);
506+
alert(window.Messages.strFormEmpty);
507507
return false;
508508
}
509509
}

js/src/database/multi_table_query.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ window.AJAX.registerOnload('database/multi_table_query.js', function () {
120120
var query = editor.getDoc().getValue();
121121
// Verifying that the query is not empty
122122
if (query === '') {
123-
Functions.ajaxShowMessage(Messages.strEmptyQuery, false, 'error');
123+
Functions.ajaxShowMessage(window.Messages.strEmptyQuery, false, 'error');
124124
return;
125125
}
126126
var data = {

js/src/database/operations.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ window.AJAX.registerOnload('database/operations.js', function () {
3838
event.preventDefault();
3939

4040
if (Functions.emptyCheckTheField(this, 'newname')) {
41-
Functions.ajaxShowMessage(Messages.strFormEmpty, false, 'error');
41+
Functions.ajaxShowMessage(window.Messages.strFormEmpty, false, 'error');
4242
return false;
4343
}
4444

4545
var oldDbName = window.CommonParams.get('db');
4646
var newDbName = $('#new_db_name').val();
4747

4848
if (newDbName === oldDbName) {
49-
Functions.ajaxShowMessage(Messages.strDatabaseRenameToSameName, false, 'error');
49+
Functions.ajaxShowMessage(window.Messages.strDatabaseRenameToSameName, false, 'error');
5050
return false;
5151
}
5252

@@ -57,7 +57,7 @@ window.AJAX.registerOnload('database/operations.js', function () {
5757
Functions.prepareForAjaxRequest($form);
5858

5959
$form.confirm(question, $form.attr('action'), function (url) {
60-
Functions.ajaxShowMessage(Messages.strRenamingDatabases, false);
60+
Functions.ajaxShowMessage(window.Messages.strRenamingDatabases, false);
6161
$.post(url, $('#rename_db_form').serialize() + window.CommonParams.get('arg_separator') + 'is_js_confirmed=1', function (data) {
6262
if (typeof data !== 'undefined' && data.success === true) {
6363
Functions.ajaxShowMessage(data.message);
@@ -89,11 +89,11 @@ window.AJAX.registerOnload('database/operations.js', function () {
8989
event.preventDefault();
9090

9191
if (Functions.emptyCheckTheField(this, 'newname')) {
92-
Functions.ajaxShowMessage(Messages.strFormEmpty, false, 'error');
92+
Functions.ajaxShowMessage(window.Messages.strFormEmpty, false, 'error');
9393
return false;
9494
}
9595

96-
Functions.ajaxShowMessage(Messages.strCopyingDatabase, false);
96+
Functions.ajaxShowMessage(window.Messages.strCopyingDatabase, false);
9797
var $form = $(this);
9898
Functions.prepareForAjaxRequest($form);
9999
$.post($form.attr('action'), $form.serialize(), function (data) {
@@ -131,7 +131,7 @@ window.AJAX.registerOnload('database/operations.js', function () {
131131
event.preventDefault();
132132
var $form = $(this);
133133
Functions.prepareForAjaxRequest($form);
134-
Functions.ajaxShowMessage(Messages.strChangingCharset);
134+
Functions.ajaxShowMessage(window.Messages.strChangingCharset);
135135
$.post($form.attr('action'), $form.serialize(), function (data) {
136136
if (typeof data !== 'undefined' && data.success === true) {
137137
Functions.ajaxShowMessage(data.message);
@@ -150,15 +150,15 @@ window.AJAX.registerOnload('database/operations.js', function () {
150150
/**
151151
* @var {String} question String containing the question to be asked for confirmation
152152
*/
153-
var question = Messages.strDropDatabaseStrongWarning + ' ';
153+
var question = window.Messages.strDropDatabaseStrongWarning + ' ';
154154
question += Functions.sprintf(
155-
Messages.strDoYouReally,
155+
window.Messages.strDoYouReally,
156156
'DROP DATABASE `' + Functions.escapeHtml(window.CommonParams.get('db') + '`')
157157
);
158158
var params = Functions.getJsConfirmCommonParam(this, $link.getPostData());
159159

160160
$(this).confirm(question, $(this).attr('href'), function (url) {
161-
Functions.ajaxShowMessage(Messages.strProcessingRequest);
161+
Functions.ajaxShowMessage(window.Messages.strProcessingRequest);
162162
$.post(url, params, function (data) {
163163
if (typeof data !== 'undefined' && data.success) {
164164
// Database deleted successfully, refresh both the frames

js/src/database/qbe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ window.AJAX.registerOnload('database/qbe.js', function () {
7373
* Ajax event handlers for 'Delete bookmark'
7474
*/
7575
$(document).on('click', '#deleteSearch', function () {
76-
var question = Functions.sprintf(Messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
76+
var question = Functions.sprintf(window.Messages.strConfirmDeleteQBESearch, $('#searchId').find('option:selected').text());
7777
if (!confirm(question)) {
7878
return false;
7979
}

0 commit comments

Comments
 (0)