home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 2004 July / APC0407D1.iso / powerkit / firewall / files / NPF2004.exe / Setup / Firewall / APP / HNetWiz.exe / HTML / WIZ-HN.JS < prev    next >
Encoding:
JavaScript  |  2003-09-06  |  11.1 KB  |  417 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
  4. //
  5. // NAME:    wiz-HN.js (Javascript file for wiz-HN.HTM)
  6. //
  7. // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////////////////
  10.  
  11. var IE4 = document.all;
  12. var nHomeNetCount = 0;
  13. var bDetected = false;
  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 Window_OnLoad()
  49. {
  50.     dialogheight = "400px";
  51.     dialogWidth = "532px";
  52.     returnValue = "";
  53.     bUserStopped = 0;
  54.     PageA.style.display = "";
  55.     BackBtn.disabled = true;
  56.  
  57.     ProdNameB.innerHTML = UserManager.AppTitle;
  58.     ProdNameC.innerHTML = UserManager.AppTitle;
  59.     ProdNameD.innerHTML = UserManager.AppTitle;
  60.  
  61.     var sProductType = UserManager.ProductType;
  62.     switch (sProductType)
  63.     {
  64.         case "PT_SCF":
  65.         case "PT_PRO":
  66.         window.WizType1.innerText = "Workgroup";
  67.         window.WizType2.innerText = "Workgroup";
  68.         window.WizType3.innerText = "business";
  69.         window.WizType4.innerText = "Workgroup";
  70.         window.WizType5.innerText = "workgroup";
  71.         window.WizType6.innerText = "Workgroup";
  72.         window.WizType7.innerText = "Workgroup";
  73.         document.title = "Workgroup Network Wizard";
  74.         break;
  75.  
  76.         default:
  77.         window.WizType1.innerText = "Home";
  78.         window.WizType2.innerText = "Home";
  79.         window.WizType3.innerText = "home";
  80.         window.WizType4.innerText = "Home";
  81.         window.WizType5.innerText = "home";
  82.         window.WizType6.innerText = "Home";
  83.         window.WizType7.innerText = "Home";
  84.         document.title = "Home Network Wizard";
  85.         break;
  86.     }
  87.  
  88.     var RLevelStatus = new ActiveXObject("RLevel.NISStatusInfo");
  89.     var bLAIsOn = RLevelStatus.LocationAwarenessEnabled;
  90.     if(bLAIsOn)
  91.     {
  92.         LocationAwarenessIsOffText.innerText = " ";
  93.     }
  94.  
  95.     if(RLevelStatus.IsSystemInHighContrastMode)
  96.     {
  97.         HNetWizBody.scroll = "auto";
  98.     }
  99.  
  100.  
  101.     CheckUserType();
  102.  
  103.     initLocationList();
  104.  
  105.     FixBtnText(false);
  106.     window.focus();
  107. }
  108.  
  109. function CheckUserType()
  110. {
  111.     var admin = HomeNetCore.WindowsAdminUser;
  112.     if(!admin)
  113.     {
  114.         newAlert(StrID("HNWizardAdministrator"), UserManager.AppTitle, 3, 0, 0, 0);
  115.         window.navigate("res://closeme.xyz");
  116.         return;
  117.     }
  118.  
  119.     var type = UserManager.CurrentUserType;
  120.     if(type != "UT_SUPERVISOR")
  121.     {
  122.         newAlert(StrID("HNWizardSupervisor"), UserManager.AppTitle, 3, 0, 0, 0);
  123.         window.navigate("res://closeme.xyz");
  124.     }
  125. }
  126.  
  127.  
  128. function FinishBtn_OnClick()
  129. {
  130.     // Add the selected items to the trusted zones of the selected locations
  131.     var arrayLocations = UILocation_GetSelectedLocations();
  132.     for(var i = 0; i < arrayLocations.length; i++)
  133.     {
  134.         HomeNetCore.FilterByLocation = arrayLocations[i];
  135.         HomeNetCore.AddItems();
  136.     }
  137.  
  138.  
  139.     window.navigate("res://closeme.xyz");
  140. }
  141.  
  142.  
  143. function NextBtn_OnClick()
  144. {
  145. // Find the active page, back to front (if we are not disabled)
  146.     if(PageD.style.display == "")
  147.     {
  148.         // Close this window
  149.         window.navigate("res://closeme.xyz");
  150.     }
  151.  
  152.     if(PageC.style.display == "")
  153.     {
  154.         PageC.style.display = "none";
  155.         PageOldC.style.display = "";
  156.  
  157.         // setup the last page
  158.         BackBtn.disabled = false;
  159.         Cancel.disabled = false;
  160.         FixBtnText(true);
  161.         window.focus();
  162.     }
  163.  
  164.     if(PageB.style.display == "")
  165.     {
  166.  
  167.         PageB.style.display = "none";
  168.         PageC.style.display = "";
  169.  
  170.         // Setup the locations page
  171.         UILocation_UpdateNextButtonState();
  172.         BackBtn.disabled = false;
  173.         Cancel.disabled = false;
  174.         FixBtnText(false);
  175.         window.focus();
  176.     }
  177.  
  178.     if(PageA.style.display == "")
  179.     {
  180.         bDetected = true;
  181.         // Do the scan (this is very quick)
  182.         nHomeNetCount = HomeNetCore.Detect();
  183.         if(nHomeNetCount == 0)
  184.         {
  185.             PageA.style.display = "none";
  186.             PageD.style.display = "";
  187.  
  188.             window.IDS_HOMENETTEXT1.innerText = StrID("HNNoneFound");
  189.  
  190.             // Setup the second page
  191.             BackBtn.disabled = true;
  192.             FixBtnText(true);
  193.             window.focus();
  194.         }
  195.         else
  196.         {
  197.             PageA.style.display = "none";
  198.             PageB.style.display = "";
  199.  
  200.             // Setup the second page
  201.             BackBtn.disabled = false;
  202.             FixBtnText(false);
  203.             window.focus();
  204.  
  205.             if(nHomeNetCount > 1)
  206.             {
  207.                 for(var i = 0; i < nHomeNetCount; i++)
  208.                 {
  209.                     // Get the details on the first item
  210.                     var oOption = document.createElement("OPTION");
  211.                     var szDisplayStr = HomeNetCore.GetAdapterName(i);
  212.  
  213.                     // If string is larger than max we will only display max chars + ...
  214.                     if(szDisplayStr.length > 30)
  215.                         szDisplayStr = szDisplayStr.substr(0, 30) + "...";
  216.  
  217.                     oOption.text = szDisplayStr;
  218.                     oOption.value = i;
  219.                     Adapters.options.add(oOption);
  220.                 }
  221.  
  222.                 Adapters.selectedIndex = 0;
  223.             }
  224.             else
  225.             {
  226.                 Adapters.style.display = "none";
  227.                 AdapterSelect.style.display = "none";
  228.                 SingleAdapter.innerHTML =   HomeNetCore.GetAdapterName(0);
  229.             }
  230.  
  231.             SetCheckAndDetails();
  232.         }
  233.     }
  234. }
  235.  
  236. function StoreCheckBox()
  237. {
  238.     var nCurOption = 0;
  239.     if(Adapters.style.display == "")
  240.         nCurOption = Number(Adapters.options.item(Adapters.selectedIndex).value);
  241.  
  242.     HomeNetCore.EnableHN(nCurOption, AddCheck.checked);
  243. }
  244.  
  245. function SetCheckAndDetails()
  246. {
  247.     var nCurOption = 0;
  248.     if(Adapters.style.display == "")
  249.         nCurOption = Number(Adapters.options.item(Adapters.selectedIndex).value);
  250.  
  251.     // Set the checkbox to this adapters state
  252.     AddCheck.checked = HomeNetCore.IsHNEnabled(nCurOption);
  253.  
  254.     // Fill in the details
  255.     SingleAdapter.innerHTML = HomeNetCore.GetAdapterName(nCurOption);
  256.     adapterMAC.innerHTML = HomeNetCore.GetMAC(nCurOption);
  257.     adapterIP.innerHTML = HomeNetCore.GetIPAddress(nCurOption);
  258.     adapterMask.innerHTML = HomeNetCore.GetMask(nCurOption);
  259. }
  260.  
  261. function OnKeyDownHandler()
  262. {
  263.     // Last Control Tab over to the <back, next, close> button.
  264.     var VK_ESCAPE = 27;
  265.  
  266.     if (window.event.keyCode == VK_ESCAPE)
  267.     {
  268.         // Escape key.. We want to exit out of the wizard..
  269.         window.navigate("res://closeme.xyz");
  270.  
  271.     }
  272.  
  273. }
  274.  
  275.  
  276. function initLocationList()
  277. {
  278.     // Setup the list control
  279.     locationList.SetTableClass("ListBoxClass");
  280.     locationList.OnClick    = locationList_OnClick;
  281.     locationList.OnDblClick = locationList_OnDblClick;
  282.     locationList.OnSpace    = locationList_OnSpace;
  283.  
  284.     locationList.SetColumnCount(2);
  285.     locationList.SetColumnWidth(0, "15px");
  286.     locationList.SetColumnWidth(1, "100px");
  287.  
  288.     // populate list
  289.     try
  290.     {
  291.         var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
  292.         var iLocation = iLocationList.GetFirst();
  293.         while(null != iLocation)
  294.         {
  295.             var pRow = locationList.InsertRow(-1);
  296.             var Enabled = "checked=yes";
  297.  
  298.             var checkboxString = "<input type=checkbox " + Enabled + ">";
  299.             locationList.SetCellTextPtr(pRow, 0, checkboxString);
  300.  
  301.             var locationName = iLocation.Name;
  302.             var divID = "";
  303.             if(iLocation.Active)
  304.             {
  305.                 locationName += "  ";
  306.                 locationName += StrID("Active");
  307.                 divID = "id='ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.'"
  308.             }
  309.             var TextToAdd = "<div " + divID + " style='margin-top:6;margin-bottom:6'>" + locationName + "</div>";
  310.             locationList.SetCellTextPtr(pRow, 1, TextToAdd);
  311.  
  312.             iLocation = iLocationList.GetNext();
  313.         }
  314.     }
  315.     catch(e)
  316.     {
  317.     }
  318.  
  319. }
  320.  
  321. function locationList_OnSpace()
  322. {
  323.     var nCurSel = locationList.GetCurSel();
  324.     var bEnable = false;
  325.  
  326.     if(nCurSel < 0)
  327.     {
  328.         return;
  329.     }
  330.  
  331.     // Swap the state of the check box for this item
  332.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  333.     CheckBox.checked = !CheckBox.checked;
  334.  
  335.     UILocation_UpdateNextButtonState();
  336. }
  337.  
  338. function locationList_OnClick()
  339. {
  340.     UILocation_UpdateNextButtonState();
  341. }
  342.  
  343. function UILocation_UpdateNextButtonState()
  344. {
  345.     var arrayLocations = UILocation_GetSelectedLocations();
  346.  
  347.     if(arrayLocations.length)
  348.     {
  349.         NextBtn.disabled = false;
  350.     }
  351.     else
  352.     {
  353.         NextBtn.disabled = true;
  354.     }
  355. }
  356.  
  357. function locationList_OnDblClick()
  358. {
  359.     var nCurSel = locationList.GetCurSel();
  360.     var bEnable = false;
  361.  
  362.     if(nCurSel < 0)
  363.     {
  364.         return;
  365.     }
  366.  
  367.     // Swap the state of the check box for this item
  368.     var CheckBox = locationList.GetCellPtr(nCurSel, 0).children[0];
  369.     CheckBox.checked = !CheckBox.checked;
  370.  
  371.     UILocation_UpdateNextButtonState();
  372. }
  373.  
  374. function UILocation_SelectAll()
  375. {
  376.     for(var i = locationList.GetRowCount(); i > 0; i--)
  377.     {
  378.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  379.         CheckBox.checked = true;
  380.     }
  381.     UILocation_UpdateNextButtonState()
  382. }
  383.  
  384. function UILocation_DeselectAll()
  385. {
  386.     for(var i = locationList.GetRowCount(); i > 0; i--)
  387.     {
  388.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  389.         CheckBox.checked = false;
  390.     }
  391.     UILocation_UpdateNextButtonState()
  392. }
  393.  
  394. function UILocation_GetSelectedLocations()
  395. {
  396.     var arrayLocations = new Array();
  397.  
  398.     for(var i = locationList.GetRowCount(); i > 0; i--)
  399.     {
  400.         var CheckBox = locationList.GetCellPtr(i - 1, 0).children[0];
  401.         var bChecked = CheckBox.checked;
  402.         var div = locationList.GetCellPtr(i-1, 1).children[0];
  403.         var sLocation = div.innerText;
  404.         if(bChecked)
  405.         {
  406.             if(div.id == "ACTIVE ITEM.  DO NOT MOVE THIS STRING OUT OF THE CODE.")
  407.             {
  408.                 var sTmp = sLocation.slice(0, sLocation.lastIndexOf(StrID("Active")));
  409.                 sLocation = sTmp;
  410.             }
  411.             sLocation = trim(sLocation);
  412.             arrayLocations = arrayLocations.concat(sLocation);
  413.         }
  414.     }
  415.     return arrayLocations;
  416. }
  417.