зеркало из https://github.com/mozilla/pjs.git
Bug 388506 - Use emdash for download status [time — progress (rate)]. Patch by Edward Lee <edilee@mozilla.com>. r=sdwilsh
This commit is contained in:
Родитель
83ad8cbb2c
Коммит
7a84662b0b
|
@ -20,19 +20,28 @@ dontQuitButtonMac=Don't Quit
|
|||
dontGoOfflineButton=Stay Online
|
||||
downloadsCompleteTitle=Downloads Complete
|
||||
downloadsCompleteMsg=All files have finished downloading.
|
||||
transferSameUnits=#1 of #3 #4
|
||||
transferDiffUnits=#1 #2 of #3 #4
|
||||
transferNoTotal=#1 #2
|
||||
remain=remain
|
||||
unknownTimeLeft=unknown time left
|
||||
statusFormat=#1 at #2 #3/sec; #4
|
||||
longTimeFormat=#1:#2:#3
|
||||
shortTimeFormat=#2:#3
|
||||
|
||||
# — is the "em dash" (long dash)
|
||||
# #1 transfer progress; #2 rate number; #3 rate unit; #4 time left
|
||||
# example: 4 minutes left — 1.1 of 11.1 GB (2.2 MB/sec)
|
||||
statusFormat=#4 — #1 (#2 #3/sec)
|
||||
bytes=bytes
|
||||
kilobyte=KB
|
||||
megabyte=MB
|
||||
gigabyte=GB
|
||||
|
||||
# #1 progress number; #2 progress unit; #3 total number; #4 total unit
|
||||
# examples: 1.1 of 333 MB; 11.1 MB of 3.3 GB; 111 KB
|
||||
transferSameUnits=#1 of #3 #4
|
||||
transferDiffUnits=#1 #2 of #3 #4
|
||||
transferNoTotal=#1 #2
|
||||
|
||||
# #1 minutes left (greater than 1)
|
||||
# example: 11 minutes left
|
||||
timeLeft=#1 minutes left
|
||||
timeLessMinute=Less than a minute
|
||||
timeUnknown=Unknown time left
|
||||
|
||||
fileDoesNotExistOpenTitle=Cannot Open %S
|
||||
fileDoesNotExistShowTitle=Cannot Show %S
|
||||
fileDoesNotExistError=%S does not exist. It may have been renamed, moved, or deleted since it was downloaded.
|
||||
|
|
|
@ -43,15 +43,14 @@ const interval = 500; // Update every 500 milliseconds.
|
|||
function DownloadProgressListener (aDocument, aStringBundle)
|
||||
{
|
||||
this.doc = aDocument;
|
||||
|
||||
|
||||
this._statusFormat = aStringBundle.getString("statusFormat");
|
||||
this._transferSameUnits = aStringBundle.getString("transferSameUnits");
|
||||
this._transferDiffUnits = aStringBundle.getString("transferDiffUnits");
|
||||
this._transferNoTotal = aStringBundle.getString("transferNoTotal");
|
||||
this._remain = aStringBundle.getString("remain");
|
||||
this._unknownTimeLeft = aStringBundle.getString("unknownTimeLeft");
|
||||
this._longTimeFormat = aStringBundle.getString("longTimeFormat");
|
||||
this._shortTimeFormat = aStringBundle.getString("shortTimeFormat");
|
||||
this._timeLeft = aStringBundle.getString("timeLeft");
|
||||
this._timeLessMinute = aStringBundle.getString("timeLessMinute");
|
||||
this._timeUnknown = aStringBundle.getString("timeUnknown");
|
||||
this._units = [aStringBundle.getString("bytes"),
|
||||
aStringBundle.getString("kilobyte"),
|
||||
aStringBundle.getString("megabyte"),
|
||||
|
@ -148,11 +147,16 @@ DownloadProgressListener.prototype =
|
|||
|
||||
// Update time remaining.
|
||||
let (remain) {
|
||||
if ((aDownload.speed > 0) && (aMaxTotalProgress > 0))
|
||||
remain = this._formatSeconds((aMaxTotalProgress - aCurTotalProgress) /
|
||||
aDownload.speed) + " " + this._remain;
|
||||
else
|
||||
remain = this._unknownTimeLeft;
|
||||
if ((aDownload.speed > 0) && (aMaxTotalProgress > 0)) {
|
||||
let minutes = Math.ceil((aMaxTotalProgress - aCurTotalProgress) /
|
||||
aDownload.speed / 60);
|
||||
if (minutes > 1)
|
||||
remain = this._replaceInsert(this._timeLeft, 1, minutes);
|
||||
else
|
||||
remain = this._timeLessMinute;
|
||||
} else {
|
||||
remain = this._timeUnknown;
|
||||
}
|
||||
|
||||
// Insert 4 is the time remaining
|
||||
status = this._replaceInsert(status, 4, remain);
|
||||
|
@ -206,32 +210,5 @@ DownloadProgressListener.prototype =
|
|||
aBytes = aBytes.toFixed((aBytes > 0) && (aBytes < 100) ? 1 : 0);
|
||||
|
||||
return [aBytes, this._units[unitIndex]];
|
||||
},
|
||||
|
||||
_formatSeconds: function (secs, doc)
|
||||
{
|
||||
// Round the number of seconds to remove fractions.
|
||||
secs = parseInt(secs + .5);
|
||||
var hours = parseInt(secs/3600);
|
||||
secs -= hours * 3600;
|
||||
|
||||
var mins = parseInt(secs/60);
|
||||
secs -= mins * 60;
|
||||
var result = hours ? this._longTimeFormat : this._shortTimeFormat;
|
||||
|
||||
if (hours < 10)
|
||||
hours = "0" + hours;
|
||||
if (mins < 10)
|
||||
mins = "0" + mins;
|
||||
if (secs < 10)
|
||||
secs = "0" + secs;
|
||||
|
||||
// Insert hours, minutes, and seconds into result string.
|
||||
result = this._replaceInsert(result, 1, hours);
|
||||
result = this._replaceInsert(result, 2, mins);
|
||||
result = this._replaceInsert(result, 3, secs);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче