home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 August / PCpro_2005_08.ISO / files / firefox / ScrapBook.xpi / chrome / scrapbook.jar / content / about.js next >
Encoding:
JavaScript  |  2005-06-04  |  3.5 KB  |  129 lines

  1. /**************************************************
  2. // about.js
  3. // Implementation file for about.xul
  4. // 
  5. // Description: 
  6. // Author: Gomita
  7. // Contributors: 
  8. // 
  9. // Version: 
  10. // License: see LICENSE.txt
  11. **************************************************/
  12.  
  13.  
  14.  
  15. const CURRENT_VER = "0.15.4";
  16. const CURRENT_BID = "Build ID 20050604";
  17. const UPDATE_URL  = "http://amb.vis.ne.jp/mozilla/scrapbook/update.rdf?ver=" + CURRENT_VER;
  18.  
  19. var SBstring;
  20. var SBupdateImage;
  21. var SBupdateLabel;
  22.  
  23.  
  24.  
  25. function SB_initAbout()
  26. {
  27.     SBstring = document.getElementById("ScrapBookString");
  28.  
  29.     var SBversion = document.getElementById("ScrapBookAboutVersion");
  30.     SBversion.setAttribute("value", "Version " + CURRENT_VER + " (" + CURRENT_BID + ")");
  31.  
  32.     SBupdateImage = document.getElementById("ScrapBookUpdateImage");
  33.     SBupdateLabel = document.getElementById("ScrapBookUpdateLabel");
  34.     SBupdateImage.setAttribute("src", "chrome://scrapbook/skin/status_busy.gif");
  35.     SBupdateLabel.setAttribute("value", SBstring.getString("CHECKING"));
  36.     setTimeout(SB_setUpdateInfo, 500);
  37. }
  38.  
  39.  
  40. function SB_visit(aXUL)
  41. {
  42.     window.opener.SBcommon.loadURL(aXUL.getAttribute("href"), true);
  43. }
  44.  
  45.  
  46. function SB_mailto(aXUL)
  47. {
  48.     window.opener.SBcommon.loadURL('mailto:' + aXUL.getAttribute('href'), false);
  49. }
  50.  
  51.  
  52. function SB_secret()
  53. {
  54.     window.opener.SBstatus.httpBusy(5, "32% : product-mozilla-screen");
  55.     setTimeout(function() { window.opener.top.document.getElementById("statusbar-display").label = "Transferring data from www.mozilla.org..."; }, 0);
  56. }
  57.  
  58.  
  59. function SB_setUpdateInfo()
  60. {
  61.     var httpReq = new XMLHttpRequest();
  62.     httpReq.parent = this;
  63.     httpReq.open("GET", UPDATE_URL);
  64.  
  65.     httpReq.onerror = function(aEvent)
  66.     {
  67.         SBupdateLabel.setAttribute("value", SBstring.getString("CHECK_FAILURE"));
  68.         SB_removeUpdateImage();
  69.     };
  70.     httpReq.onload = function(aEvent)
  71.     {
  72.         try {
  73.             var LATEST_VER = httpReq.responseXML.getElementsByTagNameNS("http://www.mozilla.org/2004/em-rdf#", "version")[0].textContent;
  74.             var CV = SB_parseVersion(CURRENT_VER);
  75.             var LV = SB_parseVersion(LATEST_VER);
  76.             if ( CV > 0 && LV > 0 && LV > CV ) {
  77.                 SBupdateLabel.setAttribute("value", SBstring.getFormattedString("NEW_VERSION_AVAILABLE", [LATEST_VER]));
  78.                 SBupdateLabel.setAttribute("class", "link");
  79.                 SBupdateLabel.setAttribute("style", "font-weight:bold;");
  80.             } else {
  81.                 SBupdateLabel.setAttribute("value", SBstring.getString("NO_UPDATES_FOUND"));
  82.             }
  83.         }
  84.         catch(ex)
  85.         {
  86.             SBupdateLabel.setAttribute("value", SBstring.getString("CHECK_FAILURE"));
  87.         }
  88.         SB_removeUpdateImage();
  89.     };
  90.  
  91.     try {
  92.         httpReq.setRequestHeader("User-Agent", "Scrapbook Ver." + CURRENT_VER);
  93.         httpReq.overrideMimeType("application/xml");
  94.         httpReq.send(null);
  95.     } catch(err) {
  96.         httpReq.abort();
  97.         SBupdateLabel.setAttribute("value", SBstring.getString("CHECK_FAILURE"));
  98.         SB_removeUpdateImage();
  99.     }
  100. }
  101.  
  102.  
  103. function SB_parseVersion(verStr)
  104. {
  105.     var verArr = [];
  106.     if ( verStr.match(/^(\d+)\.(\d+)\.(\d+)$/) ) {
  107.         verArr[0] = parseInt(RegExp.$1); verArr[1] = parseInt(RegExp.$2); verArr[2] = parseInt(RegExp.$3);
  108.         return verArr[0] * 10000 + verArr[1] * 100 + verArr[2];
  109.     } else {
  110.         return 0;
  111.     }
  112. }
  113.  
  114.  
  115. function SB_removeUpdateImage()
  116. {
  117.     SBupdateImage.removeAttribute("src");
  118.     SBupdateImage.removeAttribute("style");
  119. }
  120.  
  121.  
  122. function SB_secret()
  123. {
  124.     window.opener.SBstatus.httpBusy(5, "32% : product-mozilla-screen.png");
  125.     setTimeout(function() { window.opener.top.window.status = "Transferring data from www.mozilla.org..."; }, 0);
  126. }
  127.  
  128.  
  129.