From 85b33e22beb918ac35699afd79e4bd84b7b8d459 Mon Sep 17 00:00:00 2001 From: Malcolm Jarvis Date: Fri, 24 Apr 2009 03:21:15 +0000 Subject: [PATCH] Hopefully put an end to all these percentage bugs in the web client --- web/javascript/common.js | 2 +- web/javascript/torrent.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/javascript/common.js b/web/javascript/common.js index 8ddf6a6e3..d7af16a79 100644 --- a/web/javascript/common.js +++ b/web/javascript/common.js @@ -206,7 +206,7 @@ Math.roundWithPrecision = function(floatnum, precision) { */ Math.ratio = function( numerator, denominator ) { - var result = Math.roundWithPrecision((numerator / denominator), 2); + var result = Math.floor(100 * numerator / denominator) / 100; // check for special cases if (isNaN(result)) result = 0; diff --git a/web/javascript/torrent.js b/web/javascript/torrent.js index 8f832abae..cbf872a88 100644 --- a/web/javascript/torrent.js +++ b/web/javascript/torrent.js @@ -158,8 +158,8 @@ Torrent.prototype = return ( this._sizeWhenDone - this._leftUntilDone ) / this._sizeWhenDone; }, getPercentDoneStr: function() { - return Math.ratio( 10000 * ( this._sizeWhenDone - this._leftUntilDone ), - this._sizeWhenDone ) / 100.0; + return Math.floor(100 * Math.ratio( 100 * ( this._sizeWhenDone - this._leftUntilDone ), + this._sizeWhenDone )) / 100; }, size: function() { return this._size; }, state: function() { return this._state; },