Fix unknown property errors reported by TypeScript

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2023-04-18 20:21:48 -03:00
parent f8cfc5545a
commit e183e22d2f
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
29 changed files with 210 additions and 114 deletions

2
js/global.d.ts vendored
View File

@ -14,7 +14,9 @@ interface Window {
opera: any;
zxcvbnts: any;
msCrypto: any;
u2f: any;
drawOpenLayers: () => any;
variableNames: string[];
}
interface JQuery {

View File

@ -248,6 +248,7 @@ JQPlotChart.prototype.redraw = function (options) {
JQPlotChart.prototype.toImageString = function () {
if (this.plot !== null) {
// @ts-ignore
return $('#' + this.elementId).jqplotToImageStr({});
}
};

View File

@ -191,6 +191,7 @@ const DatabaseEvents = {
};
// Now define the function that is called when
// the user presses the "Go" button
// @ts-ignore
buttonOptions[window.Messages.strGo].click = function () {
// Move the data from the codemirror editor back to the
// textarea, where it can be used in the form submission.
@ -319,6 +320,7 @@ const DatabaseEvents = {
} // end "if (that.validate())"
}; // end of function that handles the submission of the Editor
// @ts-ignore
buttonOptions[window.Messages.strClose].click = function () {
$(this).dialog('close');
};
@ -353,6 +355,7 @@ const DatabaseEvents = {
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
});
// @ts-ignore
$.datepicker.initialized = false;
},
close: function () {
@ -587,6 +590,7 @@ AJAX.registerOnload('database/events.js', function () {
event.preventDefault();
if ($(this).hasClass('add_anchor')) {
// @ts-ignore
$.datepicker.initialized = false;
}

View File

@ -203,6 +203,7 @@ const DatabaseRoutines = {
ajaxRemoveMessage($msg);
// Now define the function that is called when
// the user presses the "Go" button
// @ts-ignore
buttonOptions[window.Messages.strGo].click = function () {
// Move the data from the codemirror editor back to the
// textarea, where it can be used in the form submission.
@ -335,6 +336,7 @@ const DatabaseRoutines = {
}); // end $.post()
}; // end of function that handles the submission of the Editor
// @ts-ignore
buttonOptions[window.Messages.strClose].click = function () {
$(this).dialog('close');
};
@ -368,6 +370,7 @@ const DatabaseRoutines = {
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
});
// @ts-ignore
$.datepicker.initialized = false;
},
close: function () {
@ -686,7 +689,7 @@ const DatabaseRoutines = {
var $inputtyp = $(this).find('select[name^=item_param_type]');
var $inputlen = $(this).find('input[name^=item_param_length]');
if ($inputtyp.length && $inputlen.length) {
if (($inputtyp.val() === 'ENUM' || $inputtyp.val() === 'SET' || $inputtyp.val().startsWith('VAR')) &&
if (($inputtyp.val() === 'ENUM' || $inputtyp.val() === 'SET' || ($inputtyp.val() as string).startsWith('VAR')) &&
$inputlen.val() === ''
) {
$inputlen.trigger('focus');
@ -858,6 +861,7 @@ const DatabaseRoutines = {
};
// Define the function that is called when
// the user presses the "Go" button
// @ts-ignore
buttonOptions[window.Messages.strGo].click = function () {
/**
* @var data Form data to be sent in the AJAX request
@ -879,6 +883,7 @@ const DatabaseRoutines = {
});
};
// @ts-ignore
buttonOptions[window.Messages.strClose].click = function () {
$(this).dialog('close');
};
@ -945,6 +950,7 @@ const DatabaseRoutines = {
AJAX.registerOnload('database/routines.js', function () {
$(document).on('click', 'a.ajax.add_anchor', function (event) {
event.preventDefault();
// @ts-ignore
$.datepicker.initialized = false;
DatabaseRoutines.editorDialog(true, $(this));
});

View File

@ -15,9 +15,6 @@ import { escapeHtml } from '../modules/functions/escape.ts';
* @requires jQueryUI
*/
var DatabaseStructure = {};
window.DatabaseStructure = DatabaseStructure;
/**
* AJAX scripts for /database/structure
*
@ -45,7 +42,7 @@ AJAX.registerTeardown('database/structure.js', function () {
* Adjust number of rows and total size in the summary
* when truncating, creating, dropping or inserting into a table
*/
DatabaseStructure.adjustTotals = function () {
const adjustTotals = function () {
var byteUnits = [
window.Messages.strB,
window.Messages.strKiB,
@ -160,7 +157,7 @@ DatabaseStructure.adjustTotals = function () {
* Gets the real row count for a table or DB.
* @param {object} $target Target for appending the real count value.
*/
DatabaseStructure.fetchRealRowCount = function ($target) {
const fetchRealRowCount = function ($target) {
var $throbber = $('#pma_navigation').find('.throbber')
.first()
.clone()
@ -272,7 +269,7 @@ AJAX.registerOnload('database/structure.js', function () {
}).done(function (modalBody) {
const bulkActionModal = $('#bulkActionModal');
bulkActionModal.on('show.bs.modal', function () {
this.querySelector('.modal-title').innerText = modalTitle;
(this.querySelector('.modal-title') as HTMLHeadingElement).innerText = modalTitle;
this.querySelector('.modal-body').innerHTML = modalBody;
});
@ -460,8 +457,15 @@ AJAX.registerOnload('database/structure.js', function () {
});
});
const DatabaseStructure = {
adjustTotals: adjustTotals,
fetchRealRowCount: fetchRealRowCount,
};
declare global {
interface Window {
DatabaseStructure: typeof DatabaseStructure;
}
}
window.DatabaseStructure = DatabaseStructure;

View File

@ -131,6 +131,7 @@ const DatabaseTriggers = {
class: 'btn btn-primary',
},
};
// @ts-ignore
buttonOptions[window.Messages.strClose].click = function () {
$(this).dialog('close').remove();
};
@ -197,6 +198,7 @@ const DatabaseTriggers = {
ajaxRemoveMessage($msg);
// Now define the function that is called when
// the user presses the "Go" button
// @ts-ignore
buttonOptions[window.Messages.strGo].click = function () {
// Move the data from the codemirror editor back to the
// textarea, where it can be used in the form submission.
@ -327,6 +329,7 @@ const DatabaseTriggers = {
}); // end $.post()
}; // end of function that handles the submission of the Editor
// @ts-ignore
buttonOptions[window.Messages.strClose].click = function () {
$(this).dialog('close');
};
@ -360,6 +363,7 @@ const DatabaseTriggers = {
Functions.addDatepicker($(this).css('width', '95%'), 'datetime');
});
// @ts-ignore
$.datepicker.initialized = false;
},
close: function () {
@ -561,6 +565,7 @@ AJAX.registerOnload('database/triggers.js', function () {
event.preventDefault();
if ($(this).hasClass('add_anchor')) {
// @ts-ignore
$.datepicker.initialized = false;
}

View File

@ -78,6 +78,7 @@ var DragDropImport = {
if (xhrobj.upload) {
xhrobj.upload.addEventListener('progress', function (event) {
var percent = 0;
// @ts-ignore
var position = event.loaded || event.position;
var total = event.total;
if (event.lengthComputable) {

View File

@ -96,7 +96,7 @@ var ErrorReport = {
const postData = $.extend(reportData, {
'send_error_report': true,
'description': $('#errorReportDescription').val(),
'always_send': $('#errorReportAlwaysSendCheckbox')[0].checked
'always_send': ($('#errorReportAlwaysSendCheckbox') as JQuery<HTMLInputElement>)[0].checked
});
$.post('index.php?route=/error-report', postData, function (data) {
if (data.success === false) {
@ -228,7 +228,7 @@ var ErrorReport = {
}
}
var reportData = {
var reportData: { exception: any; server: any; ajax_request: boolean; exception_type: string; url: string, scripts?: any[] } = {
'server': CommonParams.get('server'),
'ajax_request': true,
'exception': exception,
@ -262,9 +262,11 @@ var ErrorReport = {
}
};
// @ts-ignore
newFunc.wrapped = true;
// Set guid of wrapped function same as original function, so it can be removed
// See bug#4146 (problem with jquery draggable and sortable)
// @ts-ignore
newFunc.guid = func.guid = func.guid || newFunc.guid || $.guid++;
return newFunc;

View File

@ -66,7 +66,7 @@ function getTemplateData () {
// include unchecked checkboxes (which are ignored by serializeArray()) with null
// to uncheck them when loading the template
$form.find('input[type="checkbox"]:not(:checked)').each(function () {
($form.find('input[type="checkbox"]:not(:checked)') as JQuery<HTMLInputElement>).each(function () {
if (obj[this.name] === undefined) {
obj[this.name] = null;
}
@ -266,7 +266,7 @@ AJAX.registerOnload('export.js', function () {
// create a new template
$('input[name="createTemplate"]').on('click', function (e) {
e.preventDefault();
var name = $('input[name="templateName"]').val();
var name = ($('input[name="templateName"]').val() as string);
if (name.length) {
Export.createTemplate(name);
}
@ -275,7 +275,7 @@ AJAX.registerOnload('export.js', function () {
// load an existing template
$('select[name="template"]').on('change', function (e) {
e.preventDefault();
var id = $(this).val();
var id = ($(this).val() as string);
if (id.length) {
Export.loadTemplate(id);
}
@ -284,7 +284,7 @@ AJAX.registerOnload('export.js', function () {
// update an existing template with new criteria
$('input[name="updateTemplate"]').on('click', function (e) {
e.preventDefault();
var id = $('select[name="template"]').val();
var id = ($('select[name="template"]').val() as string);
if (id.length) {
Export.updateTemplate(id);
}
@ -293,7 +293,7 @@ AJAX.registerOnload('export.js', function () {
// delete an existing template
$('input[name="deleteTemplate"]').on('click', function (e) {
e.preventDefault();
var id = $('select[name="template"]').val();
var id = ($('select[name="template"]').val() as string);
if (id.length) {
Export.deleteTemplate(id);
}

View File

@ -111,7 +111,7 @@ AJAX.registerOnload('import.js', function () {
}
if ($('#text_csv_new_tbl_name').length > 0) {
var newTblName = $('#text_csv_new_tbl_name').val();
var newTblName = ($('#text_csv_new_tbl_name').val() as string);
if (newTblName.length > 0 && newTblName.trim().length === 0) {
ajaxShowMessage(wrongTblNameMsg, false);
@ -120,7 +120,7 @@ AJAX.registerOnload('import.js', function () {
}
if ($('#text_csv_new_db_name').length > 0) {
var newDBName = $('#text_csv_new_db_name').val();
var newDBName = ($('#text_csv_new_db_name').val() as string);
if (newDBName.length > 0 && newDBName.trim().length === 0) {
ajaxShowMessage(wrongDBNameMsg, false);
@ -165,8 +165,8 @@ AJAX.registerOnload('import.js', function () {
* if first character is escape then allow two including escape character.
*/
$('#text_csv_enclosed').add('#text_csv_escaped').on('keyup', function () {
if ($(this).val().length === 2 && $(this).val().charAt(0) !== '\\') {
$(this).val($(this).val().substring(0, 1));
if (($(this).val() as string).length === 2 && ($(this).val() as string).charAt(0) !== '\\') {
$(this).val(($(this).val() as string).substring(0, 1));
return false;
}

View File

@ -22,13 +22,13 @@ import { escapeHtml } from './modules/functions/escape.ts';
* @param enableVisib Optional, if false, show/hide column feature will be disabled
* @param enableGridEdit Optional, if false, grid editing feature will be disabled
*/
window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableGridEdit) {
const makeGrid = function (t, enableResize = undefined, enableReorder = undefined, enableVisib = undefined, enableGridEdit = undefined) {
var isResizeEnabled = enableResize === undefined ? true : enableResize;
var isReorderEnabled = enableReorder === undefined ? true : enableReorder;
var isVisibEnabled = enableVisib === undefined ? true : enableVisib;
var isGridEditEnabled = enableGridEdit === undefined ? true : enableGridEdit;
var g = {
var g: { [p: string]: any } = {
/** *********
* Constant
***********/
@ -800,8 +800,8 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
// destroy datepicker in edit area, if exist
var $dp = $(g.cEdit).find('.hasDatepicker');
if ($dp.length > 0) {
// eslint-disable-next-line no-underscore-dangle
$(document).on('mousedown', $.datepicker._checkExternalClick);
// @ts-ignore
$(document).on('mousedown', $.datepicker._checkExternalClick); // eslint-disable-line no-underscore-dangle
$dp.datepicker('refresh');
// change the cursor in edit box back to normal
@ -1058,7 +1058,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
$editArea.removeClass('edit_area_loading');
$editArea.append(data.select);
$td.data('original_data', $(data.select).val().join());
$td.data('original_data', ($(data.select).val() as string[]).join());
$editArea.append('<div class="cell_edit_hint">' + g.cellEditHint + '</div>');
}); // end $.post()
@ -1122,7 +1122,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
var $inputField = $(g.cEdit).find('.edit_box');
// remember current datetime value in $input_field, if it is not null
var datetimeValue = ! isNull ? $inputField.val() : '';
var datetimeValue = ! isNull ? ($inputField.val() as string) : '';
var showMillisec = false;
var showMicrosec = false;
@ -1180,8 +1180,8 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
// unbind the mousedown event to prevent the problem of
// datepicker getting closed, needs to be checked for any
// change in names when updating
// eslint-disable-next-line no-underscore-dangle
$(document).off('mousedown', $.datepicker._checkExternalClick);
// @ts-ignore
$(document).off('mousedown', $.datepicker._checkExternalClick); // eslint-disable-line no-underscore-dangle
// move ui-datepicker-div inside cEdit div
var datepickerDiv = $('#ui-datepicker-div');
@ -1272,7 +1272,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
// loop each edited row
$(g.t).find('td.to_be_saved').parents('tr').each(function () {
var $tr = $(this);
var whereClause = $tr.find('.where_clause').val();
var whereClause = ($tr.find('.where_clause').val() as string);
if (typeof whereClause === 'undefined') {
whereClause = '';
}
@ -1462,7 +1462,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
$(this).find('input[type=checkbox]').each(function () {
var $checkbox = $(this);
var checkboxName = $checkbox.attr('name');
var checkboxValue = $checkbox.val();
var checkboxValue = ($checkbox.val() as string);
$checkbox.attr('name', checkboxName.replace(oldClause, newClause));
$checkbox.val(checkboxValue.replace(decodedOldClause, decodedNewClause));
@ -1529,7 +1529,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
* @var $thisField Object referring to the td that is being edited
*/
var $thisField = $(g.currentEditCell);
var $testElement = ''; // to test the presence of a element
var $testElement = null; // to test the presence of a element
var needToPost = false;
@ -1561,7 +1561,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
if ($thisField.is('.bit')) {
thisFieldParams[fieldName] = $(g.cEdit).find('.edit_box').val();
} else if ($thisField.is('.set')) {
$testElement = $(g.cEdit).find('select');
$testElement = ($(g.cEdit).find('select') as JQuery<HTMLSelectElement>);
thisFieldParams[fieldName] = $testElement.map(function () {
return $(this).val();
}).get().join(',');
@ -1571,7 +1571,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
// selection list will always be updated to the edit box
thisFieldParams[fieldName] = $(g.cEdit).find('.edit_box').val();
} else if ($thisField.hasClass('hex')) {
if ($(g.cEdit).find('.edit_box').val().match(/^(0x)?[a-f0-9]*$/i) !== null) {
if (($(g.cEdit).find('.edit_box').val() as string).match(/^(0x)?[a-f0-9]*$/i) !== null) {
thisFieldParams[fieldName] = $(g.cEdit).find('.edit_box').val();
} else {
var hexError = '<div class="alert alert-danger" role="alert">' + window.Messages.strEnterValidHex + '</div>';
@ -1716,7 +1716,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
var $colOrder = $(g.o).find('.col_order'); // check if column order is passed from PHP
var i;
if ($colOrder.length > 0) {
g.colOrder = $colOrder.val().split(',');
g.colOrder = ($colOrder.val() as string).split(',');
for (i = 0; i < g.colOrder.length; i++) {
g.colOrder[i] = parseInt(g.colOrder[i], 10);
}
@ -1805,7 +1805,7 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
// initialize column visibility
var $colVisib = $(g.o).find('.col_visib'); // check if column visibility is passed from PHP
if ($colVisib.length > 0) {
g.colVisib = $colVisib.val().split(',');
g.colVisib = ($colVisib.val() as string).split(',');
for (i = 0; i < g.colVisib.length; i++) {
g.colVisib[i] = parseInt(g.colVisib[i], 10);
}
@ -2392,6 +2392,14 @@ window.makeGrid = function (t, enableResize, enableReorder, enableVisib, enableG
$(g.gDiv).addClass('data');
};
declare global {
interface Window {
makeGrid: typeof makeGrid;
}
}
window.makeGrid = makeGrid;
/**
* jQuery plugin to cancel selection in HTML code.
*/

View File

@ -103,23 +103,23 @@ var Console = {
if (Console.isInitialized === false) {
// Load config first
if (Config.AlwaysExpand) {
document.getElementById('consoleOptionsAlwaysExpandCheckbox').checked = true;
(document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked = true;
}
if (Config.StartHistory) {
document.getElementById('consoleOptionsStartHistoryCheckbox').checked = true;
(document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked = true;
}
if (Config.CurrentQuery) {
document.getElementById('consoleOptionsCurrentQueryCheckbox').checked = true;
(document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked = true;
}
if (Config.EnterExecutes) {
document.getElementById('consoleOptionsEnterExecutesCheckbox').checked = true;
(document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked = true;
}
if (Config.DarkTheme) {
document.getElementById('consoleOptionsDarkThemeCheckbox').checked = true;
(document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked = true;
$('#pma_console').find('>.content').addClass('console_dark_theme');
}
@ -179,11 +179,11 @@ var Console = {
});
$('#pma_console_options').find('.button.default').on('click', function () {
document.getElementById('consoleOptionsAlwaysExpandCheckbox').checked = false;
document.getElementById('consoleOptionsStartHistoryCheckbox').checked = false;
document.getElementById('consoleOptionsCurrentQueryCheckbox').checked = true;
document.getElementById('consoleOptionsEnterExecutesCheckbox').checked = false;
document.getElementById('consoleOptionsDarkThemeCheckbox').checked = false;
(document.getElementById('consoleOptionsAlwaysExpandCheckbox') as HTMLInputElement).checked = false;
(document.getElementById('consoleOptionsStartHistoryCheckbox') as HTMLInputElement).checked = false;
(document.getElementById('consoleOptionsCurrentQueryCheckbox') as HTMLInputElement).checked = true;
(document.getElementById('consoleOptionsEnterExecutesCheckbox') as HTMLInputElement).checked = false;
(document.getElementById('consoleOptionsDarkThemeCheckbox') as HTMLInputElement).checked = false;
Config.update();
});
@ -267,6 +267,7 @@ var Console = {
}
Console.$requestForm.children('[name=console_message_id]')
// @ts-ignore
.val(ConsoleMessages.appendQuery({ 'sql_query': queryString }).message_id);
Console.$requestForm.trigger('submit');
@ -280,6 +281,7 @@ var Console = {
} else if (data && data.reloadQuerywindow) {
if (data.reloadQuerywindow.sql_query.length > 0) {
ConsoleMessages.appendQuery(data.reloadQuerywindow, 'successed')
// @ts-ignore
.$message.addClass(Config.CurrentQuery ? '' : 'hide');
}
}
@ -518,6 +520,7 @@ var ConsoleInput = {
hintOptions: { 'completeSingle': false, 'completeOnSingleClick': true },
gutters: ['CodeMirror-lint-markers'],
lint: {
// @ts-ignore
'getAnnotations': CodeMirror.sqlLint,
'async': true,
}
@ -539,6 +542,7 @@ var ConsoleInput = {
hintOptions: { 'completeSingle': false, 'completeOnSingleClick': true },
gutters: ['CodeMirror-lint-markers'],
lint: {
// @ts-ignore
'getAnnotations': CodeMirror.sqlLint,
'async': true,
}
@ -810,6 +814,7 @@ var ConsoleMessages = {
case 'query':
$newMessage.append('<div class="query highlighted"></div>');
if (ConsoleInput.codeMirror) {
// @ts-ignore
CodeMirror.runMode(msgString,
'text/x-sql', $newMessage.children('.query')[0]);
} else {
@ -994,6 +999,7 @@ var ConsoleMessages = {
if (ConsoleInput.codeMirror) {
$targetMessage.find('.query:not(.highlighted)').each(function (index, elem) {
// @ts-ignore
CodeMirror.runMode($(elem).text(),
'text/x-sql', elem);
@ -1026,6 +1032,7 @@ var ConsoleMessages = {
}
if (ConsoleInput.codeMirror) {
// @ts-ignore
CodeMirror.runMode(queryData.sql_query, 'text/x-sql', $targetMessage.children('.query')[0]);
} else {
$targetMessage.children('.query').text(queryData.sql_query);
@ -1111,7 +1118,7 @@ var ConsoleBookmarks = {
});
$('#pma_bookmarks').find('.card.add [name=submit]').on('click', function () {
if ($('#pma_bookmarks').find('.card.add [name=label]').val().length === 0
if (($('#pma_bookmarks').find('.card.add [name=label]').val() as string).length === 0
|| ConsoleInput.getText('bookmark').length === 0) {
alert(window.Messages.strFormEmpty);
@ -1418,7 +1425,7 @@ var ConsoleDebug = {
$('#debug_console').find('.debugLog').empty();
$('#debug_console').find('.debug>.welcome').empty();
var debugJson = false;
var debugJson: any = false;
var i;
if (typeof debugInfo === 'object' && 'queries' in debugInfo) {
// Copy it to debugJson, so that it doesn't get changed
@ -1451,7 +1458,7 @@ var ConsoleDebug = {
}
var allQueries = debugJson.queries;
var uniqueQueries = {};
var uniqueQueries = [];
var totalExec = allQueries.length;

View File

@ -34,7 +34,7 @@ let sqlAutoCompleteInProgress = false;
* Object containing list of columns in each table.
* @type {(any[]|boolean)}
*/
let sqlAutoComplete = false;
let sqlAutoComplete: boolean | any[] = false;
/**
* String containing default table to autocomplete columns.
@ -232,10 +232,12 @@ function getSqlEditor ($textarea, options = undefined, resize = undefined, lintO
lineWrapping: true
};
// @ts-ignore
if (window.CodeMirror.sqlLint) {
$.extend(defaults, {
gutters: ['CodeMirror-lint-markers'],
lint: {
// @ts-ignore
'getAnnotations': window.CodeMirror.sqlLint,
'async': true,
'lintOptions': lintOptions
@ -276,7 +278,9 @@ function getSqlEditor ($textarea, options = undefined, resize = undefined, lintO
* Clear text selection
*/
function clearSelection () {
// @ts-ignore
if (document.selection && document.selection.empty) {
// @ts-ignore
document.selection.empty();
} else if (window.getSelection) {
var sel = window.getSelection();
@ -456,7 +460,7 @@ function displayPasswordGenerateButton () {
pwdCell.append('<div class="d-flex align-items-center col-4"></div>');
var pwdButton = $('<input>')
var pwdButton = ($('<input>') as JQuery<HTMLInputElement>)
.attr({ type: 'button', id: 'button_generate_password', value: window.Messages.strGenerate })
.addClass('btn btn-secondary button')
.on('click', function () {
@ -1092,7 +1096,7 @@ function onloadSqlQueryEditEvents () {
}
var $form = $(this).prev('form');
var sqlQuery = $form.find('input[name=\'sql_query\']').val().trim();
var sqlQuery = ($form.find('input[name=\'sql_query\']').val() as string).trim();
var $innerSql = $(this).parent().prev().find('code.sql');
var newContent = '<textarea name="sql_query_edit" id="sql_query_edit">' + escapeHtml(sqlQuery) + '</textarea>\n';
@ -1216,6 +1220,7 @@ function codeMirrorAutoCompleteOnInputRead (instance) {
displayText += ' | Unique';
}
// @ts-ignore
table.columns.push({
text: column,
displayText: column + ' | ' + displayText,
@ -1256,6 +1261,7 @@ function codeMirrorAutoCompleteOnInputRead (instance) {
}
if (string.length > 0) {
// @ts-ignore
window.CodeMirror.commands.autocomplete(instance);
}
}
@ -1337,6 +1343,7 @@ function updateCode ($base, htmlValue, rawValue) {
// Tries to highlight code using CodeMirror.
if (typeof window.CodeMirror !== 'undefined') {
var $highlighted = $('<div class="' + type + '-highlight cm-s-default"></div>');
// @ts-ignore
window.CodeMirror.runMode(rawValue, mode, $highlighted[0]);
$notHighlighted.hide();
$code.html('').append($notHighlighted, $highlighted[0]);
@ -1800,15 +1807,18 @@ function sortTable (textSelector) {
// get the text of the field that we will sort by
$.each(rows, function (index, row) {
// @ts-ignore
row.sortKey = $(row).find(textSelector).text().toLowerCase().trim();
});
// get the sorted order
rows.sort(function (a, b) {
// @ts-ignore
if (a.sortKey < b.sortKey) {
return -1;
}
// @ts-ignore
if (a.sortKey > b.sortKey) {
return 1;
}
@ -1819,6 +1829,7 @@ function sortTable (textSelector) {
// pull out each row from the table and then append it according to it's order
$.each(rows, function (index, row) {
$(tableBody).append(row);
// @ts-ignore
row.sortKey = null;
});
});
@ -2908,7 +2919,7 @@ function showIndexEditDialog ($outer) {
* omit this parameter the function searches
* in the whole body
**/
function showHints ($div = undefined) {
function showHints ($div: JQuery<HTMLElement> | undefined = undefined) {
var $newDiv = $div;
if ($newDiv === undefined || ! ($newDiv instanceof $) || $newDiv.length === 0) {
$newDiv = $('body');

View File

@ -160,6 +160,12 @@ function goToStep4 () {
);
}
declare global {
interface Window {
goToStep4: typeof goToStep4;
}
}
window.goToStep4 = goToStep4;
function goToStep3 () {

View File

@ -107,11 +107,11 @@ AJAX.registerOnload('replication.js', function () {
});
});
$('#button_generate_password').on('click', function () {
($('#button_generate_password') as JQuery<HTMLInputElement>).on('click', function () {
Functions.suggestPassword(this.form);
});
$('#nopass_1').on('click', function () {
($('#nopass_1') as JQuery<HTMLInputElement>).on('click', function () {
this.form.pma_pw.value = '';
this.form.pma_pw2.value = '';
this.checked = true;

View File

@ -256,7 +256,7 @@ const RevokeUser = {
// Remove the revoked user from the users list
$form.find('input:checkbox:checked').parents('tr').slideUp('medium', function () {
var thisUserInitial = $(this).find('input:checkbox').val().charAt(0).toUpperCase();
var thisUserInitial = ($(this).find('input:checkbox').val() as string).charAt(0).toUpperCase();
$(this).remove();
// If this is the last user with thisUserInitial, remove the link from #userAccountsPagination
@ -437,7 +437,7 @@ const SelectAllPrivileges = {
handleEvent: function (event) {
const method = event.target.getAttribute('data-select-target');
var options = $(method).first().children();
options.each(function (_, obj) {
options.each(function (_, obj: HTMLOptionElement) {
obj.selected = true;
});
}

View File

@ -15,7 +15,7 @@ import isStorageSupported from '../../modules/functions/isStorageSupported.ts';
* @requires jQueryUI
*/
var runtime = {};
var runtime: { [k: string]: any } = {};
var serverTimeDiff;
var serverOs;
var isSuperUser;
@ -236,7 +236,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
var editMode = false;
/* List of preconfigured charts that the user may select */
var presetCharts = {
var presetCharts: { [p: string]: any } = {
// Query cache efficiency
'qce': {
title: window.Messages.strQueryCacheEfficiency,
@ -433,7 +433,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
}
// Default setting for the chart grid
var defaultChartGrid = {
var defaultChartGrid: { [p: string]: any } = {
'c0': {
title: window.Messages.strQuestions,
series: [{ label: window.Messages.strQuestions }],
@ -512,7 +512,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
});
// global settings
$('div.popupContent select[name="chartColumns"]').on('change', function () {
($('div.popupContent select[name="chartColumns"]') as JQuery<HTMLSelectElement>).on('change', function () {
monitorSettings.columns = parseInt(this.value, 10);
calculateChartSize();
@ -578,7 +578,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
saveMonitor(); // Save settings
});
$('div.popupContent select[name="gridChartRefresh"]').on('change', function () {
($('div.popupContent select[name="gridChartRefresh"]') as JQuery<HTMLSelectElement>).on('change', function () {
monitorSettings.gridRefresh = parseInt(this.value, 10) * 1000;
clearTimeout(runtime.refreshTimeout);
@ -691,7 +691,9 @@ AJAX.registerOnload('server/status/monitor.js', function () {
var blob = new Blob([JSON.stringify(exportData)], { type: 'application/octet-stream' });
var url = null;
var fileName = 'monitor-config.json';
// @ts-ignore
if (window.navigator && window.navigator.msSaveOrOpenBlob) {
// @ts-ignore
window.navigator.msSaveOrOpenBlob(blob, fileName);
} else {
url = URL.createObjectURL(blob);
@ -732,8 +734,9 @@ AJAX.registerOnload('server/status/monitor.js', function () {
},
};
// @ts-ignore
dlgBtns[window.Messages.strImport].click = function () {
var input = $('#emptyDialog').find('#import_file')[0];
var input = ($('#emptyDialog').find('#import_file') as JQuery<HTMLInputElement>)[0];
var reader = new FileReader();
reader.onerror = function (event) {
@ -788,6 +791,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
}
};
// @ts-ignore
dlgBtns[window.Messages.strCancel].click = function () {
$(this).dialog('close');
};
@ -985,7 +989,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
return false;
});
$('input[name="chartType"]').on('change', function () {
($('input[name="chartType"]') as JQuery<HTMLInputElement>).on('change', function () {
$('#chartVariableSettings').toggle(this.checked && this.value === 'variable');
var title = $('input[name="chartTitle"]').val();
if (title === window.Messages.strChartTitle ||
@ -997,15 +1001,15 @@ AJAX.registerOnload('server/status/monitor.js', function () {
}
});
$('input[name="useDivisor"]').on('change', function () {
($('input[name="useDivisor"]') as JQuery<HTMLInputElement>).on('change', function () {
$('span.divisorInput').toggle(this.checked);
});
$('input[name="useUnit"]').on('change', function () {
($('input[name="useUnit"]') as JQuery<HTMLInputElement>).on('change', function () {
$('span.unitInput').toggle(this.checked);
});
$('select[name="varChartList"]').on('change', function () {
($('select[name="varChartList"]') as JQuery<HTMLSelectElement>).on('change', function () {
if (this.selectedIndex !== 0) {
$('#variableInput').val(this.value);
}
@ -1055,7 +1059,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
};
}
var serie = {
var serie: { [p: string]: any } = {
dataPoints: [{ type: 'statusvar', name: $('#variableInput').val() }],
display: $('input[name="differentialValue"]').prop('checked') ? 'differential' : ''
};
@ -1077,7 +1081,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
str += serie.unit ? (', ' + window.Messages.strUnit + ': ' + serie.unit) : '';
var newSeries = {
label: $('#variableInput').val().replace(/_/g, ' ')
label: ($('#variableInput').val() as string).replace(/_/g, ' ')
};
newChart.series.push(newSeries);
$('#seriesPreview').append('- ' + escapeHtml(newSeries.label + str) + '<br>');
@ -1088,7 +1092,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
$('input[name="useUnit"]').prop('checked', false);
$('input[name="useDivisor"]').trigger('change');
$('input[name="useUnit"]').trigger('change');
$('select[name="varChartList"]').get(0).selectedIndex = 0;
($('select[name="varChartList"]') as JQuery<HTMLSelectElement>).get(0).selectedIndex = 0;
$('#clearSeriesLink').show();
@ -1250,7 +1254,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
/* Adds a chart to the chart grid */
function addChart (chartObj, initialize = undefined) {
var i;
var settings = {
var settings: { [p: string]: any } = {
title: escapeHtml(chartObj.title),
grid: {
drawBorder: false,
@ -1524,11 +1528,13 @@ AJAX.registerOnload('server/status/monitor.js', function () {
},
};
// @ts-ignore
dlgBtns[window.Messages.strFromSlowLog].click = function () {
loadLog('slow', min, max);
$(this).dialog('close');
};
// @ts-ignore
dlgBtns[window.Messages.strFromGeneralLog].click = function () {
loadLog('general', min, max);
$(this).dialog('close');
@ -1829,6 +1835,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
},
};
// @ts-ignore
dlgBtns[window.Messages.strCancelRequest].click = function () {
if (logRequest !== null) {
logRequest.abort();
@ -1885,6 +1892,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
$('#emptyDialog').html('<p>' + window.Messages.strNoDataFound + '</p>');
// @ts-ignore
dlgBtns[window.Messages.strClose].click = function () {
$(this).dialog('close');
};
@ -1905,7 +1913,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
});
$('#emptyDialog').html('<p>' + window.Messages.strLogDataLoaded + '</p>');
$.each(logData.sum, function (key, value) {
$.each(logData.sum, function (key: string, value) {
var newKey = key.charAt(0).toUpperCase() + key.slice(1).toLowerCase();
if (newKey === 'Total') {
newKey = '<b>' + newKey + '</b>';
@ -1965,7 +1973,7 @@ AJAX.registerOnload('server/status/monitor.js', function () {
*/
function filterQueries (varFilterChange) {
var textFilter;
var val = $('#filterQueryText').val();
var val = ($('#filterQueryText').val() as string);
if (val.length === 0) {
textFilter = null;
@ -2251,10 +2259,12 @@ AJAX.registerOnload('server/status/monitor.js', function () {
},
};
// @ts-ignore
dlgBtns[window.Messages.strAnalyzeQuery].click = function () {
profilingChart = loadQueryAnalysis(rowData);
};
// @ts-ignore
dlgBtns[window.Messages.strClose].click = function () {
$(this).dialog('close');
};

View File

@ -148,7 +148,7 @@ var processList = {
* @return {object} urlParams - url parameters with autoRefresh request
*/
getUrlParams: function () {
var urlParams = {
var urlParams: { [k: string]: any } = {
'server': CommonParams.get('server'),
'ajax_request': true,
'refresh': true,

View File

@ -21,21 +21,21 @@ AJAX.registerOnload('server/status/variables.js', function () {
// Filters for status variables
var textFilter = null;
var alertFilter = $('#filterAlert').prop('checked');
var categoryFilter = $('#filterCategory').find(':selected').val();
var categoryFilter = ($('#filterCategory').find(':selected').val() as string);
var text = ''; // Holds filter text
/* 3 Filtering functions */
$('#filterAlert').on('change', function () {
($('#filterAlert') as JQuery<HTMLInputElement>).on('change', function () {
alertFilter = this.checked;
filterVariables();
});
$('#filterCategory').on('change', function () {
categoryFilter = $(this).val();
categoryFilter = ($(this).val() as string);
filterVariables();
});
$('#dontFormat').on('change', function () {
($('#dontFormat') as JQuery<HTMLInputElement>).on('change', function () {
// Hiding the table while changing values speeds up the process a lot
const serverStatusVariables = $('#serverStatusVariables');
serverStatusVariables.hide();
@ -45,7 +45,7 @@ AJAX.registerOnload('server/status/variables.js', function () {
}).trigger('change');
$('#filterText').on('keyup', function () {
var word = $(this).val().replace(/_/g, ' ');
var word = ($(this).val() as string).replace(/_/g, ' ');
if (word.length === 0 || word.length >= 32768) {
textFilter = null;
} else {

View File

@ -22,14 +22,16 @@ AJAX.registerTeardown('server/user_groups.js', function () {
AJAX.registerOnload('server/user_groups.js', function () {
const deleteUserGroupModal = $('#deleteUserGroupModal');
deleteUserGroupModal.on('show.bs.modal', function (event) {
// @ts-ignore
const userGroupName = $(event.relatedTarget).data('user-group');
this.querySelector('.modal-body').innerText = window.sprintf(
(this.querySelector('.modal-body') as HTMLDivElement).innerText = window.sprintf(
window.Messages.strDropUserGroupWarning,
escapeHtml(userGroupName)
);
});
deleteUserGroupModal.on('shown.bs.modal', function (event) {
// @ts-ignore
const userGroupName = $(event.relatedTarget).data('user-group');
$('#deleteUserGroupConfirm').on('click', function () {
$.post(

View File

@ -98,7 +98,9 @@ function setShowThisQuery () {
if (db === storedDb && table === storedTable) {
if (window.codeMirrorEditor) {
window.codeMirrorEditor.setValue(storedQuery);
// @ts-ignore
} else if (document.sqlform) {
// @ts-ignore
document.sqlform.sql_query.value = storedQuery;
}
}
@ -246,8 +248,11 @@ const setQuery = function (query): void {
if (window.codeMirrorEditor) {
window.codeMirrorEditor.setValue(query);
window.codeMirrorEditor.focus();
// @ts-ignore
} else if (document.sqlform) {
// @ts-ignore
document.sqlform.sql_query.value = query;
// @ts-ignore
document.sqlform.sql_query.focus();
}
};
@ -317,7 +322,9 @@ const insertQuery = function (queryType) {
}
var query = '';
// @ts-ignore
var myListBox = document.sqlform.dummy;
// @ts-ignore
table = document.sqlform.table.value;
if (myListBox.options.length > 0) {
@ -361,7 +368,9 @@ const insertQuery = function (queryType) {
*
*/
const insertValueQuery = function () {
// @ts-ignore
var myQuery = document.sqlform.sql_query;
// @ts-ignore
var myListBox = document.sqlform.dummy;
if (myListBox.options.length > 0) {
@ -384,14 +393,20 @@ const insertValueQuery = function () {
window.codeMirrorEditor.replaceSelection(columnsList);
window.codeMirrorEditor.focus();
// IE support
// @ts-ignore
} else if (document.selection) {
myQuery.focus();
// @ts-ignore
var sel = document.selection.createRange();
sel.text = columnsList;
// MOZILLA/NETSCAPE support
// @ts-ignore
} else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart === '0') {
// @ts-ignore
var startPos = document.sqlform.sql_query.selectionStart;
// @ts-ignore
var endPos = document.sqlform.sql_query.selectionEnd;
// @ts-ignore
var SqlString = document.sqlform.sql_query.value;
myQuery.value = SqlString.substring(0, startPos) + columnsList + SqlString.substring(endPos, SqlString.length);
@ -461,6 +476,7 @@ AJAX.registerTeardown('sql.js', function () {
* @memberOf jQuery
*/
AJAX.registerOnload('sql.js', function () {
// @ts-ignore
if (window.codeMirrorEditor || document.sqlform) {
Sql.setShowThisQuery();
}
@ -544,7 +560,7 @@ AJAX.registerOnload('sql.js', function () {
$('input#bkm_label').on('input', function () {
$('input#id_bkm_all_users, input#id_bkm_replace')
.parent()
.toggle($(this).val().length > 0);
.toggle(($(this).val() as string).length > 0);
}).trigger('input');
/**
@ -954,7 +970,7 @@ AJAX.registerOnload('sql.js', function () {
e.preventDefault();
var $form = $(this).parents('form');
Sql.submitShowAllForm = function () {
const submitShowAllForm = function () {
var argsep = CommonParams.get('arg_separator');
var submitData = $form.serialize() + argsep + 'ajax_request=true' + argsep + 'ajax_page_request=true';
ajaxShowMessage();
@ -963,10 +979,10 @@ AJAX.registerOnload('sql.js', function () {
};
if (! $(this).is(':checked')) { // already showing all rows
Sql.submitShowAllForm();
submitShowAllForm();
} else {
$form.confirm(window.Messages.strShowAllRowsWarning, $form.attr('action'), function () {
Sql.submitShowAllForm();
submitShowAllForm();
});
}
});
@ -1299,6 +1315,7 @@ AJAX.registerOnload('sql.js', function () {
/**
* Check if there is any saved query
*/
// @ts-ignore
if (window.codeMirrorEditor || document.sqlform) {
Sql.checkSavedQuery();
}

View File

@ -19,6 +19,7 @@ import { Functions } from '../modules/functions.ts';
* @return {boolean} always true
*/
function nullify (theType, urlField, md5Field, multiEdit) {
// @ts-ignore
var rowForm = document.forms.insertForm;
if (typeof (rowForm.elements['funcs' + multiEdit + '[' + md5Field + ']']) !== 'undefined') {
@ -173,7 +174,7 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
if ($thisInput.data('type') === 'INT' ||
$thisInput.data('type') === 'TINYINT') {
// Trim spaces if it's an integer
$thisInput.val($thisInput.val().trim());
$thisInput.val(($thisInput.val() as string).trim());
var hasMultiple = $thisInput.prop('multiple');
@ -209,7 +210,7 @@ function verifyAfterSearchFieldChange (index, searchFormId) {
$thisInput.valid();
} else if ($thisInput.data('type') === 'FLOAT') {
// Trim spaces
$thisInput.val($thisInput.val().trim());
$thisInput.val(($thisInput.val() as string).trim());
$(searchFormId).validate({
// update errors as we write
@ -306,15 +307,15 @@ function validateFloatField (jqueryInput, returnValueIfIsNumber): void {
function verificationsAfterFieldChange (urlField, multiEdit, theType) {
var evt = window.event || arguments.callee.caller.arguments[0];
var target = evt.target || evt.srcElement;
var $thisInput = $(':input[name^=\'fields[multi_edit][' + multiEdit + '][' +
urlField + ']\']');
var $thisInput = ($(':input[name^=\'fields[multi_edit][' + multiEdit + '][' +
urlField + ']\']') as JQuery<HTMLInputElement>);
// the function drop-down that corresponds to this input field
var $thisFunction = $('select[name=\'funcs[multi_edit][' + multiEdit + '][' +
urlField + ']\']');
var $thisFunction = ($('select[name=\'funcs[multi_edit][' + multiEdit + '][' +
urlField + ']\']') as JQuery<HTMLSelectElement>);
var functionSelected = false;
if (typeof $thisFunction.val() !== 'undefined' &&
$thisFunction.val() !== null &&
$thisFunction.val().length > 0
($thisFunction.val() as string).length > 0
) {
functionSelected = true;
}
@ -549,6 +550,7 @@ AJAX.registerOnload('table/change.js', function () {
*/
window.extendingValidatorMessages();
// @ts-ignore
$.datepicker.initialized = false;
$(document).on('click', 'span.open_gis_editor', function (event) {
@ -899,7 +901,7 @@ function addNewContinueInsertionFields (event) {
currRows--;
}
} else {
document.getElementById('insert_rows').value = currRows;
(document.getElementById('insert_rows') as HTMLInputElement).value = currRows;
}
}
@ -909,6 +911,7 @@ function addNewContinueInsertionFields (event) {
function changeValueFieldType (elem, searchIndex) {
var fieldsValue = $('input#fieldID_' + searchIndex);
// @ts-ignore
if (0 === fieldsValue.size()) {
return;
}

View File

@ -380,9 +380,10 @@ AJAX.registerOnload('table/chart.js', function () {
});
// handler for ajax form submission
$('#tblchartform').on('submit', function () {
var $form = $(this);
($('#tblchartform') as JQuery<HTMLFormElement>).on('submit', function () {
var $form = ($(this) as JQuery<HTMLFormElement>);
if (window.codeMirrorEditor) {
// @ts-ignore
$form[0].elements.sql_query.value = window.codeMirrorEditor.getValue();
}
@ -428,12 +429,12 @@ AJAX.registerOnload('table/chart.js', function () {
seriesColumn: null
};
var vals = $('input[name="dateTimeCols"]').val().split(' ');
var vals = ($('input[name="dateTimeCols"]').val() as string).split(' ');
$.each(vals, function (i, v) {
dateTimeCols.push(parseInt(v, 10));
});
vals = $('input[name="numericCols"]').val().split(' ');
vals = ($('input[name="numericCols"]').val() as string).split(' ');
$.each(vals, function (i, v) {
numericCols.push(parseInt(v, 10));
});

View File

@ -143,7 +143,7 @@ AJAX.registerOnload('table/operations.js', function () {
event.preventDefault();
event.stopPropagation();
var $form = $(this);
var $tblNameField = $form.find('input[name=new_name]');
var $tblNameField = ($form.find('input[name=new_name]') as JQuery<HTMLInputElement>);
var $tblCollationField = $form.find('select[name=tbl_collation]');
var collationOrigValue = $('select[name="tbl_collation"] option[selected]').val();
var $changeAllColumnCollationsCheckBox = $('#checkbox_change_all_collations');

View File

@ -10,9 +10,7 @@ import refreshMainContent from '../modules/functions/refreshMainContent.ts';
* for table relation
*/
var TableRelation = {};
TableRelation.showHideClauses = function ($thisDropdown) {
const showHideClauses = function ($thisDropdown) {
if ($thisDropdown.val() === '') {
$thisDropdown.parent().nextAll('span').hide();
} else {
@ -28,7 +26,7 @@ TableRelation.showHideClauses = function ($thisDropdown) {
* @param values
* @param selectedValue
*/
TableRelation.setDropdownValues = function ($dropdown, values, selectedValue): void {
const setDropdownValues = function ($dropdown, values, selectedValue = undefined): void {
$dropdown.empty();
var optionsAsString = '';
// add an empty string to the beginning for empty selection
@ -45,7 +43,7 @@ TableRelation.setDropdownValues = function ($dropdown, values, selectedValue): v
*
* @param $dropdown the dropdown whose value got changed
*/
TableRelation.getDropdownValues = function ($dropdown): void {
const getDropdownValues = function ($dropdown): void {
var foreignDb = null;
var foreignTable = null;
var $databaseDd;
@ -135,6 +133,12 @@ TableRelation.getDropdownValues = function ($dropdown): void {
});
};
const TableRelation = {
showHideClauses: showHideClauses,
setDropdownValues: setDropdownValues,
getDropdownValues: getDropdownValues,
};
/**
* Unbind all event handlers before tearing down a page
*/

View File

@ -9,8 +9,6 @@ import { ajaxRemoveMessage, ajaxShowMessage } from '../modules/ajax-message.ts';
* @fileoverview JavaScript functions used on /table/search
*/
var TableSelect = {};
/**
* Checks if given data-type is numeric or date.
*
@ -18,7 +16,7 @@ var TableSelect = {};
*
* @return {boolean | string}
*/
TableSelect.checkIfDataTypeNumericOrDate = function (dataType) {
const checkIfDataTypeNumericOrDate = function (dataType) {
// To test for numeric data-types.
var numericRegExp = new RegExp(
'TINYINT|SMALLINT|MEDIUMINT|INT|BIGINT|DECIMAL|FLOAT|DOUBLE|REAL',
@ -43,6 +41,10 @@ TableSelect.checkIfDataTypeNumericOrDate = function (dataType) {
return false;
};
const TableSelect = {
checkIfDataTypeNumericOrDate: checkIfDataTypeNumericOrDate,
};
/**
* Unbind all event handlers before tearing down a page
*/
@ -115,8 +117,8 @@ AJAX.registerOnload('table/select.js', function () {
Functions.prepareForAjaxRequest($searchForm);
var values = {};
$searchForm.find(':input').each(function () {
var values: { [k: string]: any } = {};
($searchForm.find(':input') as JQuery<HTMLInputElement>).each(function () {
var $input = $(this);
if ($input.attr('type') === 'checkbox' || $input.attr('type') === 'radio') {
if ($input.is(':checked')) {
@ -340,8 +342,8 @@ AJAX.registerOnload('table/select.js', function () {
Functions.addDatepicker($('#min_value'), dataType);
Functions.addDatepicker($('#max_value'), dataType);
$('#rangeSearchModalGo').on('click', function () {
var minValue = $('#min_value').val();
var maxValue = $('#max_value').val();
var minValue = ($('#min_value').val() as string);
var maxValue = ($('#max_value').val() as string);
var finalValue = '';
if (minValue.length && maxValue.length) {
finalValue = minValue + ', ' +

View File

@ -76,8 +76,10 @@ function getTimeStamp (val, type) {
if (type.toString().search(/datetime/i) !== -1 ||
type.toString().search(/timestamp/i) !== -1
) {
// @ts-ignore
return $.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', val);
} else if (type.toString().search(/time/i) !== -1) {
// @ts-ignore
return $.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', '1970-01-01 ' + val);
} else if (type.toString().search(/date/i) !== -1) {
return $.datepicker.parseDate('yy-mm-dd', val);

View File

@ -52,14 +52,14 @@ const handleCreation = ($input): void => {
// eslint-disable-next-line compat/compat
navigator.credentials.create({ publicKey: publicKey })
.then((credential) => {
.then((credential: PublicKeyCredential) => {
const credentialJson = JSON.stringify({
id: credential.id,
rawId: arrayBufferToBase64(credential.rawId),
type: credential.type,
response: {
clientDataJSON: arrayBufferToBase64(credential.response.clientDataJSON),
attestationObject: arrayBufferToBase64(credential.response.attestationObject),
attestationObject: arrayBufferToBase64((credential.response as AuthenticatorAttestationResponse).attestationObject),
}
});
$input.val(credentialJson);
@ -93,16 +93,16 @@ const handleRequest = ($input): void => {
// eslint-disable-next-line compat/compat
navigator.credentials.get({ publicKey: publicKey })
.then((credential) => {
.then((credential: PublicKeyCredential) => {
const credentialJson = JSON.stringify({
id: credential.id,
rawId: arrayBufferToBase64(credential.rawId),
type: credential.type,
response: {
authenticatorData: arrayBufferToBase64(credential.response.authenticatorData),
authenticatorData: arrayBufferToBase64((credential.response as AuthenticatorAssertionResponse).authenticatorData),
clientDataJSON: arrayBufferToBase64(credential.response.clientDataJSON),
signature: arrayBufferToBase64(credential.response.signature),
userHandle: arrayBufferToBase64(credential.response.userHandle),
signature: arrayBufferToBase64((credential.response as AuthenticatorAssertionResponse).signature),
userHandle: arrayBufferToBase64((credential.response as AuthenticatorAssertionResponse).userHandle),
}
});
$input.val(credentialJson);

View File

@ -11,7 +11,6 @@ const publicPath = path.resolve(__dirname, 'public');
const typeScriptErrorsToIgnore = [
2322, // TS2322: Type '%s' is not assignable to type '%s'.
2339, // TS2339: Property '%s' does not exist on type '%s'.
2345, // TS2345: Argument of type '%s' is not assignable to parameter of type '%s'.
2362, // TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
2363, // TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
@ -20,7 +19,6 @@ const typeScriptErrorsToIgnore = [
2405, // TS2405: The left-hand side of a 'for...in' statement must be of type 'string' or 'any'.
2469, // TS2469: The '+' operator cannot be applied to type 'symbol'.
2538, // TS2538: Type '%s' cannot be used as an index type.
2551, // TS2551: Property '%s' does not exist on type '%s'. Did you mean '%s'?
2769, // TS2769: No overload matches this call.
5096, // TS5096: Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set.
];