Merge pull request #8598 from Piccirello/limit-share-ratio

WebUI Add Limit Share Ratio context menu option
This commit is contained in:
Mike Tzou
2018-04-15 00:39:27 +08:00
committed by GitHub
12 changed files with 245 additions and 8 deletions

View File

@@ -769,7 +769,7 @@ var TorrentsTable = new Class({
this.newColumn('time_active', '', 'QBT_TR(Time Active)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('save_path', '', 'QBT_TR(Save path)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('completed', '', 'QBT_TR(Completed)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('ratio_limit', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('max_ratio', '', 'QBT_TR(Ratio Limit)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('seen_complete', '', 'QBT_TR(Last Seen Complete)QBT_TR[CONTEXT=TorrentModel]', 100, false);
this.newColumn('last_activity', '', 'QBT_TR(Last Activity)QBT_TR[CONTEXT=TorrentModel]', 100, false);
@@ -1076,8 +1076,8 @@ var TorrentsTable = new Class({
this.columns['save_path'].updateTd = this.columns['name'].updateTd;
this.columns['tracker'].updateTd = this.columns['name'].updateTd;
// ratio_limit
this.columns['ratio_limit'].updateTd = this.columns['ratio'].updateTd;
// max_ratio
this.columns['max_ratio'].updateTd = this.columns['ratio'].updateTd;
// last_activity
this.columns['last_activity'].updateTd = function(td, row) {

View File

@@ -76,6 +76,10 @@ function friendlyPercentage(value) {
return percentage.toFixed(1) + "%";
}
function friendlyFloat(value, precision) {
return parseFloat(value).toFixed(precision);
}
/*
* From: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
*/

View File

@@ -146,7 +146,6 @@ initializeWindows = function() {
uploadLimitFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
var hash = hashes[0];
new MochaUI.Window({
id: 'uploadLimitPage',
title: "QBT_TR(Torrent Upload Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
@@ -163,6 +162,45 @@ initializeWindows = function() {
}
};
shareRatioFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
var shareRatio = null;
var torrentsHaveSameShareRatio = true;
// check if all selected torrents have same share ratio
for (var i = 0; i < hashes.length; i++) {
var hash = hashes[i];
var row = torrentsTable.rows[hash].full_data;
var origValues = row.ratio_limit + "|" + row.seeding_time_limit + "|" + row.max_ratio + "|" + row.max_seeding_time;
// initialize value
if (shareRatio === null)
shareRatio = origValues;
if (origValues !== shareRatio) {
torrentsHaveSameShareRatio = false;
break;
}
}
// if all torrents have same share ratio, display that share ratio. else use the default
var orig = torrentsHaveSameShareRatio ? shareRatio : "";
new MochaUI.Window({
id: 'shareRatioPage',
title: "QBT_TR(Torrent Upload/Download Ratio Limiting)QBT_TR[CONTEXT=UpDownRatioDlg]",
loadMethod: 'iframe',
contentURL: 'shareratio.html?hashes=' + hashes.join("|") + '&orig=' + orig,
scrollbars: false,
maximizable: false,
paddingVertical: 0,
paddingHorizontal: 0,
width: 424,
height: 175
});
}
};
toggleSequentialDownloadFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
@@ -257,7 +295,6 @@ initializeWindows = function() {
downloadLimitFN = function() {
var hashes = torrentsTable.selectedRowsIds();
if (hashes.length) {
var hash = hashes[0];
new MochaUI.Window({
id: 'downloadLimitPage',
title: "QBT_TR(Torrent Download Speed Limiting)QBT_TR[CONTEXT=TransferListWidget]",
@@ -388,12 +425,11 @@ initializeWindows = function() {
var hash = hashes[0];
var row = torrentsTable.rows[hash];
if (row) {
var name = row.full_data.name;
new MochaUI.Window({
id: 'renamePage',
title: "QBT_TR(Rename)QBT_TR[CONTEXT=TransferListWidget]",
loadMethod: 'iframe',
contentURL: 'rename.html?hash=' + hashes[0] + '&name=' + name,
contentURL: 'rename.html?hash=' + hashes[0] + '&name=' + row.full_data.name,
scrollbars: false,
resizable: false,
maximizable: false,