home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / system / hddlife / HDDlifePro 3.1.155.msi / HDDlife.cab / gg / main.js < prev    next >
Encoding:
Text File  |  2007-08-31  |  11.0 KB  |  453 lines

  1. ∩╗┐var intReadDif=0;
  2. var str_arr;
  3.  
  4. var Rd=0;
  5. var Wt=0;
  6.  
  7. var UpDownR;
  8. var ChangeSpeedR=0;
  9. var CurrentRP=-135;
  10.  
  11. var UpDownW;
  12. var ChangeSpeedW=0;
  13. var CurrentWP=-135;
  14.  
  15. var Iteration;
  16. var Tempr;
  17. var tempr;
  18.  
  19. var schet;
  20. var progID="BS.hlGadgetCom"
  21. var Hdd;
  22. var ReadWrVC;
  23. var TypeVC;
  24. var TempretureVC;
  25. var GTypeVC;
  26. var UrgentVC;
  27. var UrgentV;
  28. var UrgentS;
  29.  
  30. var DiskVC;
  31. var UrgentTemprVC;
  32.  function RegAsmUninstall(root, progId, clsid) 
  33. {
  34.         var wshShell;
  35.         wshShell = new ActiveXObject("WScript.Shell"); 
  36.  
  37.         wshShell.RegDelete(root + "\\Software\\Classes\\", progId);
  38.         wshShell.RegDelete(root + "\\Software\\Classes\\CLSID\\" + clsid);
  39. function RegAsmInstall(root, progId, cls, clsid, assembly, version, codebase) 
  40. {
  41.         var wshShell;
  42.         wshShell = new ActiveXObject("WScript.Shell"); 
  43.         wshShell.RegWrite(root + "\\Software\\Classes\\", progId);
  44.         wshShell.RegWrite(root + "\\Software\\Classes\\" + progId + "\\", cls);
  45.         wshShell.RegWrite(root + "\\Software\\Classes\\" + progId + "\\CLSID\\", clsid);       
  46.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\", cls); 
  47.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\", "mscoree.dll");
  48.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\ThreadingModel", "Both");
  49.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\Class", cls);
  50.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\Assembly", assembly);
  51.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\RuntimeVersion", "v2.0.50727");
  52.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\CodeBase", codebase); 
  53.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\" + version + "\\Class", cls);
  54.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\" + version + "\\Assembly", assembly);
  55.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\" + version + "\\RuntimeVersion", "v2.0.50727");
  56.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\InprocServer32\\" + version + "\\CodeBase", codebase); 
  57.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\ProgId\\", progId); 
  58.         wshShell.RegWrite(root + "\\Software\\Classes\\CLSID\\" + clsid + "\\Implemented Categories\\{62C8FE65-4EBB-45E7-B440-6E39B2CDBF29}\\", "");
  59. }
  60. function RegAsmUninstall(root, progId, clsid) 
  61. {
  62.         var wshShell;
  63.         wshShell = new ActiveXObject("WScript.Shell"); 
  64.         wshShell.RegDelete(root + "\\Software\\Classes\\"+progId);
  65.         wshShell.RegDelete(root + "\\Software\\Classes\\CLSID\\" + clsid);
  66. }  
  67. function DeleteTempFiles( path)
  68. {
  69.  var FSO,f;
  70.  FSO = new ActiveXObject("Scripting.FileSystemObject");
  71.  f=FSO.GetFile(path);
  72.  f.Delete();
  73. }
  74.  
  75.  
  76. function GetInstallObject(path)
  77. {
  78.  return new ActiveXObject(path);
  79. }
  80. function InstallAll()
  81. {
  82.   var path;
  83.   var extrpath;
  84.   var extrpath1; 
  85.   var extrpath2;
  86.   var extrpath3;
  87.   var schet6=0; 
  88.   var Inst=null;
  89.   var Directory;
  90.   var guidIn="{AC960F61-67EB-4a8a-ADE2-3BC63852608D}";
  91.   var guidHdl="{099838F0-BC87-4787-9E59-8611F214EE97}"
  92.   var wshShell;
  93.   var status;
  94.   extrpath1=gadget.storage.extract("installer.exe"); 
  95.   extrpath=gadget.storage.extract("installer.exe.manifest");
  96.   wshShell = new ActiveXObject("WScript.Shell"); 
  97.   try
  98.   {  
  99.    status=wshShell.Run(extrpath1,1,true);
  100.  }
  101.   catch (e)
  102.   {
  103.    Alert("Can't install gadget"+e);
  104.   }
  105.   Hdd=GetInstallObject("BS.hlGadgetCom");
  106.   DeleteTempFiles(extrpath1);
  107.   DeleteTempFiles(extrpath);
  108. }
  109.  
  110. function LoadSettings()
  111. {
  112.   if (options.exists("Disk"))
  113.   {     
  114.    switch (parseInt(options.getValue("TemprIndex"))) 
  115.    {
  116.     case 1: TempretureVC = 120000; break;
  117.     case 2: TempretureVC = 300000; break;
  118.     case 3: TempretureVC = 600000; break;
  119.     case 4: TempretureVC = 1800000; break;
  120.     default: TempretureVC = 60000;
  121.    }
  122.    switch (parseInt(options.getValue("RwActivity"))) 
  123.    {
  124.     case 1: ReadWrVC = 6; break;
  125.     case 2: ReadWrVC = 10; break;
  126.     case 3: ReadWrVC = 20; break;
  127.     default: ReadWrVC = 3;
  128.    }
  129.    switch (parseInt(options.getValue("HealthIndex"))) 
  130.    {
  131.     case 1: UrgentVC = 240000; break;
  132.     case 2: UrgentVC = 480000; break;
  133.     case 3: UrgentVC = 960000; break;
  134.     case 4: UrgentVC = 1800000; break;
  135.     case 4: UrgentVC = 3600000; break;
  136.     default: UrgentVC = 120000;
  137.    } 
  138.    TypeVC=options.getValue("WarnIndex");
  139.    DiskVC=options.getValue("Disk");
  140.    GTypeVC=options.getValue("TempUnit")
  141.    UrgentTemprVC=options.getValue("UrgentTempret");
  142.   }
  143. }
  144. function Gadget_showOptions()
  145. {
  146.  var str;
  147.  var inco;
  148.  var income;
  149.  if (options.exists("Disk"))
  150.   str=options.getValue("Disk")+"-"+options.getValue("RwActivity")+"-"+options.getValue("TemprIndex")+"-"+options.getValue("WarnIndex")+"-"+options.getValue("HealthIndex")+"-"+options.getValue("UrgentTempret")+"-"+options.getValue("TempUnit");
  151.  else
  152.   str="";
  153.  inco=Hdd.GetAllChoice(str)
  154.  if (inco.length>5)
  155.  {
  156.   income=inco.split('-');
  157.   options.putValue("Disk",income[0]);
  158.   options.putValue("RwActivity",income[1]);
  159.   options.putValue("TemprIndex",income[2]);
  160.   options.putValue("WarnIndex",income[3]);
  161.   options.putValue("HealthIndex",income[4]);
  162.   options.putValue("UrgentTempret",income[5]);
  163.   options.putValue("TempUnit",income[6]);
  164.   view_onOpen();
  165.  }
  166. }
  167. function _onOptionChanged()
  168. {
  169.  
  170. }
  171. function view_onOpen()
  172. {
  173.  
  174.   _onOptionChanged();  // to initialize any preexisting options  
  175.   view.onoptionchanged = _onOptionChanged;
  176.  try 
  177.  { 
  178.   Hdd=GetInstallObject("BS.hlGadgetCom");
  179.  }
  180.  catch(e)
  181.  {
  182.  if (Hdd==null)
  183.   gadget.debug.trace("Null");
  184.  else
  185.   gadget.debug.trace("NOT NULL"); 
  186.  }
  187.   if (Hdd==null)
  188.    {
  189.     InstallAll();
  190.     Hdd=GetInstallObject("BS.hlGadgetCom");     
  191.    }
  192.     Hdd.Init();
  193.     plugin.onShowOptionsDlg = Gadget_showOptions;  
  194.     LoadSettings();
  195.     tempreture.innerText="";
  196.     vpath.innerText="";
  197.     if (ReadWrVC!=null)
  198.      Iteration=ReadWrVC;
  199.     else
  200.      Iteration=ReadWrVC=3;
  201.     if (TempretureVC==null)
  202.      TempretureVC=60000;
  203.     if (GTypeVC==null)
  204.      GTypeVC=0; 
  205.     if (UrgentVC==null)
  206.       UrgentVC=120000;     
  207.     if (DiskVC!=null)
  208.       {
  209.         if (DiskVC.length<5)
  210.          vpath.innerText=DiskVC; 
  211.         else
  212.          DiskVC="All disks";          
  213.       }
  214.     else
  215.      {
  216.       DiskVC="All disks";
  217.       vpath.innerText="All disks";
  218.      }
  219.     if (TypeVC==null)
  220.      TypeVC=0;
  221.     if (UrgentTemprVC==null)
  222.       UrgentTemprVC=55;
  223.  
  224.     Urgent.X=98;
  225.     Urgent.Y=5; 
  226.  ReadArr.rotation=-135;
  227.  writeArr.rotation=-135;
  228.  if (DiskVC!="All disks")
  229.  {
  230.  
  231.    ReadTempreture();
  232.    AnimateGadget();
  233.    ReadUrgent();
  234.    vpath.innerText=DiskVC;
  235.  }
  236.  else
  237.  {
  238.     vpath.innerText="";
  239.     Urgent.X=41;
  240.     Urgent.Y=45; 
  241.     Center.src="img/0.png"; 
  242.     ReadUrgentAll();
  243.     AnimateGadgetAll();
  244.  }
  245. }
  246. function ReadUrgentAll()
  247. {
  248.  clearTimeout(UrgentS);
  249.  UrgentV=Hdd.GetDiskHealth();
  250.  if (UrgentV.length<10)
  251.  {
  252.   Urgent.src="img/"+UrgentV+"48.png"; 
  253.   if (UrgentV=="red")
  254.    Hdd.Alert(TypeVC,"default.wav");
  255.  }
  256.  else
  257.   Urgent.src="img/unknow48.png";
  258.  UrgentS = setTimeout("ReadUrgentAll()",UrgentVC); 
  259. }
  260.  
  261. function ReadUrgent()
  262. {
  263.  clearTimeout(UrgentS);
  264.  UrgentV=Hdd.GetCurrDiskHealth(DiskVC);
  265.  if (UrgentV.length<8)
  266.  {
  267.   Urgent.src="img/"+UrgentV+".png"; 
  268.   if (UrgentV=="red")
  269.    Hdd.Alert(TypeVC,"default.wav");
  270.  }
  271.  else
  272.   Urgent.src="img/unknow.png";
  273.  UrgentS = setTimeout("ReadUrgent()",UrgentVC); 
  274. }
  275. function ReadTempreture()
  276. {
  277.  var CenterVa;
  278.  var tempVal;
  279.  CenterVa=Hdd.GetPercentFull(DiskVC);
  280.  CenterVa=100-parseInt(CenterVa);
  281.  clearTimeout(tempr);
  282.  tempVal=Hdd.GetTempretBypart(DiskVC);
  283.  Tempr=tempVal.split('-');
  284.  if (CenterVa>=10)
  285.   {
  286.    Center.src="img/"+CenterVa+".png";
  287.   } 
  288.  else
  289.    {
  290.    Center.src="img/0.png"; 
  291.    }
  292.   if ((tempVal.length<13))
  293.    {
  294.     if (parseInt(Tempr[GTypeVC])>parseInt(UrgentTemprVC))
  295.     {
  296.       tempreture.color="#FF0000";
  297.       Hdd.Alert(TypeVC,"default.wav");  
  298.      if (parseInt(GTypeVC)==0)
  299.       Tempr[GTypeVC]=Tempr[GTypeVC]+"\xB0C";
  300.      else
  301.       Tempr[GTypeVC]=Tempr[GTypeVC]+" F";
  302.      tempreture.innerText=Tempr[GTypeVC];
  303.     }
  304.     else
  305.     {
  306.      tempreture.color="#00FF00"; 
  307.      if (parseInt(GTypeVC)==0)
  308.       Tempr[GTypeVC]=Tempr[GTypeVC]+"\xB0C";
  309.      else
  310.       Tempr[GTypeVC]=Tempr[GTypeVC]+" F";
  311.      tempreture.innerText=Tempr[GTypeVC];
  312.     }
  313.    }
  314.   else
  315.     tempreture.innerText=""; 
  316.  tempr = setTimeout("ReadTempreture()",TempretureVC);
  317. }
  318. function AnimateGadgetAll()
  319. {
  320.   clearTimeout(schet);
  321.   ReadArr.rotation=CurrentRP;
  322.   writeArr.rotation=CurrentWP;
  323.   if (Rd==100)
  324.    ReadPe.innerText="R 100%";
  325.   else
  326.     if (Rd<10)
  327.      ReadPe.innerText="R  "+Rd+"%";
  328.     else
  329.      ReadPe.innerText="R  "+Rd+"%";
  330.  
  331.  
  332.   if (Wt==100)
  333.    WritePe.innerText="W 100%";
  334.   else
  335.     if (Wt<10)
  336.      WritePe.innerText="W  "+Wt+"%";
  337.     else
  338.      WritePe.innerText="W  "+Wt+"%";
  339.  
  340.   if (Iteration==0)
  341.    {
  342.     str_arr=Hdd.GetAllPartBusy().split(',');
  343.     Rd=str_arr[0];
  344.     Wt=str_arr[1];
  345.     Iteration=ReadWrVC;
  346.    }
  347.   CalculateR ();
  348.   CalculateW ();
  349.   Iteration=Iteration-1;    
  350.   schet = setTimeout("AnimateGadgetAll()", 120);
  351. }
  352. function AnimateGadget()
  353. {
  354.   clearTimeout(schet);
  355.   ReadArr.rotation=CurrentRP;
  356.   writeArr.rotation=CurrentWP;
  357.  if (Rd==100)
  358.    ReadPe.innerText="R 100%";
  359.   else
  360.     if (Rd<10)
  361.      ReadPe.innerText="R   "+Rd+"%";
  362.     else
  363.      ReadPe.innerText="R  "+Rd+"%";
  364.   
  365.  
  366.   if (Wt==100)
  367.    WritePe.innerText="W 100%";
  368.   else
  369.     if (Wt<10)
  370.      WritePe.innerText="W   "+Wt+"%";
  371.     else
  372.      WritePe.innerText="W  "+Wt+"%";
  373.  
  374.  
  375.   if (Iteration==0)
  376.    {
  377.     str_arr=Hdd.GetPartitionBusy(DiskVC).split(',');
  378.     Rd=str_arr[0];
  379.     Wt=str_arr[1];
  380.     Iteration=ReadWrVC;
  381.    }
  382.   CalculateR ();
  383.   CalculateW ();
  384.   Iteration=Iteration-1;    
  385.   schet = setTimeout("AnimateGadget()", 100);
  386. }
  387. function CalculateR ()
  388. {
  389.  if (Math.abs(CurrentRP-(Rd*2.7-135))>10)
  390.  {
  391.  if ((Rd*2.7-135)>CurrentRP)
  392.   {
  393.    CurrentRP=CurrentRP+10;     
  394.    UpDownR=1;
  395.   }
  396.  else
  397.   {
  398.    CurrentRP=CurrentRP-10;
  399.    UpDownR=-1;
  400.   }
  401.  
  402.   if (UpDownR==1)
  403.    {
  404.     if (CurrentRP>135)
  405.       {
  406.         CurrentRP=135;
  407.       }  
  408.    }
  409.   else
  410.    {
  411.     if (CurrentRP<-135)
  412.       {
  413.         CurrentRP=-135;
  414.       }
  415.    }
  416.  }
  417.  else
  418.   CurrentRP=  Math.round(Rd*2.7-135);
  419. }
  420. function CalculateW ()
  421. {
  422.   if (Math.abs(CurrentWP-(Wt*2.7-135))>10)
  423.  {
  424.  if ((Wt*2.7-135)>CurrentWP)
  425.   {
  426.    CurrentWP=CurrentWP+10;     
  427.    UpDownW=1;
  428.   }
  429.  else
  430.   {
  431.    CurrentWP=CurrentWP-10;
  432.    UpDownW=-1;
  433.   }
  434.  
  435.   if (UpDownW==1)
  436.    {
  437.     if (CurrentWP>135)
  438.       {
  439.         CurrentWP=135;
  440.       }  
  441.    }
  442.   else
  443.    {
  444.     if (CurrentWP<-135)
  445.       {
  446.         CurrentWP=-135;
  447.       }
  448.    }
  449.  }
  450.  else
  451.   CurrentWP=  Math.round(Wt*2.7-135);
  452. }