mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
Allow >100 days in WebUI function "friendlyDuration"
Because it's not only used for ETA.
This commit is contained in:
parent
9f30aba2b3
commit
d124041726
@ -1103,7 +1103,7 @@ window.qBittorrent.DynamicTable = (function() {
|
|||||||
|
|
||||||
// eta
|
// eta
|
||||||
this.columns['eta'].updateTd = function(td, row) {
|
this.columns['eta'].updateTd = function(td, row) {
|
||||||
const eta = window.qBittorrent.Misc.friendlyDuration(this.getRowValue(row));
|
const eta = window.qBittorrent.Misc.friendlyDuration(this.getRowValue(row), window.qBittorrent.Misc.MAX_ETA));
|
||||||
td.set('text', eta);
|
td.set('text', eta);
|
||||||
td.set('title', eta);
|
td.set('title', eta);
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,8 @@ window.qBittorrent.Misc = (function() {
|
|||||||
escapeHtml: escapeHtml,
|
escapeHtml: escapeHtml,
|
||||||
safeTrim: safeTrim,
|
safeTrim: safeTrim,
|
||||||
toFixedPointString: toFixedPointString,
|
toFixedPointString: toFixedPointString,
|
||||||
containsAllTerms: containsAllTerms
|
containsAllTerms: containsAllTerms,
|
||||||
|
MAX_ETA: 8640000
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -94,9 +95,8 @@ window.qBittorrent.Misc = (function() {
|
|||||||
/*
|
/*
|
||||||
* JS counterpart of the function in src/misc.cpp
|
* JS counterpart of the function in src/misc.cpp
|
||||||
*/
|
*/
|
||||||
const friendlyDuration = function(seconds) {
|
const friendlyDuration = function(seconds, maxCap = -1) {
|
||||||
const MAX_ETA = 8640000;
|
if (seconds < 0 || ((seconds >= maxCap) && (maxCap >= 0)))
|
||||||
if (seconds < 0 || seconds >= MAX_ETA)
|
|
||||||
return "∞";
|
return "∞";
|
||||||
if (seconds === 0)
|
if (seconds === 0)
|
||||||
return "0";
|
return "0";
|
||||||
@ -109,11 +109,13 @@ window.qBittorrent.Misc = (function() {
|
|||||||
minutes = minutes % 60;
|
minutes = minutes % 60;
|
||||||
if (hours < 24)
|
if (hours < 24)
|
||||||
return "QBT_TR(%1h %2m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes));
|
return "QBT_TR(%1h %2m)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(hours)).replace("%2", parseInt(minutes));
|
||||||
const days = hours / 24;
|
let days = hours / 24;
|
||||||
hours = hours % 24;
|
hours = hours % 24;
|
||||||
if (days < 100)
|
if (days < 365)
|
||||||
return "QBT_TR(%1d %2h)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(days)).replace("%2", parseInt(hours));
|
return "QBT_TR(%1d %2h)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(days)).replace("%2", parseInt(hours));
|
||||||
return "∞";
|
const years = days / 365;
|
||||||
|
days = days % 365;
|
||||||
|
return "QBT_TR(%1y %2d)QBT_TR[CONTEXT=misc]".replace("%1", parseInt(years)).replace("%2", parseInt(days));
|
||||||
}
|
}
|
||||||
|
|
||||||
const friendlyPercentage = function(value) {
|
const friendlyPercentage = function(value) {
|
||||||
@ -213,3 +215,5 @@ window.qBittorrent.Misc = (function() {
|
|||||||
|
|
||||||
return exports();
|
return exports();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
Object.freeze(window.qBittorrent.Misc);
|
||||||
|
@ -105,7 +105,7 @@ window.qBittorrent.PropGeneral = (function() {
|
|||||||
temp = window.qBittorrent.Misc.friendlyDuration(data.time_elapsed);
|
temp = window.qBittorrent.Misc.friendlyDuration(data.time_elapsed);
|
||||||
$('time_elapsed').set('html', temp);
|
$('time_elapsed').set('html', temp);
|
||||||
|
|
||||||
$('eta').set('html', window.qBittorrent.Misc.friendlyDuration(data.eta));
|
$('eta').set('html', window.qBittorrent.Misc.friendlyDuration(data.eta, window.qBittorrent.Misc.MAX_ETA));
|
||||||
|
|
||||||
temp = "QBT_TR(%1 (%2 max))QBT_TR[CONTEXT=PropertiesWidget]"
|
temp = "QBT_TR(%1 (%2 max))QBT_TR[CONTEXT=PropertiesWidget]"
|
||||||
.replace("%1", data.nb_connections)
|
.replace("%1", data.nb_connections)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user