mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Show list of categories on WebUI download page
This commit is contained in:
parent
a7c2ee3ce6
commit
7151d6babd
@ -60,7 +60,12 @@
|
|||||||
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" id="category" name="category" style="width: 16em;" />
|
<div class="select-watched-folder-editable">
|
||||||
|
<select id="categorySelect" onchange="changeCategorySelect(this)">
|
||||||
|
<option selected value="\other"></option>
|
||||||
|
</select>
|
||||||
|
<input name="category" type="text" value="" />
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -21,6 +21,28 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var categories = {};
|
||||||
|
var defaultSavePath = "";
|
||||||
|
|
||||||
|
getCategories = function() {
|
||||||
|
new Request.JSON({
|
||||||
|
url: 'api/v2/torrents/categories',
|
||||||
|
noCache: true,
|
||||||
|
method: 'get',
|
||||||
|
onSuccess: function(data) {
|
||||||
|
if (data) {
|
||||||
|
categories = data;
|
||||||
|
for (var i in data) {
|
||||||
|
var category = data[i];
|
||||||
|
var option = new Element("option");
|
||||||
|
option.set('value', category.name);
|
||||||
|
option.set('html', category.name);
|
||||||
|
$('categorySelect').appendChild(option);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
};
|
||||||
|
|
||||||
getPreferences = function() {
|
getPreferences = function() {
|
||||||
new Request.JSON({
|
new Request.JSON({
|
||||||
@ -32,7 +54,8 @@ getPreferences = function() {
|
|||||||
},
|
},
|
||||||
onSuccess: function(pref) {
|
onSuccess: function(pref) {
|
||||||
if (pref) {
|
if (pref) {
|
||||||
$('savepath').setProperty('value', pref.save_path);
|
defaultSavePath = pref.save_path;
|
||||||
|
$('savepath').setProperty('value', defaultSavePath);
|
||||||
if (pref.auto_tmm_enabled == 1) {
|
if (pref.auto_tmm_enabled == 1) {
|
||||||
$('autoTMM').selectedIndex = 1;
|
$('autoTMM').selectedIndex = 1;
|
||||||
$('savepath').disabled = true;
|
$('savepath').disabled = true;
|
||||||
@ -45,15 +68,47 @@ getPreferences = function() {
|
|||||||
}).send();
|
}).send();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
changeCategorySelect = function(item) {
|
||||||
|
if (item.value == "\\other") {
|
||||||
|
item.nextElementSibling.hidden = false;
|
||||||
|
item.nextElementSibling.value = "";
|
||||||
|
item.nextElementSibling.select();
|
||||||
|
|
||||||
|
if ($('autotmm').selectedIndex == 1)
|
||||||
|
$('savepath').value = defaultSavePath;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
item.nextElementSibling.hidden = true;
|
||||||
|
var text = item.options[item.selectedIndex].innerHTML;
|
||||||
|
item.nextElementSibling.value = text;
|
||||||
|
|
||||||
|
if ($('autotmm').selectedIndex == 1) {
|
||||||
|
var categoryName = item.value;
|
||||||
|
var category = categories[categoryName];
|
||||||
|
var savePath = defaultSavePath;
|
||||||
|
if (category !== undefined)
|
||||||
|
savePath = (category['savePath'] !== "") ? category['savePath'] : (defaultSavePath + categoryName);
|
||||||
|
$('savepath').value = savePath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
changeTMM = function(item) {
|
changeTMM = function(item) {
|
||||||
if (item.selectedIndex == 1) {
|
if (item.selectedIndex == 1) {
|
||||||
$('savepath').disabled = true;
|
$('savepath').disabled = true;
|
||||||
|
|
||||||
|
var categorySelect = $('categorySelect');
|
||||||
|
var categoryName = categorySelect.options[categorySelect.selectedIndex].value;
|
||||||
|
var category = categories[categoryName];
|
||||||
|
$('savepath').value = (category === undefined) ? "" : category['savePath'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$('savepath').disabled = false;
|
$('savepath').disabled = false;
|
||||||
|
$('savepath').value = defaultSavePath;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(window).addEventListener("load", function() {
|
$(window).addEventListener("load", function() {
|
||||||
getPreferences();
|
getPreferences();
|
||||||
|
getCategories();
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,12 @@
|
|||||||
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
<label for="category">QBT_TR(Category:)QBT_TR[CONTEXT=AddNewTorrentDialog]</label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input type="text" id="category" name="category" style="width: 16em;" />
|
<div class="select-watched-folder-editable">
|
||||||
|
<select id="categorySelect" onchange="changeCategorySelect(this)">
|
||||||
|
<option selected value="\other"></option>
|
||||||
|
</select>
|
||||||
|
<input name="category" type="text" value="" />
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
Loading…
Reference in New Issue
Block a user