Update jQuery to 3.7 and fix admintests (#5868)

* jQuery: Migrate to `.on()`, `.off()`, `.trigger()`

This avoids methods that are deprecated in newer versions of jQuery.

* jQuery: avoid `.removeAttr`, prefer `.prop`

* helper.edit: wait up to 10 seconds for ACCEPT_COMMIT

* Chat: disabled attribute is boolean

* Chat: avoid inline onclick handler to support jQuery 3.4+

* jQuery: update to version 3.6.0

* Update to 3.7

* Removed deprecated event.

* Revert change to focus on padeditor.ace

---------

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
This commit is contained in:
SamTV12345 2023-08-08 18:26:25 +02:00 committed by GitHub
parent 2f5b6b80e1
commit a096f1ae33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 9457 additions and 8785 deletions

View file

@ -164,7 +164,7 @@
$(window).resize(adjust);
// Allow for manual triggering if needed.
$ta.bind('autosize', adjust);
$ta.on('autosize', adjust);
// Call adjust in case the textarea already contains text.
adjust();

View file

@ -112,15 +112,15 @@ $(document).ready(() => {
const updateHandlers = () => {
// Search
$('#search-query').unbind('keyup').keyup(() => {
$('#search-query').off('keyup').on('keyup', () => {
search($('#search-query').val());
});
// Prevent form submit
$('#search-query').parent().bind('submit', () => false);
$('#search-query').parent().on('submit', () => false);
// update & install
$('.do-install, .do-update').unbind('click').click(function (e) {
$('.do-install, .do-update').off('click').on('click', function (e) {
const $row = $(e.target).closest('tr');
const plugin = $row.data('plugin');
if ($(this).hasClass('do-install')) {
@ -134,7 +134,7 @@ $(document).ready(() => {
});
// uninstall
$('.do-uninstall').unbind('click').click((e) => {
$('.do-uninstall').off('click').on('click', (e) => {
const $row = $(e.target).closest('tr');
const pluginName = $row.data('plugin');
socket.emit('uninstall', pluginName);
@ -143,14 +143,14 @@ $(document).ready(() => {
});
// Sort
$('.sort.up').unbind('click').click(function () {
$('.sort.up').off('click').on('click', function () {
search.sortBy = $(this).attr('data-label').toLowerCase();
search.sortDir = false;
search.offset = 0;
search(search.searchTerm, search.results.length);
search.results = [];
});
$('.sort.down, .sort.none').unbind('click').click(function () {
$('.sort.down, .sort.none').off('click').on('click', function () {
search.sortBy = $(this).attr('data-label').toLowerCase();
search.sortDir = true;
search.offset = 0;
@ -164,7 +164,7 @@ $(document).ready(() => {
if (data.query.offset === 0) search.results = [];
search.messages.hide('nothing-found');
search.messages.hide('fetching');
$('#search-query').removeAttr('disabled');
$('#search-query').prop('disabled', false);
console.log('got search results', data);

View file

@ -25,7 +25,7 @@ $(document).ready(() => {
/* Check to make sure the JSON is clean before proceeding */
if (isJSONClean(settings.results)) {
$('.settings').append(settings.results);
$('.settings').focus();
$('.settings').trigger('focus');
$('.settings').autosize();
} else {
alert('Invalid JSON');
@ -40,7 +40,7 @@ $(document).ready(() => {
socket.emit('saveSettings', $('.settings').val());
} else {
alert('Invalid JSON');
$('.settings').focus();
$('.settings').trigger('focus');
}
});
@ -62,7 +62,7 @@ const isJSONClean = (data) => {
// this is a bit naive. In theory some key/value might contain the sequences ',]' or ',}'
cleanSettings = cleanSettings.replace(',]', ']').replace(',}', '}');
try {
return typeof jQuery.parseJSON(cleanSettings) === 'object';
return typeof JSON.parseJSON(cleanSettings) === 'object';
} catch (e) {
return false; // the JSON failed to be parsed
}