rem: let status = this._statusFormat;   let ([progress, progressUnits] = this._convertByteUnits(aCurTotalProgress), [total, totalUnits] = this._convertByteUnits(aMaxTotalProgress), transfer) { if (total <= 0) transfer = this._transferNoTotal; else if (progressUnits == totalUnits) transfer = this._transferSameUnits; else transfer = this._transferDiffUnits;  transfer = this._replaceInsert(transfer, 1, progress); transfer = this._replaceInsert(transfer, 2, progressUnits); transfer = this._replaceInsert(transfer, 3, total); transfer = this._replaceInsert(transfer, 4, totalUnits);   status = this._replaceInsert(status, 1, transfer);  download.setAttribute("status-internal", transfer); }   let ([rate, unit] = this._convertByteUnits(aDownload.speed)) {  status = this._replaceInsert(status, 2, rate);  status = this._replaceInsert(status, 3, unit); }   let (remain) { if ((aDownload.speed > 0) && (aMaxTotalProgress > 0)) { let seconds = Math.ceil((aMaxTotalProgress - aCurTotalProgress) / aDownload.speed);     let (diff = seconds - this.lastSeconds) { if (diff > 0 && diff <= 10) seconds = this.lastSeconds; else this.lastSeconds = seconds; }   if (seconds <= 3) remain = this._timeFewSeconds;  else if (seconds <= 60) remain = this._replaceInsert(this._timeSecondsLeft, 1, seconds); else remain = this._replaceInsert(this._timeMinutesLeft, 1, Math.ceil(seconds / 60)); } else { remain = this._timeUnknown; }   status = this._replaceInsert(status, 4, remain); }  download.setAttribute("status", status); 
add: updateStatus(download, aDownload); 
context:   onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress,                             aMaxSelfProgress, aCurTotalProgress,                             aMaxTotalProgress, aDownload)  {    var download = getDownload(aDownload.id);    if (!download) {      // d'oh - why this happens is complicated, let's just add it in      download = this._createDownloadItem(aDownload);      gDownloadsView.insertBefore(download, gDownloadsActiveTitle.nextSibling);    }    // any activity means we should have active downloads!    gDownloadsActiveTitle.hidden = false;    // Update this download's progressmeter    if (aDownload.percentComplete == -1) {      download.setAttribute("progressmode", "undetermined");    } else {      download.setAttribute("progressmode", "normal");      download.setAttribute("progress", aDownload.percentComplete);    }    // Dispatch ValueChange for a11y    var event = document.createEvent("Events");    event.initEvent("ValueChange", true, true);    document.getAnonymousElementByAttribute(download, "anonid", "progressmeter")            .dispatchEvent(event);    // Update the rest of the UI (bytes transferred, bytes total, download rate,    // time remaining).    let status = this._statusFormat;    // Update the bytes transferred and bytes total    let ([progress, progressUnits] = this._convertByteUnits(aCurTotalProgress),         [total, totalUnits] = this._convertByteUnits(aMaxTotalProgress),         transfer) {      if (total <= 0)        transfer = this._transferNoTotal;      else if (progressUnits == totalUnits)        transfer = this._transferSameUnits;      else        transfer = this._transferDiffUnits;      transfer = this._replaceInsert(transfer, 1, progress);      transfer = this._replaceInsert(transfer, 2, progressUnits);      transfer = this._replaceInsert(transfer, 3, total);      transfer = this._replaceInsert(transfer, 4, totalUnits);      // Insert 1 is the download progress      status = this._replaceInsert(status, 1, transfer);      download.setAttribute("status-internal", transfer);    }    // Update the download rate    let ([rate, unit] = this._convertByteUnits(aDownload.speed)) {      // Insert 2 is the download rate      status = this._replaceInsert(status, 2, rate);      // Insert 3 is the |unit|/sec      status = this._replaceInsert(status, 3, unit);    }    // Update time remaining.    let (remain) {      if ((aDownload.speed > 0) && (aMaxTotalProgress > 0)) {        let seconds = Math.ceil((aMaxTotalProgress - aCurTotalProgress) /                                aDownload.speed);        // Reuse the last seconds if the new one is longer by some small amount        // This avoids jittering seconds, e.g., 41 40 38 40 -> 41 40 38 38        // However, large changes are shown, e.g., 41 38 49 -> 41 38 49        let (diff = seconds - this.lastSeconds) {          if (diff > 0 && diff <= 10)            seconds = this.lastSeconds;          else            this.lastSeconds = seconds;        }        // Be friendly in the last few seconds        if (seconds <= 3)          remain = this._timeFewSeconds;        // Show 2 digit seconds starting at 60; otherwise use minutes        else if (seconds <= 60)          remain = this._replaceInsert(this._timeSecondsLeft, 1, seconds);        else          remain = this._replaceInsert(this._timeMinutesLeft, 1,                                       Math.ceil(seconds / 60));      } else {        remain = this._timeUnknown;      }      // Insert 4 is the time remaining      status = this._replaceInsert(status, 4, remain);    }    download.setAttribute("status", status);    // Update window title    onUpdateProgress();  },
meta: 10520	/local1/tlutelli/issta_data/temp/all_js/javascript/2007_temp/2007/10520/501718d8e30b7d693415403d4dd2edd4a6aa3935/DownloadProgressListener.js/clean/toolkit/mozapps/downloads/content/DownloadProgressListener.js