|
|
@ -47,28 +47,34 @@ var switchCBState = function() { |
|
|
|
if ($("all_files_cb").hasClass("partial")) { |
|
|
|
if ($("all_files_cb").hasClass("partial")) { |
|
|
|
$("all_files_cb").removeClass("partial"); |
|
|
|
$("all_files_cb").removeClass("partial"); |
|
|
|
// Uncheck all checkboxes
|
|
|
|
// Uncheck all checkboxes
|
|
|
|
|
|
|
|
var indexes = []; |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
item.erase("checked"); |
|
|
|
item.erase("checked"); |
|
|
|
setFilePriority(index, 0); |
|
|
|
indexes.push(index); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
setFilePriority(indexes, 0); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($("all_files_cb").hasClass("checked")) { |
|
|
|
if ($("all_files_cb").hasClass("checked")) { |
|
|
|
$("all_files_cb").removeClass("checked"); |
|
|
|
$("all_files_cb").removeClass("checked"); |
|
|
|
// Uncheck all checkboxes
|
|
|
|
// Uncheck all checkboxes
|
|
|
|
|
|
|
|
var indexes = []; |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
item.erase("checked"); |
|
|
|
item.erase("checked"); |
|
|
|
setFilePriority(index, 0); |
|
|
|
indexes.push(index); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
setFilePriority(indexes, 0); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
// Check
|
|
|
|
// Check
|
|
|
|
$("all_files_cb").addClass("checked"); |
|
|
|
$("all_files_cb").addClass("checked"); |
|
|
|
// Check all checkboxes
|
|
|
|
// Check all checkboxes
|
|
|
|
|
|
|
|
var indexes = []; |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
$$('input.DownloadedCB').each(function(item, index) { |
|
|
|
item.set("checked", "checked"); |
|
|
|
item.set("checked", "checked"); |
|
|
|
setFilePriority(index, 1); |
|
|
|
indexes.push(index); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
setFilePriority(indexes, 1); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var allCBChecked = function() { |
|
|
|
var allCBChecked = function() { |
|
|
@ -93,22 +99,31 @@ var allCBUnchecked = function() { |
|
|
|
|
|
|
|
|
|
|
|
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]; |
|
|
|
|
|
|
|
|
|
|
|
new Request({ |
|
|
|
new Request({ |
|
|
|
url: 'api/v2/torrents/filePrio', |
|
|
|
url: 'api/v2/torrents/filePrio', |
|
|
|
method: 'post', |
|
|
|
method: 'post', |
|
|
|
data: { |
|
|
|
data: { |
|
|
|
'hash': current_hash, |
|
|
|
'hash': current_hash, |
|
|
|
'id': id, |
|
|
|
'id': ids.join('|'), |
|
|
|
'priority': priority |
|
|
|
'priority': priority |
|
|
|
} |
|
|
|
} |
|
|
|
}).send(); |
|
|
|
}).send(); |
|
|
|
// Display or add combobox
|
|
|
|
// Display or add combobox
|
|
|
|
if (priority > 0) { |
|
|
|
if (priority > 0) { |
|
|
|
$('comboPrio' + id).set("value", 1); |
|
|
|
ids.forEach(function(_id) { |
|
|
|
$('comboPrio' + id).removeClass("invisible"); |
|
|
|
if ($('comboPrio' + _id).hasClass("invisible")) { |
|
|
|
|
|
|
|
$('comboPrio' + _id).set("value", priority); |
|
|
|
|
|
|
|
$('comboPrio' + _id).removeClass("invisible"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
$('comboPrio' + id).addClass("invisible"); |
|
|
|
ids.forEach(function(_id) { |
|
|
|
|
|
|
|
if (!$('comboPrio' + _id).hasClass("invisible")) |
|
|
|
|
|
|
|
$('comboPrio' + _id).addClass("invisible"); |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -146,24 +161,27 @@ var createPriorityCombo = function(id, selected_prio) { |
|
|
|
var new_prio = $('comboPrio' + id).get('value'); |
|
|
|
var new_prio = $('comboPrio' + id).get('value'); |
|
|
|
setFilePriority(id, new_prio); |
|
|
|
setFilePriority(id, new_prio); |
|
|
|
}); |
|
|
|
}); |
|
|
|
var opt = new Element("option"); |
|
|
|
|
|
|
|
opt.set('value', '1'); |
|
|
|
function createOptionElement(priority, html) { |
|
|
|
opt.set('html', "QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
var elem = new Element("option"); |
|
|
|
if (selected_prio <= 1) |
|
|
|
elem.set('value', priority.toString()); |
|
|
|
opt.setAttribute('selected', ''); |
|
|
|
elem.set('html', html); |
|
|
|
opt.injectInside(select); |
|
|
|
if (selected_prio == priority) |
|
|
|
opt = new Element("option"); |
|
|
|
elem.setAttribute('selected', 'true'); |
|
|
|
opt.set('value', '2'); |
|
|
|
return elem; |
|
|
|
opt.set('html', "QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
} |
|
|
|
if (selected_prio == 2) |
|
|
|
|
|
|
|
opt.setAttribute('selected', ''); |
|
|
|
var normal = createOptionElement(1, "QBT_TR(Normal)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
opt.injectInside(select); |
|
|
|
if (selected_prio <= 0) |
|
|
|
opt = new Element("option"); |
|
|
|
normal.setAttribute('selected', ''); |
|
|
|
opt.set('value', '7'); |
|
|
|
normal.injectInside(select); |
|
|
|
opt.set('html', "QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
|
|
|
|
if (selected_prio == 7) |
|
|
|
var high = createOptionElement(2, "QBT_TR(High)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
opt.setAttribute('selected', ''); |
|
|
|
high.injectInside(select); |
|
|
|
opt.injectInside(select); |
|
|
|
|
|
|
|
|
|
|
|
var maximum = createOptionElement(7, "QBT_TR(Maximum)QBT_TR[CONTEXT=PropListDelegate]"); |
|
|
|
|
|
|
|
maximum.injectInside(select); |
|
|
|
|
|
|
|
|
|
|
|
if (is_seed || selected_prio < 1) { |
|
|
|
if (is_seed || selected_prio < 1) { |
|
|
|
select.addClass("invisible"); |
|
|
|
select.addClass("invisible"); |
|
|
|
} |
|
|
|
} |
|
|
@ -203,18 +221,19 @@ var filesDynTable = new Class({ |
|
|
|
var tds = tr.getElements('td'); |
|
|
|
var tds = tr.getElements('td'); |
|
|
|
for (var i = 0; i < row.length; ++i) { |
|
|
|
for (var i = 0; i < row.length; ++i) { |
|
|
|
switch (i) { |
|
|
|
switch (i) { |
|
|
|
case 0: |
|
|
|
case 0: // checkbox
|
|
|
|
if (row[i] > 0) |
|
|
|
if (row[i] > 0) |
|
|
|
tds[i].getChildren('input')[0].set('checked', 'checked'); |
|
|
|
tds[i].getChildren('input')[0].set('checked', 'checked'); |
|
|
|
else |
|
|
|
else |
|
|
|
tds[i].getChildren('input')[0].removeProperty('checked'); |
|
|
|
tds[i].getChildren('input')[0].removeProperty('checked'); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: |
|
|
|
case 3: // progress bar
|
|
|
|
$('pbf_' + id).setValue(row[i].toFloat()); |
|
|
|
$('pbf_' + id).setValue(row[i].toFloat()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 4: |
|
|
|
case 4: // download priority
|
|
|
|
if (!is_seed && row[i] > 0) { |
|
|
|
if (!is_seed && row[i] > 0) { |
|
|
|
tds[i].getChildren('select').set('value', row[i]); |
|
|
|
tds[i].getChildren('select').set('value', row[i]); |
|
|
|
|
|
|
|
if ($('comboPrio' + id).hasClass("invisible")) |
|
|
|
$('comboPrio' + id).removeClass("invisible"); |
|
|
|
$('comboPrio' + id).removeClass("invisible"); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|