toolkit/mozapps/update/content/history.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial