mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-14 02:27:09 -07:00
WebUI: Allow setting default category when adding torrent
This commit is contained in:
parent
14facdd0a7
commit
5b814cf149
2 changed files with 24 additions and 2 deletions
|
@ -195,10 +195,17 @@
|
|||
<select id="categorySelect" onchange="qBittorrent.AddTorrent.changeCategorySelect(this)">
|
||||
<option selected value="\other"></option>
|
||||
</select>
|
||||
<input type="text" name="category" aria-labelledby="categoryLabel">
|
||||
<input type="text" name="category" id="category" aria-labelledby="categoryLabel">
|
||||
</div>
|
||||
</td>
|
||||
</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>
|
||||
<td class="noWrap">
|
||||
<label id="tagsLabel" for="tagsSelect">QBT_TR(Tags:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||
|
|
|
@ -43,13 +43,21 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
let windowId = "";
|
||||
let source = "";
|
||||
|
||||
const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferences();
|
||||
|
||||
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()) {
|
||||
const option = document.createElement("option");
|
||||
option.value = name;
|
||||
option.textContent = name;
|
||||
document.getElementById("categorySelect").appendChild(option);
|
||||
option.selected = name === defaultCategory;
|
||||
categorySelect.appendChild(option);
|
||||
}
|
||||
|
||||
if (defaultCategory !== "")
|
||||
changeCategorySelect(categorySelect);
|
||||
};
|
||||
|
||||
const getTags = () => {
|
||||
|
@ -299,6 +307,13 @@ window.qBittorrent.AddTorrent ??= (() => {
|
|||
|
||||
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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue