зеркало из https://github.com/mozilla/pjs.git
Bug 405720 - Strange message with download manager for file with unknown filesize. r=sdwilsh, a1.9=schrep, b-ff3=mconnor
This commit is contained in:
Родитель
853c513fdb
Коммит
8d20c2a10a
|
@ -95,6 +95,13 @@ chooseAppFilePickerTitle=Open With…
|
|||
downloadsTitle=%S%% of 1 file - Downloads
|
||||
downloadsTitleMultiple=%S%% of %S files - Downloads
|
||||
|
||||
# LOCALIZATION NOTE (downloadsTitleFiles, downloadsTitlePercent): Semi-colon list of
|
||||
# plural forms. See: http://developer.mozilla.org/en/docs/Localization_and_Plurals
|
||||
# #1 number of files; #2 overall download percent (only for downloadsTitlePercent)
|
||||
# examples: 2% of 1 file - Downloads; 22% of 11 files - Downloads
|
||||
downloadsTitleFiles=#1 file - Downloads;#1 files - Downloads
|
||||
downloadsTitlePercent=#2% of #1 file - Downloads;#2% of #1 files - Downloads
|
||||
|
||||
fileExecutableSecurityWarning="%S" is an executable file. Executable files may contain viruses or other malicious code that could harm your computer. Use caution when opening this file. Are you sure you want to launch "%S"?
|
||||
fileExecutableSecurityWarningTitle=Open Executable File?
|
||||
fileExecutableSecurityWarningDontAsk=Don't ask me this again
|
||||
|
|
|
@ -90,6 +90,8 @@ let gStr = {
|
|||
stateDirty: "stateDirty",
|
||||
yesterday: "yesterday",
|
||||
monthDate: "monthDate",
|
||||
downloadsTitleFiles: "downloadsTitleFiles",
|
||||
downloadsTitlePercent: "downloadsTitlePercent",
|
||||
fileExecutableSecurityWarningTitle: "fileExecutableSecurityWarningTitle",
|
||||
fileExecutableSecurityWarningDontAsk: "fileExecutableSecurityWarningDontAsk"
|
||||
};
|
||||
|
@ -329,47 +331,47 @@ var gLastComputedMean = -1;
|
|||
var gLastActiveDownloads = 0;
|
||||
function onUpdateProgress()
|
||||
{
|
||||
if (gDownloadManager.activeDownloads == 0) {
|
||||
let numActiveDownloads = gDownloadManager.activeDownloadCount;
|
||||
|
||||
// Use the default title and reset "last" values if there's no downloads
|
||||
if (numActiveDownloads == 0) {
|
||||
document.title = document.documentElement.getAttribute("statictitle");
|
||||
gLastComputedMean = -1;
|
||||
gLastActiveDownloads = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Establish the mean transfer speed and amount downloaded.
|
||||
var mean = 0;
|
||||
var base = 0;
|
||||
var numActiveDownloads = 0;
|
||||
var dls = gDownloadManager.activeDownloads;
|
||||
while (dls.hasMoreElements()) {
|
||||
let dl = dls.getNext();
|
||||
dl.QueryInterface(Ci.nsIDownload);
|
||||
let dl = dls.getNext().QueryInterface(Ci.nsIDownload);
|
||||
if (dl.percentComplete < 100 && dl.size > 0) {
|
||||
mean += dl.amountTransferred;
|
||||
base += dl.size;
|
||||
}
|
||||
numActiveDownloads++;
|
||||
}
|
||||
|
||||
// we're not downloading anything at the moment,
|
||||
// but we already downloaded something.
|
||||
if (base == 0) {
|
||||
mean = 100;
|
||||
} else {
|
||||
// Calculate the percent transferred, unless we don't have a total file size
|
||||
let title = gStr.downloadsTitlePercent;
|
||||
if (base == 0)
|
||||
title = gStr.downloadsTitleFiles;
|
||||
else
|
||||
mean = Math.floor((mean / base) * 100);
|
||||
}
|
||||
|
||||
// Update title of window
|
||||
if (mean != gLastComputedMean || gLastActiveDownloads != numActiveDownloads) {
|
||||
gLastComputedMean = mean;
|
||||
gLastActiveDownloads = numActiveDownloads;
|
||||
|
||||
let strings = document.getElementById("downloadStrings");
|
||||
if (numActiveDownloads > 1) {
|
||||
document.title = strings.getFormattedString("downloadsTitleMultiple",
|
||||
[mean, numActiveDownloads]);
|
||||
} else {
|
||||
document.title = strings.getFormattedString("downloadsTitle", [mean]);
|
||||
}
|
||||
// Get the correct plural form and insert number of downloads and percent
|
||||
title = PluralForm.get(numActiveDownloads, title);
|
||||
title = replaceInsert(title, 1, numActiveDownloads);
|
||||
title = replaceInsert(title, 2, mean);
|
||||
|
||||
document.title = title;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче