]> granicus.if.org Git - transmission/commitdiff
Hopefully put an end to all these percentage bugs in the web client
authorMalcolm Jarvis <malcolm@boolable.ca>
Fri, 24 Apr 2009 03:21:15 +0000 (03:21 +0000)
committerMalcolm Jarvis <malcolm@boolable.ca>
Fri, 24 Apr 2009 03:21:15 +0000 (03:21 +0000)
web/javascript/common.js
web/javascript/torrent.js

index 8ddf6a6e39dd4a2b796a2cb16659f7091ec38a82..d7af16a7905db529bd7b79f68cdfe8ee6be4f12c 100644 (file)
@@ -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;
index 8f832abae0e402bf5534e7f27966ed49cb4659f1..cbf872a8878e03404c345565a39551bebcd7e761 100644 (file)
@@ -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; },