From 306bd497b89c8cc20c0057e697dd47e040237910 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 20 Mar 2012 00:41:57 +0000 Subject: [PATCH] (web) #4841 & #4842 Fix inspector statistics when multiple torrents are selected. Fix the ratio displayed when the download count for a single transfer is 0 but there is data on disk. --- web/javascript/inspector.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/web/javascript/inspector.js b/web/javascript/inspector.js index 37768a418..6c8bc97f5 100644 --- a/web/javascript/inspector.js +++ b/web/javascript/inspector.js @@ -203,8 +203,8 @@ function Inspector(controller) { else { d = f = 0; for(i=0; t=torrents[i]; ++i) { - d = t.getDownloadedEver(); - f = t.getFailedEver(); + d += t.getDownloadedEver(); + f += t.getFailedEver(); } if(f) str = fmt.size(d) + ' (' + fmt.size(f) + ' corrupt)'; @@ -221,10 +221,19 @@ function Inspector(controller) { str = none; else { d = u = 0; - for(i=0; t=torrents[i]; ++i) { - d = t.getDownloadedEver(); - u = t.getUploadedEver(); + if(torrents.length == 1) { + d = torrents[0].getDownloadedEver(); + u = torrents[0].getUploadedEver(); + + if (d == 0) + d = torrents[0].getHaveValid(); } + else { + for(i=0; t=torrents[i]; ++i) { + d += t.getDownloadedEver(); + u += t.getUploadedEver(); + } + } str = fmt.size(u) + ' (Ratio: ' + fmt.ratioString( Math.ratio(u,d))+')'; } setInnerHTML(e.uploaded_lb, str);