Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove jQuery #6333

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/components/mediaLibraryCreator/mediaLibraryCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ function onAddLibrary(e) {
isCreating = true;
loading.show();
const dlg = dom.parentWithClass(this, 'dlg-librarycreator');
const name = $('#txtValue', dlg).val();
let type = $('#selectCollectionType', dlg).val();
const name = dlg.querySelector('#txtValue').value;
let type = dlg.querySelector('#selectCollectionType').value;

if (type == 'mixed') {
type = null;
Expand Down Expand Up @@ -72,9 +72,12 @@ function getCollectionTypeOptionsHtml(collectionTypeOptions) {
}

function initEditor(page, collectionTypeOptions) {
$('#selectCollectionType', page).html(getCollectionTypeOptionsHtml(collectionTypeOptions)).val('').on('change', function () {
const selectCollectionType = page.querySelector('#selectCollectionType');
selectCollectionType.innerHTML = getCollectionTypeOptionsHtml(collectionTypeOptions);
selectCollectionType.value = '';
selectCollectionType.addEventListener('change', function () {
const value = this.value;
const dlg = $(this).parents('.dialog')[0];
const dlg = dom.parentWithClass(this, 'dialog');
libraryoptionseditor.setContentType(dlg.querySelector('.libraryOptions'), value);

if (value) {
Expand All @@ -90,12 +93,12 @@ function initEditor(page, collectionTypeOptions) {
const name = this.options[index].innerHTML
.replaceAll('*', '')
.replaceAll('&', '&');
$('#txtValue', dlg).val(name);
dlg.querySelector('#txtValue').value = name;
}
}

const folderOption = collectionTypeOptions.find(i => i.value === value);
$('.collectionTypeFieldDescription', dlg).html(folderOption?.message || '');
dlg.querySelector('.collectionTypeFieldDescription').innerHTML = folderOption?.message || '';
});
page.querySelector('.btnAddFolder').addEventListener('click', onAddButtonClick);
page.querySelector('.addLibraryForm').addEventListener('submit', onAddLibrary);
Expand Down Expand Up @@ -184,7 +187,7 @@ function onDialogClosed() {

function initLibraryOptions(dlg) {
libraryoptionseditor.embed(dlg.querySelector('.libraryOptions')).then(() => {
$('#selectCollectionType', dlg).trigger('change');
dlg.querySelector('#selectCollectionType').dispatchEvent(new Event('change'));
});
}

Expand Down
30 changes: 16 additions & 14 deletions src/components/tvproviders/schedulesdirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function (page, providerId, options) {
return i.Id === providerId;
})[0] || {};
listingsId = info.ListingsId;
$('#selectListing', page).val(info.ListingsId || '');
page.querySelector('#selectListing').value = info.ListingsId || '';
page.querySelector('.txtUser').value = info.Username || '';
page.querySelector('.txtPass').value = '';
page.querySelector('.txtZipCode').value = info.ZipCode || '';
Expand Down Expand Up @@ -114,7 +114,7 @@ export default function (page, providerId, options) {
$('#selectCountry', page).html(countryList.map(function (c) {
return '<option value="' + c.value + '">' + c.name + '</option>';
}).join('')).val(info.Country || '');
$(page.querySelector('.txtZipCode')).trigger('change');
page.querySelector('.txtZipCode').dispatchEvent(new Event('change'));
}, function () { // ApiClient.getJSON() error handler
Dashboard.alert({
message: globalize.translate('ErrorGettingTvLineups')
Expand Down Expand Up @@ -157,7 +157,7 @@ export default function (page, providerId, options) {
}

function submitListingsForm() {
const selectedListingsId = $('#selectListing', page).val();
const selectedListingsId = page.querySelector('#selectListing').value;

if (!selectedListingsId) {
Dashboard.alert({
Expand All @@ -173,7 +173,7 @@ export default function (page, providerId, options) {
return i.Id === id;
})[0];
info.ZipCode = page.querySelector('.txtZipCode').value;
info.Country = $('#selectCountry', page).val();
info.Country = page.querySelector('#selectCountry').value;
info.ListingsId = selectedListingsId;
info.EnableAllTuners = page.querySelector('.chkAllTuners').checked;
info.EnabledTuners = info.EnableAllTuners ? [] : $('.chkTuner', page).get().filter(function (i) {
Expand Down Expand Up @@ -207,7 +207,7 @@ export default function (page, providerId, options) {

function refreshListings(value) {
if (!value) {
$('#selectListing', page).html('');
page.querySelector('#selectListing').innerHTML = '';
return;
}

Expand All @@ -217,16 +217,16 @@ export default function (page, providerId, options) {
url: ApiClient.getUrl('LiveTv/ListingProviders/Lineups', {
Id: providerId,
Location: value,
Country: $('#selectCountry', page).val()
Country: page.querySelector('#selectCountry').value
}),
dataType: 'json'
}).then(function (result) {
$('#selectListing', page).html(result.map(function (o) {
page.querySelector('#selectListing').innerHTML = result.map(function (o) {
return '<option value="' + o.Id + '">' + o.Name + '</option>';
}));
}).join('');

if (listingsId) {
$('#selectListing', page).val(listingsId);
page.querySelector('#selectListing').value = listingsId;
}

loading.hide();
Expand Down Expand Up @@ -257,15 +257,17 @@ export default function (page, providerId, options) {
const hideSubmitButton = options.showSubmitButton === false;
page.querySelector('.btnSubmitListings').classList.toggle('hide', hideSubmitButton);

$('.formLogin', page).on('submit', function () {
page.querySelector('.formLogin').addEventListener('submit', function (e) {
e.preventDefault();
submitLoginForm();
return false;
});
$('.formListings', page).on('submit', function () {

page.querySelector('.formListings').addEventListener('submit', function (e) {
e.preventDefault();
submitListingsForm();
return false;
});
$('.txtZipCode', page).on('change', function () {

page.querySelector('.txtZipCode').addEventListener('change', function () {
refreshListings(this.value);
});
page.querySelector('.chkAllTuners').addEventListener('change', function (e) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/tvproviders/xmltv.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '../listview/listview.scss';
import '../../elements/emby-button/paper-icon-button-light';
import Dashboard from '../../utils/dashboard';
import Events from '../../utils/events.ts';
import dom from 'scripts/dom';

function getTunerName(providerId) {
switch (providerId.toLowerCase()) {
Expand Down Expand Up @@ -46,7 +47,7 @@ function refreshTunerDevices(page, providerInfo, devices) {
}

function onSelectPathClick(e) {
const page = $(e.target).parents('.xmltvForm')[0];
const page = dom.parentWithClass(e.target, 'xmltvForm');

import('../directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
const picker = new DirectoryBrowser();
Expand Down
28 changes: 14 additions & 14 deletions src/controllers/dashboard/encodingsettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ function loadPage(page, config, systemInfo) {
page.querySelector('#chkHardwareEncoding').checked = config.EnableHardwareEncoding;
page.querySelector('#chkAllowHevcEncoding').checked = config.AllowHevcEncoding;
page.querySelector('#chkAllowAv1Encoding').checked = config.AllowAv1Encoding;
$('#selectVideoDecoder', page).val(config.HardwareAccelerationType || 'none');
$('#selectThreadCount', page).val(config.EncodingThreadCount);
page.querySelector('#selectVideoDecoder').value = config.HardwareAccelerationType || 'none';
page.querySelector('#selectThreadCount').value = config.EncodingThreadCount;
page.querySelector('#chkEnableAudioVbr').checked = config.EnableAudioVbr;
$('#txtDownMixAudioBoost', page).val(config.DownMixAudioBoost);
$('#selectStereoDownmixAlgorithm').val(config.DownMixStereoAlgorithm || 'None');
page.querySelector('#txtDownMixAudioBoost').value = config.DownMixAudioBoost;
page.querySelector('#selectStereoDownmixAlgorithm').value = config.DownMixStereoAlgorithm || 'None';
page.querySelector('#txtMaxMuxingQueueSize').value = config.MaxMuxingQueueSize || '';
page.querySelector('.txtEncoderPath').value = config.EncoderAppPathDisplay || '';
$('#txtTranscodingTempPath', page).val(systemInfo.TranscodingTempPath || '');
page.querySelector('#txtTranscodingTempPath').value = systemInfo.TranscodingTempPath || '';
page.querySelector('#txtFallbackFontPath').value = config.FallbackFontPath || '';
page.querySelector('#chkEnableFallbackFont').checked = config.EnableFallbackFont;
$('#txtVaapiDevice', page).val(config.VaapiDevice || '');
page.querySelector('#txtVaapiDevice').value = config.VaapiDevice || '';
page.querySelector('#txtQsvDevice').value = config.QsvDevice || '';
page.querySelector('#chkTonemapping').checked = config.EnableTonemapping;
page.querySelector('#chkVppTonemapping').checked = config.EnableVppTonemapping;
Expand Down Expand Up @@ -85,15 +85,15 @@ function onSubmit() {
loading.show();
ApiClient.getNamedConfiguration('encoding').then(function (config) {
config.EnableAudioVbr = form.querySelector('#chkEnableAudioVbr').checked;
config.DownMixAudioBoost = $('#txtDownMixAudioBoost', form).val();
config.DownMixStereoAlgorithm = $('#selectStereoDownmixAlgorithm', form).val() || 'None';
config.DownMixAudioBoost = form.querySelector('#txtDownMixAudioBoost').value;
config.DownMixStereoAlgorithm = form.querySelector('#selectStereoDownmixAlgorithm').value || 'None';
config.MaxMuxingQueueSize = form.querySelector('#txtMaxMuxingQueueSize').value;
config.TranscodingTempPath = $('#txtTranscodingTempPath', form).val();
config.TranscodingTempPath = form.querySelector('#txtTranscodingTempPath').value;
config.FallbackFontPath = form.querySelector('#txtFallbackFontPath').value;
config.EnableFallbackFont = form.querySelector('#txtFallbackFontPath').value ? form.querySelector('#chkEnableFallbackFont').checked : false;
config.EncodingThreadCount = $('#selectThreadCount', form).val();
config.HardwareAccelerationType = $('#selectVideoDecoder', form).val();
config.VaapiDevice = $('#txtVaapiDevice', form).val();
config.EncodingThreadCount = form.querySelector('#selectThreadCount').value;
config.HardwareAccelerationType = form.querySelector('#selectVideoDecoder').value;
config.VaapiDevice = form.querySelector('#txtVaapiDevice').value;
config.QsvDevice = form.querySelector('#txtQsvDevice').value;
config.EnableTonemapping = form.querySelector('#chkTonemapping').checked;
config.EnableVppTonemapping = form.querySelector('#chkVppTonemapping').checked;
Expand Down Expand Up @@ -141,7 +141,7 @@ function onSubmit() {
});
};

if ($('#selectVideoDecoder', form).val() !== 'none') {
if (form.querySelector('#selectVideoDecoder').value !== 'none') {
alert({
title: globalize.translate('TitleHardwareAcceleration'),
text: globalize.translate('HardwareAccelerationWarning')
Expand Down Expand Up @@ -263,7 +263,7 @@ $(document).on('pageinit', '#encodingSettingsPage', function () {
picker.show({
callback: function (path) {
if (path) {
$('#txtTranscodingTempPath', page).val(path);
page.querySelector('#txtTranscodingTempPath').value = path;
}

picker.close();
Expand Down
27 changes: 14 additions & 13 deletions src/controllers/dashboard/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ function loadPage(page, config, languageOptions, systemInfo) {
page.querySelector('#txtServerName').value = systemInfo.ServerName;
page.querySelector('#txtCachePath').value = systemInfo.CachePath || '';
page.querySelector('#chkQuickConnectAvailable').checked = config.QuickConnectAvailable === true;
$('#txtMetadataPath', page).val(systemInfo.InternalMetadataPath || '');
$('#txtMetadataNetworkPath', page).val(systemInfo.MetadataNetworkPath || '');
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (language) {
page.querySelector('#txtMetadataPath').value = systemInfo.InternalMetadataPath || '';
page.querySelector('#txtMetadataNetworkPath').value = systemInfo.MetadataNetworkPath || '';
const localizationLanguageElem = page.querySelector('#selectLocalizationLanguage');
localizationLanguageElem.innerHTML = languageOptions.map(function (language) {
return '<option value="' + language.Value + '">' + language.Name + '</option>';
})).val(config.UICulture);
}).join('');
localizationLanguageElem.value = config.UICulture;
page.querySelector('#txtLibraryScanFanoutConcurrency').value = config.LibraryScanFanoutConcurrency || '';
page.querySelector('#txtParallelImageEncodingLimit').value = config.ParallelImageEncodingLimit || '';

Expand All @@ -28,13 +30,12 @@ function loadPage(page, config, languageOptions, systemInfo) {
function onSubmit() {
loading.show();
const form = this;
$(form).parents('.page');
ApiClient.getServerConfiguration().then(function (config) {
config.ServerName = $('#txtServerName', form).val();
config.UICulture = $('#selectLocalizationLanguage', form).val();
config.ServerName = form.querySelector('#txtServerName').value;
config.UICulture = form.querySelector('#selectLocalizationLanguage').value;
config.CachePath = form.querySelector('#txtCachePath').value;
config.MetadataPath = $('#txtMetadataPath', form).val();
config.MetadataNetworkPath = $('#txtMetadataNetworkPath', form).val();
config.MetadataPath = form.querySelector('#txtMetadataPath').value;
config.MetadataNetworkPath = form.querySelector('#txtMetadataNetworkPath').value;
config.QuickConnectAvailable = form.querySelector('#chkQuickConnectAvailable').checked;
config.LibraryScanFanoutConcurrency = parseInt(form.querySelector('#txtLibraryScanFanoutConcurrency').value || '0', 10);
config.ParallelImageEncodingLimit = parseInt(form.querySelector('#txtParallelImageEncodingLimit').value || '0', 10);
Expand Down Expand Up @@ -80,15 +81,15 @@ export default function (view) {
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
const picker = new DirectoryBrowser();
picker.show({
path: $('#txtMetadataPath', view).val(),
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
path: view.querySelector('#txtMetadataPath').value,
networkSharePath: view.querySelector('#txtMetadataNetworkPath').value,
callback: function (path, networkPath) {
if (path) {
$('#txtMetadataPath', view).val(path);
view.querySelector('#txtMetadataPath').value = path;
}

if (networkPath) {
$('#txtMetadataNetworkPath', view).val(networkPath);
view.querySelector('#txtMetadataNetworkPath').value = networkPath;
}

picker.close();
Expand Down
25 changes: 16 additions & 9 deletions src/controllers/dashboard/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,27 @@ function reloadVirtualFolders(page, virtualFolders) {
divVirtualFolders.innerHTML = html;
divVirtualFolders.classList.add('itemsContainer');
divVirtualFolders.classList.add('vertical-wrap');
$('.btnCardMenu', divVirtualFolders).on('click', function () {
showCardMenu(page, this, virtualFolders);
const btnCardMenuElements = divVirtualFolders.querySelectorAll('.btnCardMenu');
btnCardMenuElements.forEach(function (btn) {
btn.addEventListener('click', function () {
showCardMenu(page, btn, virtualFolders);
});
});
divVirtualFolders.querySelector('#addLibrary').addEventListener('click', function () {
addVirtualFolder(page);
});
$('.editLibrary', divVirtualFolders).on('click', function () {
const card = $(this).parents('.card')[0];
const index = parseInt(card.getAttribute('data-index'), 10);
const virtualFolder = virtualFolders[index];

if (virtualFolder.ItemId) {
editVirtualFolder(page, virtualFolder);
}
const libraryEditElements = divVirtualFolders.querySelectorAll('.editLibrary');
libraryEditElements.forEach(function (btn) {
btn.addEventListener('click', function () {
const card = dom.parentWithClass(btn, 'card');
const index = parseInt(card.getAttribute('data-index'), 10);
const virtualFolder = virtualFolders[index];

if (virtualFolder.ItemId) {
editVirtualFolder(page, virtualFolder);
}
});
});
loading.hide();
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/dashboard/librarydisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function(view) {
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
});
ApiClient.getNamedConfiguration('metadata').then(function(config) {
config.UseFileCreationTimeForDateAdded = $('#selectDateAdded', form).val() === '1';
config.UseFileCreationTimeForDateAdded = form.querySelector('#selectDateAdded').value === '1';
ApiClient.updateNamedConfiguration('metadata', config);
});

Expand Down
10 changes: 6 additions & 4 deletions src/controllers/dashboard/metadatanfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ function loadPage(page, config, users) {
html += users.map(function (user) {
return '<option value="' + user.Id + '">' + escapeHtml(user.Name) + '</option>';
}).join('');
$('#selectUser', page).html(html).val(config.UserId || '');
$('#selectReleaseDateFormat', page).val(config.ReleaseDateFormat);
const elem = page.querySelector('#selectUser');
elem.innerHTML = html;
elem.value = config.UserId || '';
page.querySelector('#selectReleaseDateFormat').value = config.ReleaseDateFormat;
page.querySelector('#chkSaveImagePaths').checked = config.SaveImagePathsInNfo;
page.querySelector('#chkEnablePathSubstitution').checked = config.EnablePathSubstitution;
page.querySelector('#chkEnableExtraThumbs').checked = config.EnableExtraThumbsDuplication;
Expand All @@ -22,8 +24,8 @@ function onSubmit() {
loading.show();
const form = this;
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
config.UserId = $('#selectUser', form).val() || null;
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
config.UserId = form.querySelector('#selectUser').value || null;
config.ReleaseDateFormat = form.querySelector('#selectReleaseDateFormat').value;
config.SaveImagePathsInNfo = form.querySelector('#chkSaveImagePaths').checked;
config.EnablePathSubstitution = form.querySelector('#chkEnablePathSubstitution').checked;
config.EnableExtraThumbsDuplication = form.querySelector('#chkEnableExtraThumbs').checked;
Expand Down
Loading
Loading