Bug 405884 - List date/time of download for each download shown. r=sdwilsh, b-ff3=mconnor

This commit is contained in:
edward.lee@engineering.uiuc.edu 2007-12-14 02:00:16 -08:00
parent 874a80563f
commit 69b017a4a8
6 changed files with 113 additions and 40 deletions

View File

@ -68,6 +68,11 @@ stateCanceled=Canceled
stateBlocked=Blocked by Parental Controls
stateDirty=Blocked: Download may contain a virus or spyware
# LOCALIZATION NOTE (yesterday): Displayed time for files finished yesterday
yesterday=Yesterday
# LOCALIZATION NOTE (monthDate): #1 month name; #2 date number; e.g., January 22
monthDate=#1 #2
fileDoesNotExistOpenTitle=Cannot Open %S
fileDoesNotExistShowTitle=Cannot Show %S
fileDoesNotExistError=%S does not exist. It may have been renamed, moved, or deleted since it was downloaded.

View File

@ -25,6 +25,7 @@
# Ben Goodger <ben@bengoodger.com> (v2.0)
# Blake Ross <blakeross@telocity.com>
# Shawn Wilsher <me@shawnwilsher.com> (v3.0)
# Edward Lee <edward.lee@engineering.uiuc.edu>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
@ -186,14 +187,15 @@
xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" class="name"/>
<xul:spacer flex="1"/>
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
crop="right" class="status"/>
</xul:vbox>
<xul:vbox pack="center">
<xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" flex="1" class="name"/>
<xul:label xbl:inherits="value=dateTime,tooltiptext=dateTime"
class="dateTime"/>
</xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=status"
crop="end" flex="1" class="status"/>
<xul:button class="open mini-button" tooltiptext="&cmd.open.label;"
command="cmd_open" ondblclick="event.stopPropagation();"/>
<xul:button class="info mini-button" tooltiptext="&cmd.info.label;"
@ -213,14 +215,15 @@
xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" class="name"/>
<xul:spacer flex="1"/>
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
crop="right" class="status"/>
</xul:vbox>
<xul:vbox pack="center">
<xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" flex="1" class="name"/>
<xul:label xbl:inherits="value=dateTime,tooltiptext=dateTime"
class="dateTime"/>
</xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=status"
crop="end" flex="1" class="status"/>
<xul:button class="retry mini-button" tooltiptext="&cmd.retry.label;"
command="cmd_retry" ondblclick="event.stopPropagation();"/>
<xul:button class="info mini-button" tooltiptext="&cmd.info.label;"
@ -240,14 +243,15 @@
xbl:inherits="src=image"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" class="name"/>
<xul:spacer flex="1"/>
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
crop="right" class="status"/>
</xul:vbox>
<xul:vbox pack="center">
<xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" flex="1" class="name"/>
<xul:label xbl:inherits="value=dateTime,tooltiptext=dateTime"
class="dateTime"/>
</xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=status"
crop="end" flex="1" class="status"/>
<xul:button class="retry mini-button" tooltiptext="&cmd.retry.label;"
command="cmd_retry" ondblclick="event.stopPropagation();"/>
<xul:button class="info mini-button" tooltiptext="&cmd.info.label;"
@ -266,14 +270,15 @@
<xul:image class="downloadTypeIcon blockedIcon"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" class="name"/>
<xul:spacer flex="1"/>
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
crop="right" class="status"/>
</xul:vbox>
<xul:vbox pack="center">
<xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" flex="1" class="name"/>
<xul:label xbl:inherits="value=dateTime,tooltiptext=dateTime"
class="dateTime"/>
</xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=status"
crop="end" flex="1" class="status"/>
<xul:button class="retry mini-button" tooltiptext="&cmd.retry.label;"
command="cmd_retry" ondblclick="event.stopPropagation();"/>
<xul:button class="info mini-button" tooltiptext="&cmd.info.label;"
@ -317,14 +322,15 @@
<xul:image class="downloadTypeIcon blockedIcon"/>
</xul:vbox>
<xul:vbox pack="start" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" class="name"/>
<xul:spacer flex="1"/>
<xul:label xbl:inherits="value=status,tooltiptext=status" flex="1"
crop="right" class="status"/>
</xul:vbox>
<xul:vbox pack="center">
<xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=target,tooltiptext=target"
crop="center" flex="1" class="name"/>
<xul:label xbl:inherits="value=dateTime,tooltiptext=dateTime"
class="dateTime"/>
</xul:hbox>
<xul:hbox align="center" flex="1">
<xul:label xbl:inherits="value=status,tooltiptext=status"
crop="end" flex="1" class="status"/>
<xul:button class="retry mini-button" tooltiptext="&cmd.retry.label;"
command="cmd_retry" ondblclick="event.stopPropagation();"/>
<xul:button class="info mini-button" tooltiptext="&cmd.info.label;"

View File

@ -92,6 +92,8 @@ let gStr = {
stateCanceled: "stateCanceled",
stateBlocked: "stateBlocked",
stateDirty: "stateDirty",
yesterday: "yesterday",
monthDate: "monthDate",
units: ["bytes", "kilobyte", "megabyte", "gigabyte"],
@ -139,6 +141,7 @@ function createDownloadItem(aID, aFile, aTarget, aURI, aState, aProgress,
dl.setAttribute("maxBytes", aMaxBytes);
dl.setAttribute("lastSeconds", Infinity);
updateTime(dl);
updateStatus(dl);
try {
@ -175,6 +178,9 @@ function downloadCompleted(aDownload)
dl.setAttribute("currBytes", aDownload.amountTransferred);
dl.setAttribute("maxBytes", aDownload.size);
// Show the finish time because we're done
updateTime(dl);
// If we are displaying search results, we do not want to add it to the list
// of completed downloads
if (!gSearching) {
@ -906,6 +912,50 @@ function updateStatus(aItem, aDownload) {
aItem.setAttribute("status", status);
}
/**
* Updates the time that gets shown for completed download items
*
* @param aItem
* The richlistitem representing a download in the UI
*/
function updateTime(aItem)
{
// Don't bother updating for things that aren't finished
if (aItem.inProgress)
return;
// Figure out when today begins
let now = new Date();
let today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
// Get the end time to display
let end = new Date(parseInt(aItem.getAttribute("endTime")));
// Figure out if the end time is from today, yesterday, this week, etc.
let dateTime;
if (end >= today) {
// Download finished after today started, show the time
let dts = Cc["@mozilla.org/intl/scriptabledateformat;1"].
getService(Ci.nsIScriptableDateFormat);
dateTime = dts.FormatTime("", dts.timeFormatNoSeconds,
end.getHours(), end.getMinutes(), 0);
} else if (today - end < (24 * 60 * 60 * 1000)) {
// Download finished after yesterday started, show yesterday
dateTime = gStr.yesterday;
} else if (today - end < (6 * 24 * 60 * 60 * 1000)) {
// Download finished after last week started, show day of week
dateTime = end.toLocaleFormat("%A");
} else {
// Download must have been from some time ago.. show month/day
let month = end.toLocaleFormat("%B");
let date = end.toLocaleFormat("%d");
dateTime = replaceInsert(gStr.monthDate, 1, month);
dateTime = replaceInsert(dateTime, 2, date);
}
aItem.setAttribute("dateTime", dateTime);
}
/**
* Converts a number of bytes to the appropriate unit that results in a
* number that needs fewer than 4 digits

View File

@ -24,6 +24,10 @@ richlistitem[type="download"] .name {
font-size: larger;
}
richlistitem[type="download"] .dateTime {
font-size: smaller;
}
#information {
-moz-appearance: none;
background-color: white;

View File

@ -18,6 +18,10 @@ richlistitem[type="download"] .name {
font-size: larger;
}
richlistitem[type="download"] .dateTime {
font-size: smaller;
}
richlistitem[type="download"] button {
-moz-appearance: none;
min-height: 16px;

View File

@ -24,6 +24,10 @@ richlistitem[type="download"] .name {
font-size: larger;
}
richlistitem[type="download"] .dateTime {
font-size: smaller;
}
#information {
-moz-appearance: none;
background-color: white;