home *** CD-ROM | disk | FTP | other *** search
- ////////////////////////////////////////////////////////////////////////////////////////////
- //
- // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
- //
- // NAME: Location-Wiz.js (Javascript file for Location-Wiz.htm)
- //
- // Copyright (c) 2003 by Symantec Corporation. All rights reserved.
- //
- ////////////////////////////////////////////////////////////////////////////////////////////
-
- var IE4 = document.all;
-
- var g_SelectedLocationName = "";
- var g_bLaunchedFromAlert = true;
-
- var g_numberTrusted = 0;
- var g_numberTrustable = 0;
- var g_iLocationList;
-
- ///////////////////////////////////////////////////////
- /////////new alert params /////////////////////////////
- ///////////////////////////////////////////////////////
- //icon:
- // 0 = no icon
- // 1 = error
- // 2 = question
- // 3 = alert
- // 4 = info
- //
- //buts:
- // 0 = ok
- // 1 = ok, cancel
- // 2 = abort, retry, cancel
- // 3 = yes, no, cancel
- // 4 = yes, no
- // 5 = retry, cancel
- //
- //defbut
- // 0 = first
- // 1 = second
- // 2 = third
- //
- //mods:
- // 0 = app modal
- // 1 = system modal
- function newAlert(mess, title, icon, buts, defbut, mods)
- {
- if(IE4)
- makeMsgBox(title, mess, icon, buts, defbut, mods)
- else
- alert(mess);
- }
-
- function Window_OnLoad()
- {
- dialogheight = "400px";
- dialogWidth = "532px";
- returnValue = "";
-
- try
- {
- var RLevelStatus = new ActiveXObject("RLevel.NISStatusInfo");
-
- if (RLevelStatus.IsSystemInHighContrastMode)
- document.body.scroll = "auto";
- else
- document.body.scroll = "no";
- }
- catch(err)
- {
- // Just bail... we'll continue anyways.
- }
-
- FinishBtn.disabled = false; // enable the finish button beacuse a location will be selected by default
- BackBtn.disabled = true;
-
- Location_PopulateDropDown(DropList_Location, 1);
-
- // if no arguments were passed in, then this is being launched from the NIS main UI,
- // so picking from saved locations is not an option
- // if arguments are passed in, then this is being launched from the new location alert
- (window.dialogArguments != "undefined" && window.dialogArguments.length) ? g_bLaunchedFromAlert = true : g_bLaunchedFromAlert = false;
-
- g_iLocationList = new ActiveXObject("ccFWSettg.LocationList");
- var nNumberLocations = g_iLocationList.ItemCount;
- if(nNumberLocations >= 64)
- {
- Radio_CreateNewLocation.disabled = true;
- var webWnd = new ActiveXObject("CcWebWnd.ccWebWindow");
- webWnd.SetIcon2("res://nisres.dll/105");
- webWnd.MsgBox(StrID("EnoughWithTheNewLocationsAlready!"), UserManager.ProductName, 0);
-
- // if no arguments were passed in, then this is being launched from the NIS main UI,
- // so picking from saved locations is not an option
- // if arguments are passed in, then this is being launched from the new location alert
- if(!g_bLaunchedFromAlert)
- {
- returnValue = "";
- window.navigate("res://closeme.xyz");
- return;
- }
- }
- else
- {
- GenerateSuggestedLocationName();
-
- g_numberTrustable = HomeNetCore.Detect();
-
- // must manually disable detected networks. HomeNetCore ought to wait until the code tells it to enable anything before doing so
- for(var i = 0; i < g_numberTrustable; i++)
- {
- HomeNetCore.EnableHN(i, false);
- }
-
- if(g_numberTrustable)
- {
- InitializeTrustableList();
- }
- }
-
- // if no arguments were passed in, then this is being launched from the NIS main UI,
- // so picking from saved locations is not an option
- // if arguments are passed in, then this is being launched from the new location alert
- if(!g_bLaunchedFromAlert)
- {
- FixBtnText(false); // we need the next button, not the finish button
- Cancel.disabled = false;
-
- PageA.style.display = "none";
- if(g_numberTrustable)
- {
- PageB.style.display = "";
- }
- else
- {
- PageD.style.display = "";
- }
- }
- else
- {
- FixBtnText(true); // change next button to finish since the "use preexisting location" option is the default
- PageA.style.display = "";
- Cancel.style.display = "none";
- }
-
- window.focus();
- }
-
- function InitializeTrustableList()
- {
- // Setup the list control
- TrustableList.SetTableClass("ListBoxClass");
- TrustableList.OnDblClick = TrustableList_OnDblClick;
- TrustableList.OnSpace = TrustableList_OnSpace;
- TrustableList.OnClick = TrustableList_OnClick;
-
- TrustableList.SetColumnCount(2);
- TrustableList.SetColumnWidth(0, "15%");
- TrustableList.SetColumnWidth(1, "85%");
-
- var Checked = ""; // don't select anything by default var Enabled = "checked"
- var checkboxString = "<input type=checkbox " + Checked + ">";
-
- for(var i = 0; i < g_numberTrustable; i++)
- {
-
- var pRow = TrustableList.InsertRow(-1);
-
- TrustableList.SetCellTextPtr(pRow, 0, checkboxString);
-
- var trustableDescription = StrID("Address") + ": " + HomeNetCore.GetIPAddress(i);
- trustableDescription += "<br>" + StrID("Mask") + ": " + HomeNetCore.GetMask(i);
-
- var TextToAdd = "<div style='margin-top:6;margin-bottom:6'>" + trustableDescription + "</div>";
- TrustableList.SetCellTextPtr(pRow, 1, TextToAdd);
- }
- }
-
- function TrustableList_OnSpace()
- {
- var nCurSel = TrustableList.GetCurSel();
- var bEnable = false;
-
- if(nCurSel < 0)
- {
- return;
- }
-
- // Swap the state of the check box for this item
- var CheckBox = TrustableList.GetCellPtr(nCurSel, 0).children[0];
- CheckBox.checked = !CheckBox.checked;
-
- var arrayTrusted = GetSelectedTrustable();
- g_numberTrusted = arrayTrusted.length;
- }
-
- function TrustableList_OnClick()
- {
- var arrayTrusted = GetSelectedTrustable();
- g_numberTrusted = arrayTrusted.length;
- }
-
- function TrustableList_OnDblClick()
- {
- var nCurSel = TrustableList.GetCurSel();
- var bEnable = false;
-
- if(nCurSel < 0)
- {
- return;
- }
-
- // Swap the state of the check box for this item
- var CheckBox = TrustableList.GetCellPtr(nCurSel, 0).children[0];
- CheckBox.checked = !CheckBox.checked;
-
- var arrayTrusted = GetSelectedTrustable();
- g_numberTrusted = arrayTrusted.length;
- }
-
- function GetSelectedTrustable()
- {
- var arrayTrusted = new Array();
-
- for(var i = 0; i < TrustableList.GetRowCount(); i++)
- {
- var CheckBox = TrustableList.GetCellPtr(i, 0).children[0];
- var bChecked = CheckBox.checked;
- if(bChecked)
- {
- arrayTrusted[arrayTrusted.length] = i;
- }
- }
- return arrayTrusted;
- }
-
- function FinishBtn_OnClick()
- {
- BackBtn.disabled = true;
- NextBtn.disabled = true;
- FinishBtn.disabled = true;
- Cancel.disabled = true;
-
- if (g_SelectedLocationName == "")
- {
- OnDropListLocationChange(DropList_Location.options[DropList_Location.selectedIndex]);
- }
-
- if(Radio_CreateNewLocation.checked || !g_bLaunchedFromAlert)
- {
- setTimeout("Finish_LongProcessing()", 100);
- }
- else
- {
- setTimeout("Finish_LongProcessing_Location_Existed()", 100);
- }
- }
-
- function Finish_LongProcessing_Location_Existed()
- {
- var iLocation = g_iLocationList.GetItemByName(g_SelectedLocationName);
-
- if(null != iLocation)
- {
- iLocation.AddNetSpec(window.dialogArguments);
-
- g_iLocationList.SaveItem(iLocation);
- }
-
- window.navigate("res://closeme.xyz");
- }
-
- function Finish_LongProcessing()
- {
- var iLocation = new ActiveXObject("ccFWSettg.Location");
-
- if (window.dialogArguments != "")
- {
- iLocation.AddNetSpec(window.dialogArguments);
- }
-
- if(Radio_UseSavedLocation.checked && window.dialogArguments.length)
- {
- iLocation.Name = g_SelectedLocationName;
- }
- else
- {
- iLocation.AutomaticProgramControl = Radio_ProgramControl_On.checked;
- iLocation.Name = newLocationName.value;
- }
-
- var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
- iLocationList.SaveItem(iLocation);
-
- var iFirewallSettings = new ActiveXObject("ccFWSettg.FirewallSettings");
- iFirewallSettings.CreateDefaultSettingsForLocation(iLocation.Name);
-
- // Trusted Zones must be added after the location is created and assigned an ID
- var arrayTrusted = GetSelectedTrustable();
- if(arrayTrusted.length)
- {
- HomeNetCore.FilterByLocation = newLocationName.value;
- for(var i = 0; i < arrayTrusted.length; i++)
- {
- var networkNum = 0;
- networkNum = Number(arrayTrusted[i]);
- HomeNetCore.EnableHN(networkNum, true);
- }
- HomeNetCore.AddItems();
- }
-
- returnValue = "";
- window.navigate("res://closeme.xyz");
- }
-
- function NextBtn_OnClick()
- {
- if(PageE.style.display == "")
- {
- // remove all backslashes, and leading and trailing whitespace
- newLocationName.value = newLocationName.value.replace(/\\/g,"");
- newLocationName.value = newLocationName.value.replace(/^\s*/,"");
- newLocationName.value = newLocationName.value.replace(/\s*$/,"");
-
- // if the result is an empty string, do not continue
- // TODO: There should be a MsgBox warning here, but it's now
- // too late in the NIS2004 development cycle to add one.
- if (newLocationName.value.length == 0) return;
-
- // if the result already exists, warn with a MsgBox, but do not continue
- var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
- var iLocation = iLocationList.GetItemByName(newLocationName.value);
- if(null != iLocation)
- {
- var webWnd = new ActiveXObject("CcWebWnd.ccWebWindow");
- webWnd.SetIcon2("res://nisres.dll/105");
- webWnd.MsgBox(StrID("LocationDupeEntry"), UserManager.ProductName, 0);
- return;
- }
-
- SummaryLocationName.innerText = newLocationName.value;
- if(Radio_ProgramControl_On.checked)
- {
- SummaryLocationProgramControlType.innerText = StrID("Automatic");
- }
- else
- {
- SummaryLocationProgramControlType.innerText = StrID("AlertMe");
- }
-
- if(g_numberTrusted)
- {
- SummaryLocationTrustedNumber.innerText = g_numberTrusted;
- }
- else
- {
- SummaryLocationTrustedNumber.innerText = StrID("None");
- }
-
- BackBtn.disabled = false;
- PageE.style.display = "none";
- PageF.style.display = "";
- FixBtnText(true);
- FinishBtn.disabled = false;
- window.focus();
- return;
- }
-
- if(PageD.style.display == "")
- {
- BackBtn.disabled = false;
- PageD.style.display = "none";
- PageE.style.display = "";
- window.focus();
- return;
- }
-
- if(PageC.style.display == "")
- {
- BackBtn.disabled = false;
- PageC.style.display = "none";
- PageD.style.display = "";
- window.focus();
- return;
- }
-
- if(PageB.style.display == "")
- {
- BackBtn.disabled = false;
- PageB.style.display = "none";
- if(Radio_EnableTrustedZones.checked)
- {
- PageC.style.display = "";
- }
- else
- {
- PageD.style.display = "";
- }
- window.focus();
- return;
- }
-
- if(PageA.style.display == "")
- {
- PageA.style.display = "none";
-
- if(g_numberTrustable)
- {
- PageB.style.display = "";
- }
- else
- {
- PageD.style.display = "";
- }
-
- BackBtn.disabled = false;
- window.focus();
- return;
- }
- }
-
- function BackBtn_OnClick()
- {
- if(PageB.style.display == "")
- {
- PageB.style.display = "none"
- PageA.style.display = ""
- BackBtn.disabled = true
- FixBtnText(false)
- return;
- }
-
- if(PageC.style.display == "")
- {
- if(!g_bLaunchedFromAlert)
- {
- BackBtn.disabled = true;
- }
- PageC.style.display = "none"
- PageB.style.display = ""
- return;
- }
-
- if(PageD.style.display == "")
- {
- PageD.style.display = "none"
-
- if(g_numberTrustable)
- {
- PageB.style.display = ""
- if(!g_bLaunchedFromAlert)
- {
- BackBtn.disabled = true;
- }
- }
- else if(g_bLaunchedFromAlert)
- {
- PageA.style.display = ""
- BackBtn.disabled = true;
- FixBtnText(false)
- }
- return;
- }
-
- if(PageE.style.display == "")
- {
- if(!g_numberTrustable && !g_bLaunchedFromAlert)
- {
- BackBtn.disabled = true;
- }
-
- PageE.style.display = "none"
- PageD.style.display = ""
- EnableButton(NextBtn, true);
- return;
- }
-
- if(PageF.style.display == "")
- {
- PageF.style.display = "none"
- PageE.style.display = ""
- FixBtnText(false)
- return;
- }
- }
-
- function OnKeyDownHandler()
- {
- // Last Control Tab over to the <back, next, close> button.
- var VK_ESCAPE = 0x1B;
-
- if (window.event.keyCode == VK_ESCAPE)
- {
- // Escape key.. We want to exit out of the wizard..
- // window.navigate("res://closeme.xyz");
- }
- }
-
- function Radio_CreateNewLocation_OnClick()
- {
- if(Radio_CreateNewLocation.checked)
- {
- FixBtnText(false);
- }
- else
- {
- FixBtnText(true);
- }
-
- // disable the finish button if the user hasn't selected a location
- if(g_SelectedLocationName.length)
- {
- FinishBtn.disabled = false;
- }
- else
- {
- FinishBtn.disabled = true;
- }
- }
-
- function OnDropListLocationChange(oSelectedOption)
- {
- var sLocation = Location_GetDropDownSelectedItemText(oSelectedOption);
- g_SelectedLocationName = sLocation;
-
- FinishBtn.disabled = false;
- }
-
- function Cancel_OnClick()
- {
- returnValue = "";
- window.navigate("res://closeme.xyz");
- }
-
- function FixBtnText(bFinish)
- {
- if(bFinish == true)
- {
- NextBtn.style.display = "none"
- FinishBtn.style.display = ""
- }
- else
- {
- NextBtn.style.display = ""
- FinishBtn.style.display = "none"
- }
- }
-
- function GenerateSuggestedLocationName()
- {
- var iLocationList = new ActiveXObject("ccFWSettg.LocationList");
- var iLocation = iLocationList.GetItemByName(newLocationName.value);
-
- var locationNameBase = newLocationName.value;
- locationNameBase = locationNameBase.slice(0, locationNameBase.length - 1); // strip off the "1" from Location1
-
- // look for a location name "locationN" that is not in use
- var nIndex = 2;
- while(null != iLocation)
- {
- iLocation = iLocationList.GetItemByName(locationNameBase + nIndex);
- nIndex++;
- }
- newLocationName.value = locationNameBase + (nIndex -1); // add the number of the first location not in use to the word "Location"
- }
-