mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-22 17:26:21 +03:00
Use natural sorting in WebUI
Also change case sensitivity to the default of 'sort' mode. PR #20264.
This commit is contained in:
parent
6918316a3d
commit
00372dd559
4 changed files with 9 additions and 12 deletions
|
@ -575,7 +575,7 @@ window.addEvent('load', function() {
|
||||||
const sortedTags = [];
|
const sortedTags = [];
|
||||||
for (const key in tagList)
|
for (const key in tagList)
|
||||||
sortedTags.push(tagList[key].name);
|
sortedTags.push(tagList[key].name);
|
||||||
sortedTags.sort();
|
sortedTags.sort(window.qBittorrent.Misc.naturalSortCollator.compare);
|
||||||
|
|
||||||
for (let i = 0; i < sortedTags.length; ++i) {
|
for (let i = 0; i < sortedTags.length; ++i) {
|
||||||
const tagName = sortedTags[i];
|
const tagName = sortedTags[i];
|
||||||
|
|
|
@ -456,7 +456,7 @@ window.qBittorrent.ContextMenu = (function() {
|
||||||
Object.each(category_list, function(category) {
|
Object.each(category_list, function(category) {
|
||||||
sortedCategories.push(category.name);
|
sortedCategories.push(category.name);
|
||||||
});
|
});
|
||||||
sortedCategories.sort();
|
sortedCategories.sort(window.qBittorrent.Misc.naturalSortCollator.compare);
|
||||||
|
|
||||||
let first = true;
|
let first = true;
|
||||||
Object.each(sortedCategories, function(categoryName) {
|
Object.each(sortedCategories, function(categoryName) {
|
||||||
|
@ -493,7 +493,7 @@ window.qBittorrent.ContextMenu = (function() {
|
||||||
const sortedTags = [];
|
const sortedTags = [];
|
||||||
for (const key in tagList)
|
for (const key in tagList)
|
||||||
sortedTags.push(tagList[key].name);
|
sortedTags.push(tagList[key].name);
|
||||||
sortedTags.sort();
|
sortedTags.sort(window.qBittorrent.Misc.naturalSortCollator.compare);
|
||||||
|
|
||||||
for (let i = 0; i < sortedTags.length; ++i) {
|
for (let i = 0; i < sortedTags.length; ++i) {
|
||||||
const tagName = sortedTags[i];
|
const tagName = sortedTags[i];
|
||||||
|
|
|
@ -179,7 +179,8 @@ window.qBittorrent.Misc = (function() {
|
||||||
return escapedString;
|
return escapedString;
|
||||||
};
|
};
|
||||||
|
|
||||||
const naturalSortCollator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' });
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#parameters
|
||||||
|
const naturalSortCollator = new Intl.Collator(undefined, { numeric: true, usage: 'sort' });
|
||||||
|
|
||||||
const safeTrim = function(value) {
|
const safeTrim = function(value) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -541,14 +541,10 @@
|
||||||
$('searchResultsTableContainer').style.display = "block";
|
$('searchResultsTableContainer').style.display = "block";
|
||||||
|
|
||||||
// sort plugins alphabetically
|
// sort plugins alphabetically
|
||||||
const allPlugins = searchPlugins.sort(function(pluginA, pluginB) {
|
const allPlugins = searchPlugins.sort((left, right) => {
|
||||||
const a = pluginA.fullName.toLowerCase();
|
const leftName = left.fullName;
|
||||||
const b = pluginB.fullName.toLowerCase();
|
const rightName = right.fullName;
|
||||||
if (a < b)
|
return window.qBittorrent.Misc.naturalSortCollator.compare(leftName, rightName);
|
||||||
return -1;
|
|
||||||
if (a > b)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
allPlugins.each(function(plugin) {
|
allPlugins.each(function(plugin) {
|
||||||
|
|
Loading…
Reference in a new issue