From c1f9ebd38a5e25ab9b60fa4e9945eff7dd6020bf Mon Sep 17 00:00:00 2001 From: "mscott%netscape.com" Date: Wed, 4 Jul 2001 04:14:56 +0000 Subject: [PATCH] Bug 84410 --> properly show unknown time and put the progress bar in undetermined mode when we don't know how large the download is. r=sspitzer sr=blake git-svn-id: svn://10.0.0.236/trunk@98621 18797224-902f-48f8-a5cc-f745e15eee43 --- .../ucth/resources/helperAppDldProgress.js | 35 ++++++++++++------- .../locale/en-US/downloadProgress.dtd | 2 +- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/mozilla/xpfe/components/ucth/resources/helperAppDldProgress.js b/mozilla/xpfe/components/ucth/resources/helperAppDldProgress.js index 912a159d2f1..9c03b8e39ad 100644 --- a/mozilla/xpfe/components/ucth/resources/helperAppDldProgress.js +++ b/mozilla/xpfe/components/ucth/resources/helperAppDldProgress.js @@ -77,12 +77,16 @@ var progressListener = { if (!gRestartChecked) { gRestartChecked = true; - // right now, all that supports restarting downloads is ftp (rfc959) - ftpChannel = aRequest.QueryInterface(Components.interfaces.nsIFTPChannel); - if (ftpChannel) { + try + { + // right now, all that supports restarting downloads is ftp (rfc959) + ftpChannel = aRequest.QueryInterface(Components.interfaces.nsIFTPChannel); + if (ftpChannel) { dialog.pause.setAttribute("hidden", false); dialog.pause.setAttribute("label", getString("pause")); + } } + catch (ex) {} } // this is so that we don't clobber the status text if @@ -118,7 +122,7 @@ var progressListener = { // Calculate percentage. var percent; - if ( aMaxTotalProgress != "-1" ) + if ( aMaxTotalProgress > 0) { percent = parseInt( (overallProgress*100)/aMaxTotalProgress + .5 ); if ( percent > 100 ) @@ -129,7 +133,7 @@ var progressListener = { } else { - percent = "??"; + percent = -1; // Progress meter should be barber-pole in this case. dialog.progress.setAttribute( "mode", "undetermined" ); @@ -183,20 +187,25 @@ var progressListener = { // Update status msg. dialog.status.setAttribute("value", status); - // Update percentage label on progress meter. - var percentMsg = getString( "percentMsg" ); - percentMsg = replaceInsert( percentMsg, 1, percent ); - dialog.progressText.setAttribute("value", percentMsg); + // Update percentage label on progress meter. + if (percent < 0) + dialog.progressText.setAttribute("value", ""); + else + { + var percentMsg = getString( "percentMsg" ); + percentMsg = replaceInsert( percentMsg, 1, percent ); + dialog.progressText.setAttribute("value", percentMsg); + } // Update time remaining. - if ( rate && aMaxTotalProgress != "-1" ) + if ( rate && (aMaxTotalProgress > 0) ) { var rem = ( aMaxTotalProgress - aCurTotalProgress ) / rate; - rem = parseInt( rem + .5 ); - dialog.timeLeft.setAttribute("value", formatSeconds( rem )); + rem = parseInt( rem + .5 ); + dialog.timeLeft.setAttribute("value", formatSeconds( rem )); } else - dialog.timeLeft.setAttribute("value", getString( "unknownTime" )); + dialog.timeLeft.setAttribute("value", getString( "unknownTime" )); }, onLocationChange: function(aWebProgress, aRequest, aLocation) { diff --git a/mozilla/xpfe/components/xfer/resources/locale/en-US/downloadProgress.dtd b/mozilla/xpfe/components/xfer/resources/locale/en-US/downloadProgress.dtd index 85306a9e6a6..50b5d2da91b 100644 --- a/mozilla/xpfe/components/xfer/resources/locale/en-US/downloadProgress.dtd +++ b/mozilla/xpfe/components/xfer/resources/locale/en-US/downloadProgress.dtd @@ -29,7 +29,7 @@ - +