mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-17 06:01:33 -06:00
WebUI: disallow number literals with zero fractions or dangling dots
Javascript treats them all the same as `Number`.
This commit is contained in:
@@ -68,6 +68,7 @@ export default [
|
||||
"Stylistic/quote-props": ["error", "consistent-as-needed"],
|
||||
"Stylistic/semi": "error",
|
||||
"Stylistic/spaced-comment": ["error", "always", { exceptions: ["*"] }],
|
||||
"Unicorn/no-zero-fractions": "error",
|
||||
"Unicorn/prefer-number-properties": "error"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1628,7 +1628,7 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
||||
if (prop_h !== null)
|
||||
prop_h = Number(prop_h) * Window.getSize().y;
|
||||
else
|
||||
prop_h = Window.getSize().y / 2.0;
|
||||
prop_h = Window.getSize().y / 2;
|
||||
new MochaUI.Panel({
|
||||
id: "propertiesPanel",
|
||||
title: "Panel",
|
||||
|
||||
@@ -340,7 +340,7 @@ window.qBittorrent.ContextMenu ??= (() => {
|
||||
else
|
||||
there_are_f_l_piece_prio = true;
|
||||
|
||||
if (data["progress"] !== 1.0) // not downloaded
|
||||
if (data["progress"] !== 1) // not downloaded
|
||||
all_are_downloaded = false;
|
||||
else if (data["super_seeding"] !== true)
|
||||
all_are_super_seeding = false;
|
||||
|
||||
@@ -1980,10 +1980,10 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||
|
||||
getFilteredAndSortedRows() {
|
||||
const getSizeFilters = () => {
|
||||
let minSize = (window.qBittorrent.Search.searchSizeFilter.min > 0.00) ? (window.qBittorrent.Search.searchSizeFilter.min * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.minUnit)) : 0.00;
|
||||
let maxSize = (window.qBittorrent.Search.searchSizeFilter.max > 0.00) ? (window.qBittorrent.Search.searchSizeFilter.max * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.maxUnit)) : 0.00;
|
||||
let minSize = (window.qBittorrent.Search.searchSizeFilter.min > 0) ? (window.qBittorrent.Search.searchSizeFilter.min * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.minUnit)) : 0;
|
||||
let maxSize = (window.qBittorrent.Search.searchSizeFilter.max > 0) ? (window.qBittorrent.Search.searchSizeFilter.max * Math.pow(1024, window.qBittorrent.Search.searchSizeFilter.maxUnit)) : 0;
|
||||
|
||||
if ((minSize > maxSize) && (maxSize > 0.00)) {
|
||||
if ((minSize > maxSize) && (maxSize > 0)) {
|
||||
const tmp = minSize;
|
||||
minSize = maxSize;
|
||||
maxSize = tmp;
|
||||
@@ -2018,16 +2018,16 @@ window.qBittorrent.DynamicTable ??= (() => {
|
||||
const seedsFilters = getSeedsFilters();
|
||||
const searchInTorrentName = document.getElementById("searchInTorrentName").value === "names";
|
||||
|
||||
if (searchInTorrentName || (filterTerms.length > 0) || (window.qBittorrent.Search.searchSizeFilter.min > 0.00) || (window.qBittorrent.Search.searchSizeFilter.max > 0.00)) {
|
||||
if (searchInTorrentName || (filterTerms.length > 0) || (window.qBittorrent.Search.searchSizeFilter.min > 0) || (window.qBittorrent.Search.searchSizeFilter.max > 0)) {
|
||||
for (const row of this.getRowValues()) {
|
||||
|
||||
if (searchInTorrentName && !window.qBittorrent.Misc.containsAllTerms(row.full_data.fileName, searchTerms))
|
||||
continue;
|
||||
if ((filterTerms.length > 0) && !window.qBittorrent.Misc.containsAllTerms(row.full_data.fileName, filterTerms))
|
||||
continue;
|
||||
if ((sizeFilters.min > 0.00) && (row.full_data.fileSize < sizeFilters.min))
|
||||
if ((sizeFilters.min > 0) && (row.full_data.fileSize < sizeFilters.min))
|
||||
continue;
|
||||
if ((sizeFilters.max > 0.00) && (row.full_data.fileSize > sizeFilters.max))
|
||||
if ((sizeFilters.max > 0) && (row.full_data.fileSize > sizeFilters.max))
|
||||
continue;
|
||||
if ((seedsFilters.min > 0) && (row.full_data.nbSeeders < seedsFilters.min))
|
||||
continue;
|
||||
|
||||
@@ -131,7 +131,7 @@ window.qBittorrent.FileTree ??= (() => {
|
||||
}
|
||||
|
||||
calculateRemaining() {
|
||||
this.remaining = this.isIgnored() ? 0 : (this.size * (1.0 - (this.progress / 100)));
|
||||
this.remaining = this.isIgnored() ? 0 : (this.size * (1 - (this.progress / 100)));
|
||||
}
|
||||
|
||||
serialize() {
|
||||
|
||||
@@ -80,9 +80,9 @@ window.qBittorrent.Search ??= (() => {
|
||||
max: 0
|
||||
};
|
||||
const searchSizeFilter = {
|
||||
min: 0.00,
|
||||
min: 0,
|
||||
minUnit: 2, // B = 0, KiB = 1, MiB = 2, GiB = 3, TiB = 4, PiB = 5, EiB = 6
|
||||
max: 0.00,
|
||||
max: 0,
|
||||
maxUnit: 3
|
||||
};
|
||||
|
||||
@@ -789,9 +789,9 @@ window.qBittorrent.Search ??= (() => {
|
||||
document.getElementById("searchMinSeedsFilter").value = searchSeedsFilter.min;
|
||||
document.getElementById("searchMaxSeedsFilter").value = searchSeedsFilter.max;
|
||||
|
||||
searchSizeFilter.min = 0.00;
|
||||
searchSizeFilter.min = 0;
|
||||
searchSizeFilter.minUnit = 2; // B = 0, KiB = 1, MiB = 2, GiB = 3, TiB = 4, PiB = 5, EiB = 6
|
||||
searchSizeFilter.max = 0.00;
|
||||
searchSizeFilter.max = 0;
|
||||
searchSizeFilter.maxUnit = 3;
|
||||
document.getElementById("searchMinSizeFilter").value = searchSizeFilter.min;
|
||||
document.getElementById("searchMinSizePrefix").value = searchSizeFilter.minUnit;
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
return;
|
||||
|
||||
const shareLimit = getSelectedRadioValue("shareLimit");
|
||||
let ratioLimitValue = 0.00;
|
||||
let ratioLimitValue = 0;
|
||||
let seedingTimeLimitValue = 0;
|
||||
let inactiveSeedingTimeLimitValue = 0;
|
||||
let shareLimitActionValue = "Default";
|
||||
|
||||
@@ -68,11 +68,11 @@ test("Test toFixedPointString()", () => {
|
||||
expect(toFixedPointString(-35.855, 3)).toBe("-35.855");
|
||||
expect(toFixedPointString(-35.855, 4)).toBe("-35.8550");
|
||||
|
||||
expect(toFixedPointString(100.00, 0)).toBe("100");
|
||||
expect(toFixedPointString(100.00, 1)).toBe("100.0");
|
||||
expect(toFixedPointString(100.00, 2)).toBe("100.00");
|
||||
expect(toFixedPointString(100, 0)).toBe("100");
|
||||
expect(toFixedPointString(100, 1)).toBe("100.0");
|
||||
expect(toFixedPointString(100, 2)).toBe("100.00");
|
||||
|
||||
expect(toFixedPointString(-100.00, 0)).toBe("-100");
|
||||
expect(toFixedPointString(-100.00, 1)).toBe("-100.0");
|
||||
expect(toFixedPointString(-100.00, 2)).toBe("-100.00");
|
||||
expect(toFixedPointString(-100, 0)).toBe("-100");
|
||||
expect(toFixedPointString(-100, 1)).toBe("-100.0");
|
||||
expect(toFixedPointString(-100, 2)).toBe("-100.00");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user