home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 May / PCWorld_2003-05_cd.bin / Komunik / phoenix / chrome / browser.jar / content / browser / downloads / downloadProperties.js < prev    next >
Text File  |  2002-11-09  |  2KB  |  43 lines

  1. function Startup()
  2. {
  3.   const NC_NS = "http://home.netscape.com/NC-rdf#";
  4.   const rdfSvcContractID = "@mozilla.org/rdf/rdf-service;1";
  5.   const rdfSvcIID = Components.interfaces.nsIRDFService;
  6.   var rdfService = Components.classes[rdfSvcContractID].getService(rdfSvcIID);
  7.  
  8.   const dlmgrContractID = "@mozilla.org/download-manager;1";
  9.   const dlmgrIID = Components.interfaces.nsIDownloadManager;
  10.   var downloadMgr = Components.classes[dlmgrContractID].getService(dlmgrIID);
  11.   var ds = downloadMgr.datasource;
  12.   
  13.   const dateTimeContractID = "@mozilla.org/intl/scriptabledateformat;1";
  14.   const dateTimeIID = Components.interfaces.nsIScriptableDateFormat;
  15.   var dateTimeService = Components.classes[dateTimeContractID].getService(dateTimeIID);  
  16.  
  17.   var resource = rdfService.GetUnicodeResource(window.arguments[0]);
  18.   var dateStartedRes = rdfService.GetResource(NC_NS + "DateStarted");
  19.   var dateEndedRes = rdfService.GetResource(NC_NS + "DateEnded");
  20.   var sourceRes = rdfService.GetResource(NC_NS + "URL");
  21.  
  22.   var dateStartedField = document.getElementById("dateStarted");
  23.   var dateEndedField = document.getElementById("dateEnded");
  24.   var pathField = document.getElementById("path");
  25.   var sourceField = document.getElementById("source");
  26.  
  27.   var dateStarted = ds.GetTarget(resource, dateStartedRes, true).QueryInterface(Components.interfaces.nsIRDFDate).Value;
  28.   var dateEnded = ds.GetTarget(resource, dateEndedRes, true).QueryInterface(Components.interfaces.nsIRDFDate).Value;
  29.   dateStarted = new Date(dateStarted/1000);
  30.   dateStarted = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateStarted.getFullYear(), dateStarted.getMonth()+1, dateStarted.getDate(), dateStarted.getHours(), dateStarted.getMinutes(), dateStarted.getSeconds());
  31.   dateEnded = new Date(dateEnded/1000);
  32.   dateEnded = dateTimeService.FormatDateTime("", dateTimeService.dateFormatShort, dateTimeService.timeFormatSeconds, dateEnded.getFullYear(), dateEnded.getMonth()+1, dateEnded.getDate(), dateEnded.getHours(), dateEnded.getMinutes(), dateEnded.getSeconds());
  33.   
  34.   var source = ds.GetTarget(resource, sourceRes, true).QueryInterface(Components.interfaces.nsIRDFResource).Value;
  35.  
  36.   dateStartedField.setAttribute("value", dateStarted);
  37.   dateEndedField.setAttribute("value", dateEnded);
  38.   pathField.value = window.arguments[0];
  39.   sourceField.value = source;
  40.   
  41.   document.documentElement.getButton("accept").focus();
  42. }
  43.