mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-30 08:24:22 +00:00
Fix display bugs in WebUI Files tab. Remove <IE9 support
Priority select boxes would frequently go blank due to an unexpected priority value. On first load, the torrent-scoped file checkbox's state was inconsistent with the state of the torrent's files.
This commit is contained in:
parent
a44ed9cfd3
commit
66015164d7
@ -133,7 +133,7 @@
|
|||||||
<table class="dynamicTable" style="width: 100%">
|
<table class="dynamicTable" style="width: 100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 4.5em; border-right: 0"><input type="checkbox" id="tristate_cb" style="display: none;" onclick="javascript:switchCBState()" /><label id="all_files_cb" class="tristate" for="tristate_cb"></label></th>
|
<th style="width: 4.5em; border-right: 0"><input type="checkbox" id="tristate_cb" onclick="switchCBState()" /></th>
|
||||||
<th>QBT_TR(Name)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th>QBT_TR(Name)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
<th style="width: 150px;">QBT_TR(Size)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th style="width: 150px;">QBT_TR(Size)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
<th style="width: 90px;">QBT_TR(Progress)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
<th style="width: 90px;">QBT_TR(Progress)QBT_TR[CONTEXT=TorrentContentModel]</th>
|
||||||
|
@ -1,51 +1,26 @@
|
|||||||
var is_seed = true;
|
var is_seed = true;
|
||||||
var current_hash = "";
|
var current_hash = "";
|
||||||
|
|
||||||
if (!(Browser.name == "ie" && Browser.version < 9)) {
|
|
||||||
$("all_files_cb").removeClass("tristate");
|
|
||||||
$("all_files_cb").removeClass("partial");
|
|
||||||
$("all_files_cb").removeClass("checked");
|
|
||||||
$("tristate_cb").style.display = "inline";
|
|
||||||
}
|
|
||||||
|
|
||||||
var setCBState = function(state) {
|
var setCBState = function(state) {
|
||||||
if (Browser.name == "ie" && Browser.version < 9) {
|
$("tristate_cb").state = state;
|
||||||
if (state == "partial") {
|
if (state === "partial") {
|
||||||
if (!$("all_files_cb").hasClass("partial")) {
|
$("tristate_cb").indeterminate = true;
|
||||||
$("all_files_cb").removeClass("checked");
|
|
||||||
$("all_files_cb").addClass("partial");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (state == "checked") {
|
|
||||||
if (!$("all_files_cb").hasClass("checked")) {
|
|
||||||
$("all_files_cb").removeClass("partial");
|
|
||||||
$("all_files_cb").addClass("checked");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$("all_files_cb").removeClass("partial");
|
|
||||||
$("all_files_cb").removeClass("checked");
|
|
||||||
}
|
}
|
||||||
else {
|
else if (state === "checked") {
|
||||||
if (state == "partial") {
|
$("tristate_cb").indeterminate = false;
|
||||||
$("tristate_cb").indeterminate = true;
|
$("tristate_cb").checked = true;
|
||||||
}
|
}
|
||||||
else if (state == "checked") {
|
else if (state === "unchecked") {
|
||||||
$("tristate_cb").indeterminate = false;
|
$("tristate_cb").indeterminate = false;
|
||||||
$("tristate_cb").checked = true;
|
$("tristate_cb").checked = false;
|
||||||
}
|
|
||||||
else {
|
|
||||||
$("tristate_cb").indeterminate = false;
|
|
||||||
$("tristate_cb").checked = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var switchCBState = function() {
|
var switchCBState = function() {
|
||||||
// Uncheck
|
// Uncheck
|
||||||
if ($("all_files_cb").hasClass("partial")) {
|
if (($("tristate_cb").state === "partial") || ($("tristate_cb").state === "checked")) {
|
||||||
$("all_files_cb").removeClass("partial");
|
$("tristate_cb").state = "unchecked";
|
||||||
|
$("tristate_cb").checked = false;
|
||||||
// Uncheck all checkboxes
|
// Uncheck all checkboxes
|
||||||
var indexes = [];
|
var indexes = [];
|
||||||
$$('input.DownloadedCB').each(function(item, index) {
|
$$('input.DownloadedCB').each(function(item, index) {
|
||||||
@ -53,28 +28,19 @@ var switchCBState = function() {
|
|||||||
indexes.push(index);
|
indexes.push(index);
|
||||||
});
|
});
|
||||||
setFilePriority(indexes, 0);
|
setFilePriority(indexes, 0);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if ($("all_files_cb").hasClass("checked")) {
|
else if ($("tristate_cb").state === "unchecked") {
|
||||||
$("all_files_cb").removeClass("checked");
|
// Check
|
||||||
// Uncheck all checkboxes
|
$("tristate_cb").state = "checked";
|
||||||
|
$("tristate_cb").checked = true;
|
||||||
|
// Check all checkboxes
|
||||||
var indexes = [];
|
var indexes = [];
|
||||||
$$('input.DownloadedCB').each(function(item, index) {
|
$$('input.DownloadedCB').each(function(item, index) {
|
||||||
item.erase("checked");
|
item.set("checked", "checked");
|
||||||
indexes.push(index);
|
indexes.push(index);
|
||||||
});
|
});
|
||||||
setFilePriority(indexes, 0);
|
setFilePriority(indexes, FilePriority.Normal);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
// Check
|
|
||||||
$("all_files_cb").addClass("checked");
|
|
||||||
// Check all checkboxes
|
|
||||||
var indexes = [];
|
|
||||||
$$('input.DownloadedCB').each(function(item, index) {
|
|
||||||
item.set("checked", "checked");
|
|
||||||
indexes.push(index);
|
|
||||||
});
|
|
||||||
setFilePriority(indexes, 1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var allCBChecked = function() {
|
var allCBChecked = function() {
|
||||||
@ -97,10 +63,32 @@ var allCBUnchecked = function() {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var FilePriority = {
|
||||||
|
"Ignored": 0,
|
||||||
|
"Normal": 1,
|
||||||
|
"High": 6,
|
||||||
|
"Maximum": 7,
|
||||||
|
"Mixed": -1
|
||||||
|
};
|
||||||
|
|
||||||
|
var normalizePriority = function(priority) {
|
||||||
|
switch (priority) {
|
||||||
|
case FilePriority.Ignored:
|
||||||
|
case FilePriority.Normal:
|
||||||
|
case FilePriority.High:
|
||||||
|
case FilePriority.Maximum:
|
||||||
|
case FilePriority.Mixed:
|
||||||
|
return priority;
|
||||||
|
default:
|
||||||
|
return FilePriority.Normal;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var setFilePriority = function(id, priority) {
|
var setFilePriority = function(id, priority) {
|
||||||
if (current_hash === "") return;
|
if (current_hash === "") return;
|
||||||
var ids = Array.isArray(id) ? id : [id];
|
var ids = Array.isArray(id) ? id : [id];
|
||||||
|
|
||||||
|
clearTimeout(loadTorrentFilesDataTimer);
|
||||||
new Request({
|
new Request({
|
||||||
url: 'api/v2/torrents/filePrio',
|
url: 'api/v2/torrents/filePrio',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -108,6 +96,9 @@ var setFilePriority = function(id, priority) {
|
|||||||
'hash': current_hash,
|
'hash': current_hash,
|
||||||
'id': ids.join('|'),
|
'id': ids.join('|'),
|
||||||
'priority': priority
|
'priority': priority
|
||||||
|
},
|
||||||
|
onComplete: function() {
|
||||||
|
loadTorrentFilesDataTimer = loadTorrentFilesData.delay(1000);
|
||||||
}
|
}
|
||||||
}).send();
|
}).send();
|
||||||
// Display or add combobox
|
// Display or add combobox
|
||||||
@ -142,13 +133,11 @@ var createDownloadedCB = function(id, downloaded) {
|
|||||||
if (allCBChecked()) {
|
if (allCBChecked()) {
|
||||||
setCBState("checked");
|
setCBState("checked");
|
||||||
}
|
}
|
||||||
|
else if (allCBUnchecked()) {
|
||||||
|
setCBState("unchecked");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (allCBUnchecked()) {
|
setCBState("partial");
|
||||||
setCBState("unchecked");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setCBState("partial");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return CB;
|
return CB;
|
||||||
@ -166,23 +155,16 @@ var createPriorityCombo = function(id, selected_prio) {
|
|||||||
var elem = new Element("option");
|
var elem = new Element("option");
|
||||||
elem.set('value', priority.toString());
|
elem.set('value', priority.toString());
|
||||||
elem.set('html', html);
|
elem.set('html', html);
|
||||||
if (selected_prio == priority)
|
if (priority == selected_prio)
|
||||||
elem.setAttribute('selected', 'true');
|
elem.setAttribute('selected', '');
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
var normal = createOptionElement(1, "QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]");
|
createOptionElement(FilePriority.Normal, "QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
|
||||||
if (selected_prio <= 0)
|
createOptionElement(FilePriority.High, "QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
|
||||||
normal.setAttribute('selected', '');
|
createOptionElement(FilePriority.Maximum, "QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]").injectInside(select);
|
||||||
normal.injectInside(select);
|
|
||||||
|
|
||||||
var high = createOptionElement(6, "QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]");
|
if (is_seed || (selected_prio === FilePriority.Ignored) || (selected_prio === FilePriority.Mixed)) {
|
||||||
high.injectInside(select);
|
|
||||||
|
|
||||||
var maximum = createOptionElement(7, "QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]");
|
|
||||||
maximum.injectInside(select);
|
|
||||||
|
|
||||||
if (is_seed || selected_prio < 1) {
|
|
||||||
select.addClass("invisible");
|
select.addClass("invisible");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -231,8 +213,9 @@ var filesDynTable = new Class({
|
|||||||
$('pbf_' + id).setValue(row[i].toFloat());
|
$('pbf_' + id).setValue(row[i].toFloat());
|
||||||
break;
|
break;
|
||||||
case 4: // download priority
|
case 4: // download priority
|
||||||
if (!is_seed && row[i] > 0) {
|
var priority = normalizePriority(row[i]);
|
||||||
tds[i].getChildren('select').set('value', row[i]);
|
if (!is_seed && (priority > 0)) {
|
||||||
|
tds[i].getChildren('select').set('value', priority);
|
||||||
if ($('comboPrio' + id).hasClass("invisible"))
|
if ($('comboPrio' + id).hasClass("invisible"))
|
||||||
$('comboPrio' + id).removeClass("invisible");
|
$('comboPrio' + id).removeClass("invisible");
|
||||||
}
|
}
|
||||||
@ -278,7 +261,7 @@ var filesDynTable = new Class({
|
|||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
td.adopt(createPriorityCombo(id, row[i]));
|
td.adopt(createPriorityCombo(id, normalizePriority(row[i])));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
td.set('html', row[i]);
|
td.set('html', row[i]);
|
||||||
@ -346,13 +329,11 @@ var loadTorrentFilesData = function() {
|
|||||||
if (allCBChecked()) {
|
if (allCBChecked()) {
|
||||||
setCBState("checked");
|
setCBState("checked");
|
||||||
}
|
}
|
||||||
|
else if (allCBUnchecked()) {
|
||||||
|
setCBState("unchecked");
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (allCBUnchecked()) {
|
setCBState("partial");
|
||||||
setCBState("unchecked");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
setCBState("partial");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user