diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /toolkit/mozapps/update/content/history.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/update/content/history.js')
-rw-r--r-- | toolkit/mozapps/update/content/history.js | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/toolkit/mozapps/update/content/history.js b/toolkit/mozapps/update/content/history.js new file mode 100644 index 0000000000..51de669af3 --- /dev/null +++ b/toolkit/mozapps/update/content/history.js @@ -0,0 +1,96 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +var gUpdateHistory = { + _view: null, + + /** + * Initialize the User Interface + */ + onLoad() { + this._view = document.getElementById("historyItems"); + + var um = Cc["@mozilla.org/updates/update-manager;1"].getService( + Ci.nsIUpdateManager + ); + var uc = um.getUpdateCount(); + if (uc) { + while (this._view.hasChildNodes()) { + this._view.firstChild.remove(); + } + + for (var i = 0; i < uc; ++i) { + var update = um.getUpdateAt(i); + + if (!update || !update.name) { + continue; + } + + // Don't display updates that are downloading since they don't have + // valid statusText for the UI (bug 485493). + if (!update.statusText) { + continue; + } + + var element = document.createXULElement("richlistitem"); + element.className = "update"; + + const topLine = document.createXULElement("hbox"); + const nameLabel = document.createXULElement("label"); + nameLabel.className = "update-name"; + document.l10n.setAttributes(nameLabel, "update-full-build-name", { + name: update.name, + buildID: update.buildID, + }); + topLine.appendChild(nameLabel); + + if (update.detailsURL) { + const detailsLink = document.createXULElement("label", { + is: "text-link", + }); + detailsLink.href = update.detailsURL; + document.l10n.setAttributes(detailsLink, "update-details"); + topLine.appendChild(detailsLink); + } + + const installedOnLabel = document.createXULElement("label"); + installedOnLabel.className = "update-installedOn-label"; + document.l10n.setAttributes(installedOnLabel, "update-installed-on", { + date: this._formatDate(update.installDate), + }); + + const statusLabel = document.createXULElement("label"); + statusLabel.className = "update-status-label"; + document.l10n.setAttributes(statusLabel, "update-status", { + status: update.statusText, + }); + + element.append(topLine, installedOnLabel, statusLabel); + this._view.appendChild(element); + } + } + var cancelbutton = document.getElementById("history").getButton("cancel"); + cancelbutton.focus(); + }, + + /** + * Formats a date into human readable form + * @param seconds + * A date in seconds since 1970 epoch + * @returns A human readable date string + */ + _formatDate(seconds) { + var date = new Date(seconds); + const dtOptions = { + year: "numeric", + month: "long", + day: "numeric", + hour: "numeric", + minute: "numeric", + second: "numeric", + }; + return date.toLocaleString(undefined, dtOptions); + }, +}; |