Skip to content

Commit

Permalink
WebUI: don't auto infer radix parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed May 11, 2024
1 parent dd9765c commit 9260d1a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/webui/www/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default [
"operator-assignment": "error",
"prefer-arrow-callback": "error",
"prefer-const": "error",
"radix": "error",
"Stylistic/no-mixed-operators": [
"error",
{
Expand Down
4 changes: 2 additions & 2 deletions src/webui/www/private/rename_files.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
menu: "multiRenameFilesMenu",
actions: {
ToggleSelection: function(element, ref) {
const rowId = parseInt(element.get("data-row-id"));
const rowId = parseInt(element.get("data-row-id"), 10);
const row = bulkRenameFilesTable.getNode(rowId);
const checkState = (row.checked === 1) ? 0 : 1;
bulkRenameFilesTable.toggleNodeTreeCheckbox(rowId, checkState);
Expand Down Expand Up @@ -128,7 +128,7 @@
$("include_folders").checked = fileRenamer.includeFolders;

const multirename_fileEnumerationStart = LocalPreferences.get("multirename_fileEnumerationStart", 0);
fileRenamer.fileEnumerationStart = parseInt(multirename_fileEnumerationStart);
fileRenamer.fileEnumerationStart = parseInt(multirename_fileEnumerationStart, 10);
$("file_counter").set("value", fileRenamer.fileEnumerationStart);

const multirename_replaceAll = LocalPreferences.get("multirename_replaceAll", false);
Expand Down
8 changes: 4 additions & 4 deletions src/webui/www/private/scripts/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ window.qBittorrent.Misc = (function() {
return "QBT_TR(< 1m)QBT_TR[CONTEXT=misc]";
let minutes = seconds / 60;
if (minutes < 60)
return "QBT_TR(%1m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(minutes));
return "QBT_TR(%1m)QBT_TR[CONTEXT=misc]".replace("%1", Math.floor(minutes));
let hours = minutes / 60;
minutes %= 60;
if (hours < 24)
return "QBT_TR(%1h %2m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes));
return "QBT_TR(%1h %2m)QBT_TR[CONTEXT=misc]".replace("%1", Math.floor(hours)).replace("%2", Math.floor(minutes));
let days = hours / 24;
hours %= 24;
if (days < 365)
return "QBT_TR(%1d %2h)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(days)).replace("%2", parseInt(hours));
return "QBT_TR(%1d %2h)QBT_TR[CONTEXT=misc]".replace("%1", Math.floor(days)).replace("%2", Math.floor(hours));
const years = days / 365;
days %= 365;
return "QBT_TR(%1y %2d)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(years)).replace("%2", parseInt(days));
return "QBT_TR(%1y %2d)QBT_TR[CONTEXT=misc]".replace("%1", Math.floor(years)).replace("%2", Math.floor(days));
};

const friendlyPercentage = function(value) {
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/scripts/progressbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ window.qBittorrent.ProgressBar = (function() {
this.vals.dark.textContent = displayedValue;
this.vals.light.textContent = displayedValue;

const r = parseInt(this.vals.width * (value / 100));
const r = parseInt((this.vals.width * (value / 100)), 10);
this.vals.dark.setStyle("clip", `rect(0, ${r}px, ${this.vals.height}px, 0)`);
this.vals.light.setStyle("clip", `rect(0, ${this.vals.width}px, ${this.vals.height}px, ${r}px)`);
}
Expand Down
5 changes: 2 additions & 3 deletions src/webui/www/private/scripts/prop-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,15 @@ window.qBittorrent.PropFiles = (function() {

const updatePriorityCombo = function(id, selectedPriority) {
const combobox = $("comboPrio" + id);

if (parseInt(combobox.value) !== selectedPriority)
if (parseInt(combobox.value, 10) !== selectedPriority)
selectComboboxPriority(combobox, selectedPriority);
};

const selectComboboxPriority = function(combobox, priority) {
const options = combobox.options;
for (let i = 0; i < options.length; ++i) {
const option = options[i];
if (parseInt(option.value) === priority)
if (parseInt(option.value, 10) === priority)
option.selected = true;
else
option.selected = false;
Expand Down
8 changes: 4 additions & 4 deletions src/webui/www/private/shareratio.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@

const values = {
ratioLimit: window.qBittorrent.Misc.friendlyFloat(origValues[0], 2),
seedingTimeLimit: parseInt(origValues[1]),
inactiveSeedingTimeLimit: parseInt(origValues[2]),
seedingTimeLimit: parseInt(origValues[1], 10),
inactiveSeedingTimeLimit: parseInt(origValues[2], 10),
maxRatio: window.qBittorrent.Misc.friendlyFloat(origValues[3], 2),
maxSeedingTime: parseInt(origValues[4]),
maxInactiveSeedingTime: parseInt(origValues[5])
maxSeedingTime: parseInt(origValues[4], 10),
maxInactiveSeedingTime: parseInt(origValues[5], 10)
};

// select default when orig values not passed. using double equals to compare string and int
Expand Down
2 changes: 1 addition & 1 deletion src/webui/www/private/views/rssDownloader.html
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@
rulesList[rule].mustNotContain = $("mustNotContainText").value;
rulesList[rule].episodeFilter = $("episodeFilterText").value;
rulesList[rule].smartFilter = $("useSmartFilter").checked;
rulesList[rule].ignoreDays = parseInt($("ignoreDaysValue").value);
rulesList[rule].ignoreDays = parseInt($("ignoreDaysValue").value, 10);
rulesList[rule].affectedFeeds = rssDownloaderFeedSelectionTable.rows.filter((row) => row.full_data.checked)
.map((row) => row.full_data.url)
.getValues();
Expand Down

0 comments on commit 9260d1a

Please sign in to comment.