mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
WebUI: Allow setting default category when adding torrent
This commit is contained in:
parent
e98e1cf748
commit
b5b65aa8f5
2 changed files with 24 additions and 2 deletions
|
@ -204,10 +204,17 @@
|
||||||
<select id="categorySelect" onchange="qBittorrent.AddTorrent.changeCategorySelect(this)">
|
<select id="categorySelect" onchange="qBittorrent.AddTorrent.changeCategorySelect(this)">
|
||||||
<option selected value="\other"></option>
|
<option selected value="\other"></option>
|
||||||
</select>
|
</select>
|
||||||
<input type="text" name="category" aria-labelledby="categoryLabel">
|
<input type="text" name="category" id="category" aria-labelledby="categoryLabel">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="noWrap"></td>
|
||||||
|
<td class="fullWidth">
|
||||||
|
<input type="checkbox" id="setDefaultCategory">
|
||||||
|
<label for="setDefaultCategory">QBT_TR(Set as default category)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="noWrap">
|
<td class="noWrap">
|
||||||
<label id="tagsLabel" for="tagsSelect">QBT_TR(Tags:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
<label id="tagsLabel" for="tagsSelect">QBT_TR(Tags:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||||
|
|
|
@ -43,13 +43,21 @@ window.qBittorrent.AddTorrent ??= (() => {
|
||||||
let windowId = "";
|
let windowId = "";
|
||||||
let source = "";
|
let source = "";
|
||||||
|
|
||||||
|
const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferences();
|
||||||
|
|
||||||
const getCategories = () => {
|
const getCategories = () => {
|
||||||
|
const defaultCategory = LocalPreferences.get("add_torrent_default_category", "");
|
||||||
|
const categorySelect = document.getElementById("categorySelect");
|
||||||
for (const name of window.parent.qBittorrent.Client.categoryMap.keys()) {
|
for (const name of window.parent.qBittorrent.Client.categoryMap.keys()) {
|
||||||
const option = document.createElement("option");
|
const option = document.createElement("option");
|
||||||
option.value = name;
|
option.value = name;
|
||||||
option.textContent = name;
|
option.textContent = name;
|
||||||
document.getElementById("categorySelect").appendChild(option);
|
option.selected = name === defaultCategory;
|
||||||
|
categorySelect.appendChild(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaultCategory !== "")
|
||||||
|
changeCategorySelect(categorySelect);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTags = () => {
|
const getTags = () => {
|
||||||
|
@ -301,6 +309,13 @@ window.qBittorrent.AddTorrent ??= (() => {
|
||||||
|
|
||||||
document.getElementById("loadingSpinner").style.display = "block";
|
document.getElementById("loadingSpinner").style.display = "block";
|
||||||
|
|
||||||
|
if (document.getElementById("setDefaultCategory").checked) {
|
||||||
|
const category = document.getElementById("category").value.trim();
|
||||||
|
if (category.length === 0)
|
||||||
|
LocalPreferences.remove("add_torrent_default_category");
|
||||||
|
else
|
||||||
|
LocalPreferences.set("add_torrent_default_category", category);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("load", async (event) => {
|
window.addEventListener("load", async (event) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue