toolkit/mozapps/update/content/history.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
michael@0 7
michael@0 8 var gUpdateHistory = {
michael@0 9 _view: null,
michael@0 10
michael@0 11 /**
michael@0 12 * Initialize the User Interface
michael@0 13 */
michael@0 14 onLoad: function() {
michael@0 15 this._view = document.getElementById("historyItems");
michael@0 16
michael@0 17 var um =
michael@0 18 Components.classes["@mozilla.org/updates/update-manager;1"].
michael@0 19 getService(Components.interfaces.nsIUpdateManager);
michael@0 20 var uc = um.updateCount;
michael@0 21 if (uc) {
michael@0 22 while (this._view.hasChildNodes())
michael@0 23 this._view.removeChild(this._view.firstChild);
michael@0 24
michael@0 25 var bundle = document.getElementById("updateBundle");
michael@0 26
michael@0 27 for (var i = 0; i < uc; ++i) {
michael@0 28 var update = um.getUpdateAt(i);
michael@0 29 if (!update || !update.name)
michael@0 30 continue;
michael@0 31
michael@0 32 // Don't display updates that are downloading since they don't have
michael@0 33 // valid statusText for the UI (bug 485493).
michael@0 34 if (!update.statusText)
michael@0 35 continue;
michael@0 36
michael@0 37 var element = document.createElementNS(NS_XUL, "update");
michael@0 38 this._view.appendChild(element);
michael@0 39 element.name = bundle.getFormattedString("updateFullName",
michael@0 40 [update.name, update.buildID]);
michael@0 41 element.type = bundle.getString("updateType_" + update.type);
michael@0 42 element.installDate = this._formatDate(update.installDate);
michael@0 43 if (update.detailsURL)
michael@0 44 element.detailsURL = update.detailsURL;
michael@0 45 else
michael@0 46 element.hideDetailsURL = true;
michael@0 47 element.status = update.statusText;
michael@0 48 }
michael@0 49 }
michael@0 50 var cancelbutton = document.documentElement.getButton("cancel");
michael@0 51 cancelbutton.focus();
michael@0 52 },
michael@0 53
michael@0 54 /**
michael@0 55 * Formats a date into human readable form
michael@0 56 * @param seconds
michael@0 57 * A date in seconds since 1970 epoch
michael@0 58 * @returns A human readable date string
michael@0 59 */
michael@0 60 _formatDate: function(seconds) {
michael@0 61 var sdf =
michael@0 62 Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
michael@0 63 getService(Components.interfaces.nsIScriptableDateFormat);
michael@0 64 var date = new Date(seconds);
michael@0 65 return sdf.FormatDateTime("", sdf.dateFormatLong,
michael@0 66 sdf.timeFormatSeconds,
michael@0 67 date.getFullYear(),
michael@0 68 date.getMonth() + 1,
michael@0 69 date.getDate(),
michael@0 70 date.getHours(),
michael@0 71 date.getMinutes(),
michael@0 72 date.getSeconds());
michael@0 73 }
michael@0 74 };
michael@0 75

mercurial