Hopefully put an end to all these percentage bugs in the web client
This commit is contained in:
parent
7f60d9db17
commit
85b33e22be
|
@ -206,7 +206,7 @@ Math.roundWithPrecision = function(floatnum, precision) {
|
||||||
*/
|
*/
|
||||||
Math.ratio = function( numerator, denominator )
|
Math.ratio = function( numerator, denominator )
|
||||||
{
|
{
|
||||||
var result = Math.roundWithPrecision((numerator / denominator), 2);
|
var result = Math.floor(100 * numerator / denominator) / 100;
|
||||||
|
|
||||||
// check for special cases
|
// check for special cases
|
||||||
if (isNaN(result)) result = 0;
|
if (isNaN(result)) result = 0;
|
||||||
|
|
|
@ -158,8 +158,8 @@ Torrent.prototype =
|
||||||
return ( this._sizeWhenDone - this._leftUntilDone ) / this._sizeWhenDone;
|
return ( this._sizeWhenDone - this._leftUntilDone ) / this._sizeWhenDone;
|
||||||
},
|
},
|
||||||
getPercentDoneStr: function() {
|
getPercentDoneStr: function() {
|
||||||
return Math.ratio( 10000 * ( this._sizeWhenDone - this._leftUntilDone ),
|
return Math.floor(100 * Math.ratio( 100 * ( this._sizeWhenDone - this._leftUntilDone ),
|
||||||
this._sizeWhenDone ) / 100.0;
|
this._sizeWhenDone )) / 100;
|
||||||
},
|
},
|
||||||
size: function() { return this._size; },
|
size: function() { return this._size; },
|
||||||
state: function() { return this._state; },
|
state: function() { return this._state; },
|
||||||
|
|
Loading…
Reference in New Issue