Skip to content

Commit 8a32925

Browse files
committed
Replace var with let or const in TypeScript files
Most of the changes were done by PhpStorm. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
1 parent ef34ab5 commit 8a32925

72 files changed

Lines changed: 2826 additions & 2775 deletions

Some content is hidden

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

resources/js/codemirror/addon/lint/sql-lint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ window.CodeMirror.sqlLint = function (text, updateLinting, options, cm) {
1111
}
1212

1313
function handleResponse (response) {
14-
var found = [];
15-
for (var idx in response) {
14+
const found = [];
15+
for (let idx in response) {
1616
found.push({
1717
// eslint-disable-next-line new-cap
1818
from: window.CodeMirror.Pos(

resources/js/database/central_columns.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
5353

5454
$('#tableslistcontainer').find('button[name="delete_central_columns"]').on('click', function (event) {
5555
event.preventDefault();
56-
var multiDeleteColumns = $('.checkall:checkbox:checked').serialize();
56+
const multiDeleteColumns = $('.checkall:checkbox:checked').serialize();
5757
if (multiDeleteColumns === '') {
5858
ajaxShowMessage(window.Messages.strRadioUnchecked);
5959

@@ -67,15 +67,15 @@ AJAX.registerOnload('database/central_columns.js', function () {
6767

6868
$('#tableslistcontainer').find('button[name="edit_central_columns"]').on('click', function (event) {
6969
event.preventDefault();
70-
var editColumnList = $('.checkall:checkbox:checked').serialize();
70+
const editColumnList = $('.checkall:checkbox:checked').serialize();
7171
if (editColumnList === '') {
7272
ajaxShowMessage(window.Messages.strRadioUnchecked);
7373

7474
return false;
7575
}
7676

77-
var argsep = CommonParams.get('arg_separator');
78-
var editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
77+
const argsep = CommonParams.get('arg_separator');
78+
const editColumnData = editColumnList + '' + argsep + 'edit_central_columns_page=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
7979
ajaxShowMessage();
8080
AJAX.source = $(this);
8181
$.post('index.php?route=/database/central-columns', editColumnData, AJAX.responseHandler);
@@ -84,8 +84,8 @@ AJAX.registerOnload('database/central_columns.js', function () {
8484
$('#multi_edit_central_columns').on('submit', function (event) {
8585
event.preventDefault();
8686
event.stopPropagation();
87-
var argsep = CommonParams.get('arg_separator');
88-
var multiColumnEditData = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
87+
const argsep = CommonParams.get('arg_separator');
88+
const multiColumnEditData = $('#multi_edit_central_columns').serialize() + argsep + 'multi_edit_central_column_save=true' + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true' + argsep + 'db=' + encodeURIComponent(CommonParams.get('db')) + argsep + 'server=' + CommonParams.get('server');
8989
ajaxShowMessage();
9090
AJAX.source = $(this);
9191
$.post('index.php?route=/database/central-columns', multiColumnEditData, AJAX.responseHandler);
@@ -107,19 +107,19 @@ AJAX.registerOnload('database/central_columns.js', function () {
107107
window.scrollTo(0, 0);
108108
$(document).on('keyup', '.filter_rows', function () {
109109
// get the column names
110-
var cols = $('th.column_heading').map(function () {
110+
const cols = $('th.column_heading').map(function () {
111111
return $(this).text().trim();
112112
}).get();
113113
$.uiTableFilter($('#table_columns'), $(this).val(), cols, null, 'td span');
114114
});
115115

116116
$('.edit').on('click', function () {
117-
var rownum = $(this).parent().data('rownum');
117+
const rownum = $(this).parent().data('rownum');
118118
$('#save_' + rownum).show();
119119
$(this).hide();
120120
$('#f_' + rownum + ' td span').hide();
121121
$('#f_' + rownum + ' input, #f_' + rownum + ' select, #f_' + rownum + ' .open_enum_editor').show();
122-
var attributeVal = $('#f_' + rownum + ' td[name=col_attribute] span').html();
122+
const attributeVal = $('#f_' + rownum + ' td[name=col_attribute] span').html();
123123
$('#f_' + rownum + ' select[name=field_attribute\\[' + rownum + '\\] ] option[value="' + attributeVal + '"]').attr('selected', 'selected');
124124
if ($('#f_' + rownum + ' .default_type').val() === 'USER_DEFINED') {
125125
$('#f_' + rownum + ' .default_type').siblings('.default_value').show();
@@ -131,10 +131,10 @@ AJAX.registerOnload('database/central_columns.js', function () {
131131
$('.del_row').on('click', function (event) {
132132
event.preventDefault();
133133
event.stopPropagation();
134-
var $td = $(this);
135-
var question = window.Messages.strDeleteCentralColumnWarning;
134+
const $td = $(this);
135+
const question = window.Messages.strDeleteCentralColumnWarning;
136136
$td.confirm(question, null, function () {
137-
var rownum = $td.data('rownum');
137+
const rownum = $td.data('rownum');
138138
$('#del_col_name').val('selected_fld%5B%5D=' + $('#checkbox_row_' + rownum).val());
139139
$('#del_form').trigger('submit');
140140
});
@@ -143,7 +143,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
143143
$('.edit_cancel_form').on('click', function (event) {
144144
event.preventDefault();
145145
event.stopPropagation();
146-
var rownum = $(this).data('rownum');
146+
const rownum = $(this).data('rownum');
147147
$('#save_' + rownum).hide();
148148
$('#edit_' + rownum).show();
149149
$('#f_' + rownum + ' td span').show();
@@ -154,7 +154,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
154154
$('.edit_save_form').on('click', function (event) {
155155
event.preventDefault();
156156
event.stopPropagation();
157-
var rownum = $(this).data('rownum');
157+
const rownum = $(this).data('rownum');
158158
$('#f_' + rownum + ' td').each(function () {
159159
if ($(this).attr('name') !== 'undefined') {
160160
$(this).find(':input[type!="hidden"],select').first()
@@ -168,7 +168,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
168168
$('#f_' + rownum + ' .default_value').attr('name', 'col_default_val');
169169
}
170170

171-
var datastring = $('#f_' + rownum + ' :input').serialize();
171+
const datastring = $('#f_' + rownum + ' :input').serialize();
172172
$.ajax({
173173
type: 'POST',
174174
url: 'index.php?route=/database/central-columns',
@@ -212,14 +212,14 @@ AJAX.registerOnload('database/central_columns.js', function () {
212212
});
213213

214214
$('#table-select').on('change', function () {
215-
var selectValue = $(this).val();
216-
var defaultColumnSelect = $('#column-select').find('option').first();
217-
var href = 'index.php?route=/database/central-columns/populate';
218-
var params = {
215+
const selectValue = $(this).val();
216+
const defaultColumnSelect = $('#column-select').find('option').first();
217+
const href = 'index.php?route=/database/central-columns/populate';
218+
const params = {
219219
'ajax_request': true,
220220
'server': CommonParams.get('server'),
221221
'db': CommonParams.get('db'),
222-
'selectedTable': selectValue
222+
'selectedTable': selectValue,
223223
};
224224
$('#column-select').html('<option value="">' + window.Messages.strLoading + '</option>');
225225
if (selectValue !== '') {
@@ -231,7 +231,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
231231
});
232232

233233
$('#add_column').on('submit', function (e) {
234-
var selectvalue = $('#column-select').val();
234+
const selectvalue = $('#column-select').val();
235235
if (selectvalue === '') {
236236
e.preventDefault();
237237
e.stopPropagation();
@@ -240,7 +240,7 @@ AJAX.registerOnload('database/central_columns.js', function () {
240240

241241
$('#add_col_div').find('>a').on('click', function () {
242242
$('#add_new').slideToggle('slow');
243-
var $addColDivLinkSpan = $('#add_col_div').find('>a span');
243+
const $addColDivLinkSpan = $('#add_col_div').find('>a span');
244244
if ($addColDivLinkSpan.html() === '+') {
245245
$addColDivLinkSpan.html('-');
246246
} else {

resources/js/database/events.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const DatabaseEvents = {
3030
* @var $elm a jQuery object containing the reference
3131
* to an element that is being validated
3232
*/
33-
var $elm = null;
33+
let $elm = null;
3434
// Common validation. At the very least the name
3535
// and the definition must be provided for an item
3636
$elm = $('table.rte_table').last().find('input[name=item_name]');
@@ -60,21 +60,21 @@ const DatabaseEvents = {
6060
},
6161

6262
exportDialog: function ($this) {
63-
var $msg = ajaxShowMessage();
63+
const $msg = ajaxShowMessage();
6464
if ($this.attr('id') === 'bulkActionExportButton') {
65-
var combined = {
65+
const combined = {
6666
success: true,
6767
title: window.Messages.strExport,
6868
message: '',
69-
error: ''
69+
error: '',
7070
};
7171
// export anchors of all selected rows
72-
var exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
73-
var count = exportAnchors.length;
74-
var returnCount = 0;
75-
var p: any = $.when();
72+
const exportAnchors = $('input.checkall:checked').parents('tr').find('.export_anchor');
73+
const count = exportAnchors.length;
74+
let returnCount = 0;
75+
let p: any = $.when();
7676
exportAnchors.each(function () {
77-
var h = $(this).attr('href');
77+
const h = $(this).attr('href');
7878
p = p.then(function () {
7979
return $.get(h, { 'ajax_request': true }, function (data) {
8080
returnCount++;
@@ -126,13 +126,13 @@ const DatabaseEvents = {
126126
}
127127
},
128128
editorDialog: function (isNew, $this) {
129-
var that = this;
129+
const that = this;
130130
/**
131131
* @var $edit_row jQuery object containing the reference to
132132
* the row of the the item being edited
133133
* from the list of items
134134
*/
135-
var $editRow = null;
135+
let $editRow = null;
136136
if ($this.hasClass('edit_anchor')) {
137137
// Remember the row of the item being edited for later,
138138
// so that if the edit is successful, we can replace the
@@ -144,7 +144,7 @@ const DatabaseEvents = {
144144
* @var $msg jQuery object containing the reference to
145145
* the AJAX message shown to the user
146146
*/
147-
var $msg = ajaxShowMessage();
147+
let $msg = ajaxShowMessage();
148148
$.get($this.attr('href'), { 'ajax_request': true }, function (data) {
149149
if (data.success !== true) {
150150
ajaxShowMessage(data.error, false);
@@ -169,12 +169,12 @@ const DatabaseEvents = {
169169
/**
170170
* @var data Form data to be sent in the AJAX request
171171
*/
172-
var data = $('form.rte_form').last().serialize();
172+
const data = $('form.rte_form').last().serialize();
173173
$msg = ajaxShowMessage(
174174
window.Messages.strProcessingRequest
175175
);
176176

177-
var url = $('form.rte_form').last().attr('action');
177+
const url = $('form.rte_form').last().attr('action');
178178
$.post(url, data, function (data) {
179179
if (data.success !== true) {
180180
ajaxShowMessage(data.error, false);
@@ -205,12 +205,12 @@ const DatabaseEvents = {
205205
* to find the correct location where
206206
* to insert a new row.
207207
*/
208-
var text = '';
208+
let text = '';
209209
/**
210210
* @var inserted Whether a new item has been
211211
* inserted in the list or not
212212
*/
213-
var inserted = false;
213+
let inserted = false;
214214
$('table.data').find('tr').each(function () {
215215
text = $(this)
216216
.children('td')
@@ -258,12 +258,12 @@ const DatabaseEvents = {
258258
/**
259259
* @var ct Count of processed rows
260260
*/
261-
var ct = 0;
261+
let ct = 0;
262262
/**
263263
* @var rowclass Class to be attached to the row
264264
* that is being processed
265265
*/
266-
var rowclass = '';
266+
let rowclass = '';
267267
$('table.data').find('tr').has('td').each(function () {
268268
rowclass = (ct % 2 === 0) ? 'odd' : 'even';
269269
$(this).removeClass().addClass(rowclass);
@@ -319,8 +319,8 @@ const DatabaseEvents = {
319319
* @var elm jQuery object containing the reference to
320320
* the Definition textarea.
321321
*/
322-
var $elm = $('textarea[name=item_definition]').last();
323-
var linterOptions = {
322+
const $elm = $('textarea[name=item_definition]').last();
323+
const linterOptions = {
324324
editorType: 'event',
325325
};
326326
that.syntaxHiglighter = getSqlEditor($elm, {}, 'vertical', linterOptions);
@@ -342,21 +342,21 @@ const DatabaseEvents = {
342342
/**
343343
* @var $curr_row Object containing reference to the current row
344344
*/
345-
var $currRow = $this.parents('tr');
345+
const $currRow = $this.parents('tr');
346346
/**
347347
* @var question String containing the question to be asked for confirmation
348348
*/
349-
var question = $('<div></div>').text(
350-
$currRow.children('td').children('.drop_sql').html()
349+
const question = $('<div></div>').text(
350+
$currRow.children('td').children('.drop_sql').html(),
351351
);
352352
// We ask for confirmation first here, before submitting the ajax request
353353
$this.confirm(question, $this.attr('href'), function (url) {
354354
/**
355355
* @var msg jQuery object containing the reference to
356356
* the AJAX message shown to the user
357357
*/
358-
var $msg = ajaxShowMessage(window.Messages.strProcessingRequest);
359-
var params = getJsConfirmCommonParam(this, $this.getPostData());
358+
const $msg = ajaxShowMessage(window.Messages.strProcessingRequest);
359+
const params = getJsConfirmCommonParam(this, $this.getPostData());
360360
$.post(url, params, function (data) {
361361
if (data.success !== true) {
362362
ajaxShowMessage(data.error, false);
@@ -368,7 +368,7 @@ const DatabaseEvents = {
368368
* @var $table Object containing reference
369369
* to the main list of elements
370370
*/
371-
var $table = $currRow.parent();
371+
const $table = $currRow.parent();
372372
// Check how many rows will be left after we remove
373373
// the one that the user has requested us to remove
374374
if ($table.find('tr').length === 3) {
@@ -390,12 +390,12 @@ const DatabaseEvents = {
390390
/**
391391
* @var ct Count of processed rows
392392
*/
393-
var ct = 0;
393+
let ct = 0;
394394
/**
395395
* @var rowclass Class to be attached to the row
396396
* that is being processed
397397
*/
398-
var rowclass = '';
398+
let rowclass = '';
399399
$table.find('tr').has('td').each(function () {
400400
rowclass = (ct % 2 === 1) ? 'odd' : 'even';
401401
$(this).removeClass().addClass(rowclass);
@@ -420,21 +420,21 @@ const DatabaseEvents = {
420420
* @var msg jQuery object containing the reference to
421421
* the AJAX message shown to the user
422422
*/
423-
var $msg = ajaxShowMessage(window.Messages.strProcessingRequest);
423+
const $msg = ajaxShowMessage(window.Messages.strProcessingRequest);
424424

425425
// drop anchors of all selected rows
426-
var dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
427-
var success = true;
428-
var count = dropAnchors.length;
429-
var returnCount = 0;
426+
const dropAnchors = $('input.checkall:checked').parents('tr').find('.drop_anchor');
427+
let success = true;
428+
const count = dropAnchors.length;
429+
let returnCount = 0;
430430

431431
dropAnchors.each(function () {
432-
var $anchor = $(this);
432+
const $anchor = $(this);
433433
/**
434434
* @var $curr_row Object containing reference to the current row
435435
*/
436-
var $currRow = $anchor.parents('tr');
437-
var params = getJsConfirmCommonParam(this, $anchor.getPostData());
436+
const $currRow = $anchor.parents('tr');
437+
const params = getJsConfirmCommonParam(this, $anchor.getPostData());
438438
$.post($anchor.attr('href'), params, function (data) {
439439
returnCount++;
440440
if (data.success !== true) {
@@ -451,7 +451,7 @@ const DatabaseEvents = {
451451
* @var $table Object containing reference
452452
* to the main list of elements
453453
*/
454-
var $table = $currRow.parent();
454+
const $table = $currRow.parent();
455455
// Check how many rows will be left after we remove
456456
// the one that the user has requested us to remove
457457
if ($table.find('tr').length === 3) {
@@ -471,12 +471,12 @@ const DatabaseEvents = {
471471
/**
472472
* @var ct Count of processed rows
473473
*/
474-
var ct = 0;
474+
let ct = 0;
475475
/**
476476
* @var rowclass Class to be attached to the row
477477
* that is being processed
478478
*/
479-
var rowclass = '';
479+
let rowclass = '';
480480
$table.find('tr').has('td').each(function () {
481481
rowclass = (ct % 2 === 1) ? 'odd' : 'even';
482482
$(this).removeClass().addClass(rowclass);
@@ -510,7 +510,7 @@ const DatabaseEvents = {
510510
* @var elm a jQuery object containing the reference
511511
* to an element that is being validated
512512
*/
513-
var $elm = null;
513+
let $elm = null;
514514
const eventsEditorModal = $('#eventsEditorModal');
515515
if (eventsEditorModal.find('select[name=item_type]').find(':selected').val() === 'RECURRING') {
516516
// The interval field must not be empty for recurring events

0 commit comments

Comments
 (0)