Added number check to sorting and parseInt radix

Introduced changes suggested by thornbill.
This commit is contained in:
DesertCookie 2020-09-10 09:22:58 +02:00 committed by GitHub
parent c8858b10f6
commit 746a6231fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,10 +172,10 @@ function renderTrackSelections(page, instance, item, forceReload) {
var resolutionNames = []; var resolutionNames = [];
var sourceNames = []; var sourceNames = [];
mediaSources.forEach(function (v) { mediaSources.forEach(function (v) {
(v.Name.endsWith('p') || v.Name.endsWith('i')) ? resolutionNames.push(v) : sourceNames.push(v); ((v.Name.endsWith('p') || v.Name.endsWith('i'))) && !Number.isNaN(parseInt(v.Name, 10) ? resolutionNames.push(v) : sourceNames.push(v);
}); });
resolutionNames.sort((a, b) => parseInt(b.Name) - parseInt(a.Name)); resolutionNames.sort((a, b) => parseInt(b.Name, 10) - parseInt(a.Name, 10));
sourceNames.sort(function(a, b) { sourceNames.sort(function(a, b) {
var nameA = a.Name.toUpperCase(); var nameA = a.Name.toUpperCase();
var nameB = b.Name.toUpperCase(); var nameB = b.Name.toUpperCase();