Changeset 398

Show
Ignore:
Timestamp:
07/01/08 08:41:15 (2 months ago)
Author:
charles
Message:

fix swarm speed and ratio formatting bugs that were introduced during the RPC changes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/rpc/web/javascript/torrent.js

    r394 r398  
    130130        peersDownloading: function() { return this._peers_downloading; }, 
    131131        peersUploading: function() { return this._peers_uploading; }, 
    132         percentCompleted: function() { return this._percent_completed; }, 
    133132        size: function() { return this._size; }, 
    134133        state: function() { return this._state; }, 
     
    260259                this._completed         = data.haveUnchecked + data.haveValid; 
    261260                this._verified          = data.haveValid; 
    262                 this._percent_completed = 100 * this._completed / this._size; 
    263261                this._download_total    = data.downloadedEver; 
    264262                this._upload_total      = data.uploadedEver; 
     
    271269                this._error_message     = data.errorString; 
    272270                this._eta               = data.eta; 
    273                 this._swarm_speed       = data.swarm_speed; 
     271                this._swarm_speed       = data.swarmSpeed; 
    274272                this._total_leechers    = data.leechers; 
    275273                this._total_seeders     = data.seeders; 
     
    301299                 
    302300                // Figure out the percent completed 
    303                 var css_percent_completed = Math.floor(this._percent_completed * Torrent._MaxProgressBarWidth / 100)
    304                 var int_percent_completed = Math.floor(this._percent_completed); 
     301                var percent_completed = this._completed / this._size
     302                var css_completed_width = Math.floor(this._percent_completed * Torrent._MaxProgressBarWidth ); 
    305303                 
    306304                // Sometimes get figures greater that the max 
    307                 if (css_percent_completed > Torrent._MaxProgressBarWidth) { 
    308                     css_percent_completed = Torrent._MaxProgressBarWidth; 
     305                if (css_completed_width > Torrent._MaxProgressBarWidth) { 
     306                    css_completed_width = Torrent._MaxProgressBarWidth; 
    309307                } 
    310308                 
    311309                // Add the progress bar 
    312                 if (int_percent_completed < 100 && this.state() != "seeding") 
     310                var notDone = this._completed < this._size; 
     311                if( notDone ) 
    313312                { 
    314                         // Add the decimals if the percentage is an integer 
    315                         if ((this._percent_completed % 1) == 0) { 
    316                                 this._percent_completed = this._percent_completed + '.00'; 
    317                         } 
    318313                        // Create the 'progress details' label 
    319314                        // Eg: '101 MB of 631 MB (16.02%) - 2 hr 30 min remaining' 
    320315                        progress_details = Math.formatBytes(this._completed) + ' of '; 
    321316                        progress_details += Math.formatBytes(this._size) + ' ('; 
    322                         progress_details += this._percent_completed + '%)'; 
     317                        progress_details += Math.ratio( this._completed, this._size ) + '%)'; 
    323318                        if ((this._eta < 0 || this._eta >= Torrent._InfiniteTimeRemaining) && this.isActive()) { 
    324319                                progress_details += ' - remaining time unknown'; 
     
    332327                        root._progress_complete_container.addClass('torrent_progress_bar'); 
    333328                        root._progress_complete_container.addClass(class_name); 
    334                         root._progress_complete_container.css('width', css_percent_completed + '%'); 
     329                        root._progress_complete_container.css('width', css_completed_width + '%'); 
    335330                         
    336331                        // Update the 'incomplete' bar 
     
    339334                                root._progress_incomplete_container.addClass('torrent_progress_bar in_progress'); 
    340335                        } 
    341                         root._progress_incomplete_container.css('width', (Torrent._MaxProgressBarWidth - css_percent_completed) + '%'); 
     336                        root._progress_incomplete_container.css('width', (Torrent._MaxProgressBarWidth - css_completed_width) + '%'); 
    342337                        root._progress_incomplete_container.show(); 
    343338                         
     
    370365                        progress_details += Math.ratio(this._completed, this._size) + ')'; 
    371366                         
    372                     // Hide the 'incomplete' bar 
     367                       // Hide the 'incomplete' bar 
    373368                        root._progress_incomplete_container.hide(); 
    374                  
     369                        
    375370                        // Set progress to maximum 
    376371                        root._progress_complete_container.css('width', Torrent._MaxProgressBarWidth + '%'); 
     
    503498                        break; 
    504499        } 
    505  
     500         
    506501        if( sortDirection == Prefs._SortDescending ) 
    507502                torrents.reverse( ); 
    508  
     503         
    509504        return torrents; 
    510505} 
  • branches/rpc/web/javascript/transmission.js

    r396 r398  
    889889                $(ti+'secure')[0].innerHTML          = private_string; 
    890890                $(ti+'creator_date')[0].innerHTML    = date_created; 
    891                 $(ti+'progress')[0].innerHTML        = Math.ratio( total_completed, total_size ) + '% (' + 
    892                                                        Math.ratio( total_completed, total_size ) + '% Selected)'; 
     891                $(ti+'progress')[0].innerHTML        = Math.ratio( total_completed * 100, total_size ) + '% (' + 
     892                                                       Math.ratio( total_completed * 100, total_size ) + '% Selected)'; 
    893893        }, 
    894894