1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/update/content/history.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,75 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +const NS_XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; 1.10 + 1.11 +var gUpdateHistory = { 1.12 + _view: null, 1.13 + 1.14 + /** 1.15 + * Initialize the User Interface 1.16 + */ 1.17 + onLoad: function() { 1.18 + this._view = document.getElementById("historyItems"); 1.19 + 1.20 + var um = 1.21 + Components.classes["@mozilla.org/updates/update-manager;1"]. 1.22 + getService(Components.interfaces.nsIUpdateManager); 1.23 + var uc = um.updateCount; 1.24 + if (uc) { 1.25 + while (this._view.hasChildNodes()) 1.26 + this._view.removeChild(this._view.firstChild); 1.27 + 1.28 + var bundle = document.getElementById("updateBundle"); 1.29 + 1.30 + for (var i = 0; i < uc; ++i) { 1.31 + var update = um.getUpdateAt(i); 1.32 + if (!update || !update.name) 1.33 + continue; 1.34 + 1.35 + // Don't display updates that are downloading since they don't have 1.36 + // valid statusText for the UI (bug 485493). 1.37 + if (!update.statusText) 1.38 + continue; 1.39 + 1.40 + var element = document.createElementNS(NS_XUL, "update"); 1.41 + this._view.appendChild(element); 1.42 + element.name = bundle.getFormattedString("updateFullName", 1.43 + [update.name, update.buildID]); 1.44 + element.type = bundle.getString("updateType_" + update.type); 1.45 + element.installDate = this._formatDate(update.installDate); 1.46 + if (update.detailsURL) 1.47 + element.detailsURL = update.detailsURL; 1.48 + else 1.49 + element.hideDetailsURL = true; 1.50 + element.status = update.statusText; 1.51 + } 1.52 + } 1.53 + var cancelbutton = document.documentElement.getButton("cancel"); 1.54 + cancelbutton.focus(); 1.55 + }, 1.56 + 1.57 + /** 1.58 + * Formats a date into human readable form 1.59 + * @param seconds 1.60 + * A date in seconds since 1970 epoch 1.61 + * @returns A human readable date string 1.62 + */ 1.63 + _formatDate: function(seconds) { 1.64 + var sdf = 1.65 + Components.classes["@mozilla.org/intl/scriptabledateformat;1"]. 1.66 + getService(Components.interfaces.nsIScriptableDateFormat); 1.67 + var date = new Date(seconds); 1.68 + return sdf.FormatDateTime("", sdf.dateFormatLong, 1.69 + sdf.timeFormatSeconds, 1.70 + date.getFullYear(), 1.71 + date.getMonth() + 1, 1.72 + date.getDate(), 1.73 + date.getHours(), 1.74 + date.getMinutes(), 1.75 + date.getSeconds()); 1.76 + } 1.77 +}; 1.78 +