mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1108310 - Remove deprecated for-each-in loop and let blocks and fix strict mode warnings in webapprt/content/downloads/downloads. r=Unfocused
This commit is contained in:
parent
9fe0ffc6db
commit
59d247b8c0
@ -2,6 +2,8 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { interfaces: Ci, utils: Cu, classes: Cc } = Components;
|
||||
|
||||
const nsIDM = Ci.nsIDownloadManager;
|
||||
@ -354,29 +356,29 @@ DownloadItem.prototype = {
|
||||
case nsIDM.DOWNLOAD_BLOCKED_PARENTAL:
|
||||
case nsIDM.DOWNLOAD_BLOCKED_POLICY:
|
||||
case nsIDM.DOWNLOAD_DIRTY:
|
||||
let (stateSize = {}) {
|
||||
stateSize[nsIDM.DOWNLOAD_FINISHED] = () => {
|
||||
// Display the file size, but show "Unknown" for negative sizes.
|
||||
let sizeText = gStr.doneSizeUnknown;
|
||||
if (this.maxBytes >= 0) {
|
||||
let [size, unit] = DownloadUtils.convertByteUnits(this.maxBytes);
|
||||
sizeText = gStr.doneSize.replace("#1", size);
|
||||
sizeText = sizeText.replace("#2", unit);
|
||||
}
|
||||
return sizeText;
|
||||
};
|
||||
stateSize[nsIDM.DOWNLOAD_FAILED] = () => gStr.stateFailed;
|
||||
stateSize[nsIDM.DOWNLOAD_CANCELED] = () => gStr.stateCanceled;
|
||||
stateSize[nsIDM.DOWNLOAD_BLOCKED_PARENTAL] = () => gStr.stateBlocked;
|
||||
stateSize[nsIDM.DOWNLOAD_BLOCKED_POLICY] = () => gStr.stateBlockedPolicy;
|
||||
stateSize[nsIDM.DOWNLOAD_DIRTY] = () => gStr.stateDirty;
|
||||
let stateSize = {};
|
||||
stateSize[nsIDM.DOWNLOAD_FINISHED] = () => {
|
||||
// Display the file size, but show "Unknown" for negative sizes.
|
||||
let sizeText = gStr.doneSizeUnknown;
|
||||
if (this.maxBytes >= 0) {
|
||||
let [size, unit] = DownloadUtils.convertByteUnits(this.maxBytes);
|
||||
sizeText = gStr.doneSize.replace("#1", size);
|
||||
sizeText = sizeText.replace("#2", unit);
|
||||
}
|
||||
return sizeText;
|
||||
};
|
||||
stateSize[nsIDM.DOWNLOAD_FAILED] = () => gStr.stateFailed;
|
||||
stateSize[nsIDM.DOWNLOAD_CANCELED] = () => gStr.stateCanceled;
|
||||
stateSize[nsIDM.DOWNLOAD_BLOCKED_PARENTAL] = () => gStr.stateBlocked;
|
||||
stateSize[nsIDM.DOWNLOAD_BLOCKED_POLICY] = () => gStr.stateBlockedPolicy;
|
||||
stateSize[nsIDM.DOWNLOAD_DIRTY] = () => gStr.stateDirty;
|
||||
|
||||
// Insert 1 is the download size or download state.
|
||||
status = gStr.doneStatus.replace("#1", stateSize[this.state]());
|
||||
}
|
||||
// Insert 1 is the download size or download state.
|
||||
status = gStr.doneStatus.replace("#1", stateSize[this.state]());
|
||||
|
||||
let [displayHost, fullHost] =
|
||||
DownloadUtils.getURIHost(this.referrer || this.uri);
|
||||
|
||||
// Insert 2 is the eTLD + 1 or other variations of the host.
|
||||
status = status.replace("#2", displayHost);
|
||||
// Set the tooltip to be the full host.
|
||||
@ -721,12 +723,11 @@ let gDownloadList = {
|
||||
}
|
||||
|
||||
// Clear the list before adding items by replacing with a shallow copy.
|
||||
let (empty = this.downloadView.cloneNode(false)) {
|
||||
this.downloadView.parentNode.replaceChild(empty, this.downloadView);
|
||||
this.downloadView = empty;
|
||||
}
|
||||
let empty = this.downloadView.cloneNode(false);
|
||||
this.downloadView.parentNode.replaceChild(empty, this.downloadView);
|
||||
this.downloadView = empty;
|
||||
|
||||
for each (let downloadItem in this.downloadItems) {
|
||||
for (let downloadItem of this.downloadItems) {
|
||||
if (downloadItem.inProgress ||
|
||||
downloadItem.matchesSearch(this.searchTerms, this.searchAttributes)) {
|
||||
this.downloadView.appendChild(downloadItem.element);
|
||||
@ -772,7 +773,7 @@ let gDownloadList = {
|
||||
let button = document.getElementById("clearListButton");
|
||||
|
||||
// The button is enabled if we have items in the list that we can clean up.
|
||||
for each (let downloadItem in this.downloadItems) {
|
||||
for (let downloadItem of this.downloadItems) {
|
||||
if (!downloadItem.inProgress &&
|
||||
downloadItem.matchesSearch(this.searchTerms, this.searchAttributes)) {
|
||||
button.disabled = false;
|
||||
@ -876,7 +877,7 @@ let gDownloadList = {
|
||||
let items = Array.from(this.downloadView.selectedItems);
|
||||
|
||||
// Do the command for each download item.
|
||||
for each (let item in items) {
|
||||
for (let item of items) {
|
||||
this.performCommand(aCmd, item);
|
||||
}
|
||||
|
||||
@ -982,7 +983,7 @@ let gDownloadList = {
|
||||
let totalSize = 0;
|
||||
let totalTransferred = 0;
|
||||
|
||||
for each (let downloadItem in this.downloadItems) {
|
||||
for (let downloadItem of this.downloadItems) {
|
||||
if (!downloadItem.inProgress) {
|
||||
continue;
|
||||
}
|
||||
@ -1109,15 +1110,14 @@ let gDownloadList = {
|
||||
|
||||
function Startup() {
|
||||
// Convert strings to those in the string bundle.
|
||||
let (sb = document.getElementById("downloadStrings")) {
|
||||
let strings = ["paused", "cannotPause", "doneStatus", "doneSize",
|
||||
"doneSizeUnknown", "stateFailed", "stateCanceled",
|
||||
"stateBlocked", "stateBlockedPolicy", "stateDirty",
|
||||
"downloadsTitleFiles", "downloadsTitlePercent",];
|
||||
let sb = document.getElementById("downloadStrings");
|
||||
let strings = ["paused", "cannotPause", "doneStatus", "doneSize",
|
||||
"doneSizeUnknown", "stateFailed", "stateCanceled",
|
||||
"stateBlocked", "stateBlockedPolicy", "stateDirty",
|
||||
"downloadsTitleFiles", "downloadsTitlePercent",];
|
||||
|
||||
for each (let name in strings) {
|
||||
gStr[name] = sb.getString(name);
|
||||
}
|
||||
for (let name of strings) {
|
||||
gStr[name] = sb.getString(name);
|
||||
}
|
||||
|
||||
gDownloadList.init();
|
||||
|
Loading…
Reference in New Issue
Block a user