home *** CD-ROM | disk | FTP | other *** search
/ PC User 2004 November / PCU1104CD1.iso / software / security / files / norton.exe / Setup / ISCommon / APP / ALEScan.exe / HTML / WIZ-ALES.JS < prev    next >
Encoding:
Text File  |  2003-09-06  |  14.4 KB  |  626 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
  4. //
  5. // NAME:    wiz-ALEs.js (Javascript file for wiz-ALEs.HTM)
  6. //
  7. // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////////////////
  10.  
  11. IE4 = document.all;
  12. var g_LocationAwarenessOffText;
  13.  
  14. ///////////////////////////////////////////////////////
  15. /////////new alert params /////////////////////////////
  16. ///////////////////////////////////////////////////////
  17. //icon:
  18. // 0 = no icon
  19. // 1 = error
  20. // 2 = question
  21. // 3 = alert
  22. // 4 = info
  23. //
  24. //buts:
  25. // 0 = ok
  26. // 1 = ok, cancel
  27. // 2 = abort, retry, cancel
  28. // 3 = yes, no, cancel
  29. // 4 = yes, no
  30. // 5 = retry, cancel
  31. //
  32. //defbut
  33. // 0 = first
  34. // 1 = second
  35. // 2 = third
  36. //
  37. //mods:
  38. // 0 = app modal
  39. // 1 = system modal
  40. function newAlert(mess, title, icon, buts, defbut, mods)
  41. {
  42.     if(IE4)
  43.         makeMsgBox(title, mess, icon, buts, defbut, mods)
  44.     else
  45.         alert(mess);
  46. }
  47.  
  48. function OnLoad()
  49. {
  50.     g_LocationAwarenessOffText = LocationAwarenessIsOffText.innerText;
  51.     FoundList.SetOnCheckedChangedCallback(foundList_OnCheckStateChanged);
  52. }
  53.  
  54. function driveList_OnSpace(nRow)
  55. {
  56.     //
  57.     // Swap the state of the check box for this item
  58.     //
  59.     var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  60.     CheckBox.checked = !CheckBox.checked;
  61. }
  62.  
  63. function initDriveList()
  64. {
  65.     driveList.OnSpace = driveList_OnSpace;
  66.     driveList.DeleteAllRows();
  67.     driveList.SetColumnCount(2);
  68.     driveList.SetColumnWidth(0, "50px");
  69.     driveList.SetColumnWidth(1, "83px");
  70.  
  71.     var szDrives = NetScan.DriveList;
  72.  
  73.     for(var i = 0; i < szDrives.length; ++i)
  74.     {
  75.         var pRow = driveList.InsertRow(-1);
  76.         driveList.SetCellTextPtr(pRow, 0, "<input type=\"checkbox\" checked>");
  77.         driveList.SetCellTextPtr(pRow, 1, szDrives.substring(i, i+1) + ":\\");
  78.     }
  79.  
  80.     driveList.SetOnClickHandler(CheckBox_OnClick);
  81. }
  82.  
  83. function CheckBox_OnClick()
  84. {
  85.     // Get a count of checked items... if zero are checked, disable the next btn
  86.     var nCount = driveList.GetRowCount();
  87.  
  88.     var nChecked = 0;
  89.     for(var nRow = 0; nRow < nCount; ++nRow)
  90.     {
  91.         var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  92.         if(CheckBox.checked)
  93.         {
  94.             nChecked++;
  95.         }
  96.     }
  97.  
  98.     if(nChecked == 0)
  99.         NextBtn.disabled = true;
  100.     else
  101.         NextBtn.disabled = false;
  102. }
  103.  
  104. function saveDriveList()
  105. {
  106.     var nCount = driveList.GetRowCount();
  107.  
  108.     szDrives = "";
  109.     for(var nRow = 0; nRow < nCount; ++nRow)
  110.     {
  111.         var CheckBox = driveList.GetCellPtr(nRow, 0).children[0];
  112.         if(CheckBox.checked)
  113.         {
  114.             szDrives += driveList.GetCellPtr(nRow, 1).innerText.substring(0, 1);
  115.         }
  116.     }
  117.  
  118.     NetScan.DriveList = szDrives;
  119. }
  120.  
  121. function NextBtn_OnClick()
  122. {
  123. // Find the active page, back to front (if we are not disabled)
  124.     if(PageD.style.display == "")
  125.     {
  126.         ConfigInfo.AleScanRun = true;
  127.         returnValue = "";
  128.         AleWiz_Body.style.cursor = "wait";
  129.         BackBtn.disabled = true;
  130.         FinishBtn.disabled = true;
  131.         Cancel.disabled = true;
  132.         locationSelectAll.disabled = true;
  133.         locationSelectNone.disabled = true;
  134.         locationList.Enabled(false);
  135.         locationList.LTable.style.cursor = "wait";
  136.         EnableCloseButton(false);
  137.  
  138.         // save the items in the list
  139.         var arrayLocations = UILocation_GetSelectedLocations();
  140.  
  141.         for(var i = 0; i < arrayLocations.length; i++)
  142.         {
  143.             var checkbox = locationList.GetCellPtr(i,0);
  144.             checkbox.disabled = true;
  145.             FoundList.AddALEScanLocation(arrayLocations[i]);
  146.         }
  147.  
  148.         FoundList.MergeItemsAsync(OnMergeItemsComplete);
  149.     }
  150.  
  151.     if(PageC.style.display == "")
  152.     {
  153.         PageC.style.display = "none";
  154.         PageD.style.display = "";
  155.  
  156.         //set location awareness text        
  157.         var RLevelStatus = new ActiveXObject("RLevel.NISStatusInfo");    
  158.         var bLAIsOn = RLevelStatus.LocationAwarenessEnabled;
  159.         if(bLAIsOn)
  160.             LocationAwarenessIsOffText.innerText = " ";
  161.         else 
  162.             LocationAwarenessIsOffText.innerText = g_LocationAwarenessOffText;
  163.         initLocationList();
  164.         
  165.         FixBtnText(true);
  166.         window.focus();
  167.     }
  168.  
  169.     if(PageB.style.display == "")
  170.     {
  171.         // setup PageC
  172.         PageB.style.display = "none";
  173.         PageC.style.display = "";
  174.  
  175.         window.focus();
  176.             
  177.         //copy the file list
  178.         if(g_bFoundListLoaded)
  179.         {
  180.             SetFileListIsLoading(true);
  181.             
  182.             //turn off buttons
  183.             BackBtn.disabled = true;
  184.             NextBtn.disabled = true;
  185.             Cancel.disabled = true;
  186.             EnableCloseButton(false);
  187.             
  188.             FoundList.PutFileListAsync(NetScan.FileList,OnPutFileListComplete,SetPutFileListProgress);
  189.         }
  190.     }
  191.  
  192.     if(PageA.style.display == "")
  193.     {
  194.         PageA.style.display = "none";
  195.         PageB.style.display = "";
  196.  
  197.         // setup PageB
  198.         NextBtn.disabled = true;
  199.         Cancel.disabled = true;
  200.         StopBtn.disabled = false;
  201.         EnableCloseButton(false);
  202.  
  203.         ScanDone.style.display = "none";
  204.         ScanStopped.style.display = "none"
  205.         Scanning.style.display = "";
  206.         Filename.style.display = "";
  207.         ScanFound.innerHTML = "0";
  208.         SetProgress(0);
  209.         pctdone.innerHTML = "0";
  210.         pctdone_text.style.display = "";
  211.  
  212.         saveDriveList();
  213.         g_bScanStarted = true;
  214.         NetScan.StartScan();
  215.  
  216.         FixBtnText(false);
  217.     }
  218. }
  219.  
  220. function OnPutFileListComplete(result)
  221. {
  222.     SetFileListIsLoading(false);
  223.     
  224.     // This was put in to fix defect 410860. It selects all applications by default. It could significantly
  225.     // slow down NIS. If it needs to be pulled, remove the follwing line and change the TIP text in
  226.     // wiz-ALEs.htm.
  227.     // The decision was since reversed, and thus the code has been removed. If it's re-reversed, un-comment
  228.     // the following code and change the html text.
  229.     //FoundList.SelectAll();
  230.     
  231.     g_bFoundListLoaded = true;
  232.     
  233.     BackBtn.disabled = false;
  234.     //Leave the next button off because no items are selected
  235.     //NextBtn.disabled = false;
  236.     Cancel.disabled = false;
  237.     EnableCloseButton(true);
  238.  
  239.     //Save the xml
  240.     //NetScan.FileList.save("C:\x.xml")
  241. }
  242.  
  243. function SetFileListIsLoading(bLoading)
  244. {
  245.     SetPutFileListProgress(0);
  246.  
  247.     //progress bar
  248.     if (bLoading) FoundListLoading.style.display = "";
  249.     else FoundListLoading.style.display = "none";
  250.     
  251.     //internet-enabled programs
  252.     if (bLoading) FoundList.style.display = "none";
  253.     else FoundList.style.display = "";
  254.     
  255.     //title
  256.     if (bLoading)
  257.     {
  258.         IDS_ALESCANTEXT12.style.display = "none";
  259.         IDS_ALESCANTEXT13.style.display = "";
  260.     }
  261.     else 
  262.     {
  263.         IDS_ALESCANTEXT12.style.display = "";
  264.         IDS_ALESCANTEXT13.style.display = "none";
  265.     }
  266.     
  267.     //buttons
  268.     CheckAll.disabled = bLoading;
  269.     UncheckAll.disabled = bLoading;
  270.     Add.disabled = bLoading;
  271.     Modify.disabled = bLoading;
  272. }
  273.  
  274. function OnMergeItemsComplete(result)
  275. {
  276.     if(HandleAleScanError(result, 1014, 1))
  277.     {
  278.         // This means that the user needs to be sent back to 
  279.         // PageC to de-select some applications.
  280.         if(PageA.style.display == "")
  281.             PageA.style.display = "none"
  282.         if(PageB.style.display == "")
  283.             PageB.style.display = "none"
  284.         if(PageD.style.display == "")
  285.             PageD.style.display = "none"
  286.         
  287.         PageC.style.display = "";
  288.  
  289.         window.focus();
  290.         
  291.         // Reset the values on the location page.
  292.         locationSelectAll.disabled = false;
  293.         locationSelectNone.disabled = false;
  294.         locationList.Enabled(true);
  295.         locationList.LTable.style.cursor = "";
  296.         // re-enable the items in the list
  297.         var arrayLocations = UILocation_GetSelectedLocations();
  298.         for(var i = 0; i < arrayLocations.length; i++)
  299.         {
  300.             var checkbox = locationList.GetCellPtr(i,0);
  301.             checkbox.disabled = false;
  302.         }
  303.  
  304.         // Reset the buttons.
  305.         FinishBtn.disabled = false;
  306.         NextBtn.disabled = false;
  307.         BackBtn.disabled = false;
  308.         Cancel.disabled = false;
  309.         FixBtnText(false);
  310.         EnableCloseButton(true);
  311.  
  312.         // And the cursor
  313.         AleWiz_Body.style.cursor = "";
  314.     }
  315.     else
  316.     {
  317.         AleWiz_Body.style.cursor = "";
  318.         window.navigate("res://closeme.xyz");
  319.     }
  320. }
  321.  
  322. function SetProgress(nPct)
  323. {
  324.     SetProgressImpl(ProgDone,ProgRemain,pctdone,nPct);
  325. }
  326.  
  327. function SetPutFileListProgress(nPct)
  328. {
  329.     SetProgressImpl(FoundListLoadComplete,FoundListLoadRemain,FoundListPctDone,nPct);
  330. }
  331.  
  332. function SetProgressImpl(complete,remaining,text,nPct)
  333. {
  334.     // We must special case 0 otherwise we get "invalid property"... arrrgggg!
  335.     var nRemain = 100 - nPct;
  336.     text.innerHTML = nPct;
  337.     
  338.     if(nPct > 0)
  339.     {
  340.         complete.style.display = "";
  341.         complete.width = nPct + "%";
  342.     }
  343.     else
  344.     {
  345.         complete.style.display = "none";
  346.     }
  347.     
  348.     if(nRemain > 0)
  349.     {
  350.         remaining.style.display = "";
  351.         remaining.width = nRemain + "%";
  352.     }
  353.     else
  354.     {
  355.         remaining.style.display = "none";
  356.     }
  357. }
  358.  
  359. function Elipse_Path(nMaxLen, szPath)
  360. {
  361.     var szItems = szPath.split("\\");
  362.     var nItem = 0;
  363.     var nLastStart = 1;
  364.     var szOutput = szPath;
  365.     while(szOutput.length > nMaxLen)
  366.     {
  367.         szOutput = szItems[0];
  368.         szOutput = szOutput + "\\" + "...";
  369.         
  370.         for(nItem = nLastStart; nItem < szItems.length; nItem++)
  371.         {
  372.             szOutput = szOutput + "\\" + szItems[nItem];            
  373.         }
  374.         
  375.         nLastStart++;
  376.     }
  377.     
  378.     return szOutput;
  379. }
  380.  
  381. function CheckUserType()
  382. {
  383.     var type = UserManager.CurrentUserType;
  384.     var product = UserManager.ProductType;
  385.  
  386.     if((product == "PT_SCF") || (product == "PT_NPF") || (product == "PT_SDF"))
  387.     {
  388.         if(type == "UT_RESTRICTED")
  389.         {
  390.             newAlert(StrID("ALEScanAdministrator"), UserManager.AppTitle, 3, 0, 0, 0);
  391.             window.navigate("res://closeme.xyz");
  392.         }
  393.     }
  394.         else
  395.     {
  396.         if(type != "UT_SUPERVISOR")
  397.         {
  398.             newAlert(StrID("ALEScanSupervisor"), UserManager.AppTitle, 3, 0, 0, 0);
  399.             window.navigate("res://closeme.xyz");
  400.         }
  401.     }
  402. }
  403.  
  404. function OnAdd()
  405. {
  406.     FoundList.Add();
  407.     foundList_OnCheckStateChanged(true);
  408. }
  409.  
  410. function OnModify()
  411. {
  412.     FoundList.Modify();
  413. }
  414.  
  415. function OnCheckAll()
  416. {
  417.     FoundList.SelectAll();
  418. }
  419.  
  420. function OnUncheckAll()
  421. {
  422.     FoundList.UnselectAll();
  423. }
  424.  
  425. function foundList_OnCheckStateChanged(bAnySelected)
  426. {
  427.     NextBtn.disabled = !bAnySelected;
  428. }
  429.  
  430. function OnKeyDownHandler()
  431. {
  432.     // Last Control Tab over to the <back, next, close> button.
  433.     var VK_ESCAPE = 27;
  434.  
  435.     if (window.event.keyCode == VK_ESCAPE && !Cancel.disabled)
  436.     {
  437.         // Escape key.. We want to exit out of the wizard..
  438.         window.navigate("res://closeme.xyz");
  439.  
  440.     }
  441.     
  442. }
  443.  
  444. function initLocationList()
  445. {
  446.     // Setup the list control
  447.     locationList.SetTableClass("ListBoxClass");
  448.     locationList.OnClick    = locationList_OnClick;
  449.     locationList.OnDblClick = locationList_OnDblClick;
  450.     locationList.OnSpace    = locationList_OnSpace;
  451.  
  452.     locationList.DeleteAllRows();
  453.     locationList.SetColumnCount(2);
  454.     locationList.SetColumnWidth(0, "15px");
  455.     locationList.SetColumnWidth(1, "100px");
  456.  
  457.     // populate list
  458.     AleWiz_Body.style.cursor = "wait";
  459.  
  460.     try
  461.     {
  462.         var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
  463.         var iLocation = iLocationList.GetFirst();
  464.         while(null != iLocation)
  465.         {
  466.             var pRow = locationList.InsertRow(-1);
  467.             var Enabled = "checked=yes";
  468.             
  469.             var checkboxString = "<input type=checkbox " + Enabled + ">";
  470.             locationList.SetCellTextPtr(pRow, 0, checkboxString);
  471.             
  472.             var locationName = iLocation.Name;
  473.             var divID = "";
  474.             if(iLocation.Active)
  475.             {
  476.                 locationName += "  ";
  477.                 locationName += StrID("Active");
  478.                 divID = "id='ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.'"
  479.             }
  480.             var TextToAdd = "<div " + divID + " style='margin-top:6;margin-bottom:6'>" + locationName + "</div>";
  481.             locationList.SetCellTextPtr(pRow, 1, TextToAdd);
  482.  
  483.             iLocation = iLocationList.GetNext();
  484.         }
  485.     }
  486.     catch(e)
  487.     {
  488.         // ejp comment out this code, but do not remove it
  489.         /*
  490.         for(var i = 0; i < 25; i++)
  491.         {
  492.             var pRow = locationList.InsertRow(-1);
  493.             var Enabled = "checked=yes";
  494.             
  495.             var checkboxString = "<input type=checkbox " + Enabled + ">";
  496.             locationList.SetCellTextPtr(pRow, 0, checkboxString);
  497.             
  498.             var locationName = "Fake location" + i;
  499.             var divID = "";
  500.             if(i % 3 == 1)
  501.             {
  502.                 locationName += " ";
  503.                 locationName += StrID("Active");
  504.                 divID = "id='ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.'"
  505.             }
  506.             
  507.             var TextToAdd = "<div " + divID + " style='margin-top:6;margin-bottom:6'>" + locationName + "</div>";
  508.             locationList.SetCellTextPtr(pRow, 1, TextToAdd);
  509.         }
  510.         */
  511.     }
  512.     
  513.     AleWiz_Body.style.cursor = "";
  514. }
  515.  
  516. function locationList_OnSpace()
  517. {
  518.     var nCurSel = locationList.GetCurSel();
  519.     var bEnable = false;
  520.  
  521.     if(nCurSel < 0)
  522.     {
  523.         return;    
  524.     }
  525.  
  526.     // Swap the state of the check box for this item
  527.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  528.     CheckBox.checked = !CheckBox.checked;
  529.     
  530.     UILocation_UpdateNextButtonState();
  531. }
  532.  
  533. function locationList_OnClick()
  534. {
  535.     UILocation_UpdateNextButtonState();
  536. }
  537.  
  538. function UILocation_UpdateNextButtonState()
  539. {
  540.     var arrayLocations = UILocation_GetSelectedLocations();
  541.  
  542.     if(arrayLocations.length)
  543.     {
  544.         FinishBtn.disabled = false;
  545.     }
  546.     else
  547.     {
  548.         FinishBtn.disabled = true;
  549.     }
  550. }
  551.  
  552. function locationList_OnDblClick()
  553. {
  554.     var nCurSel = locationList.GetCurSel();
  555.     var bEnable = false;
  556.  
  557.     if(nCurSel < 0)
  558.     {
  559.         return;    
  560.     }
  561.  
  562.     // Swap the state of the check box for this item
  563.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  564.     CheckBox.checked = !CheckBox.checked;
  565.     
  566.     UILocation_UpdateNextButtonState();
  567. }
  568.  
  569. function UILocation_SelectAll()
  570. {
  571.     for(var i = locationList.GetRowCount(); i > 0; i--)
  572.     {
  573.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  574.         CheckBox.checked = true;
  575.     }
  576.     UILocation_UpdateNextButtonState()
  577. }
  578.  
  579. function UILocation_DeselectAll()
  580. {
  581.     for(var i = locationList.GetRowCount(); i > 0; i--)
  582.     {
  583.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  584.         CheckBox.checked = false;
  585.     }
  586.     UILocation_UpdateNextButtonState()
  587. }
  588.  
  589. function UILocation_GetSelectedLocations()
  590. {
  591.     var arrayLocations = new Array();
  592.     
  593.     for(var i = locationList.GetRowCount(); i > 0; i--)
  594.     {
  595.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  596.         var bChecked = CheckBox.checked;
  597.         var div = locationList.GetCellPtr(i-1, 1).children[0];
  598.         var sLocation = div.innerText;    
  599.         if(bChecked)
  600.         {
  601.             if(div.id == "ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.")
  602.             {
  603.                 var sTmp = sLocation.slice(0, sLocation.lastIndexOf(StrID("Active")));
  604.                 sLocation = sTmp;
  605.             }
  606.             sLocation = trim(sLocation);
  607.             arrayLocations = arrayLocations.concat(sLocation);
  608.         }
  609.     }
  610.     return arrayLocations;
  611. }
  612.  
  613. function UserManager_OnFREIntegratorStart()
  614. {
  615.     if(g_bScanStarted)
  616.         StopBtn_OnClick();
  617.  
  618.     window.navigate('res://closeme.xyz');
  619. }
  620.  
  621. function EnableCloseButton(bEnabled)
  622. {
  623.     //turn off webWnd's close button
  624.     var webWnd = window.external.ObjectArg;
  625.     webWnd.CloseButton = bEnabled;
  626. }