home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 May / 05_02.iso / software / nis / files / NIS / NIS.MSI / fwUI.dll / HTML / ADAPTERS-POPUP.JS < prev    next >
Encoding:
JavaScript  |  2001-12-01  |  5.6 KB  |  214 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // PRODUCT: Norton Internet Security/Symantec Desktop Firewall
  4. //
  5. // NAME:    Adapters-Popup.js (Javascript file for Adapters-popup.HTM)
  6. //
  7. // Copyright (c) 2001 by Symantec Corporation. All rights reserved.
  8. //
  9. ////////////////////////////////////////////////////////////////////////////////////////////
  10.  
  11.     var xmlIPList = null;
  12.     var xmlIPListPrivate = new ActiveXObject("Microsoft.XMLDOM");
  13.     returnValue = null;
  14.  
  15. function Page_OnLoad()
  16. {
  17.     UIIPLoad(window.dialogArguments);
  18.     IPSetText(getElem(xmlIPList.parentNode, "Action").toLowerCase());
  19.  
  20.     //
  21.     // Register special handlers
  22.     //
  23.     IPAdd.onclick = IPAdd_OnClick;
  24.     IPRemove.onclick = IPRemove_OnClick;
  25.     
  26.     OKB.focus();
  27. }
  28.  
  29. ////////////////////////////////////////////////////////////////////////////////////
  30. //  Local Sites/Zones to Block page
  31. //
  32.  
  33. var currentActionState = null;
  34.  
  35. function IPList_OnClick()
  36. {
  37.     // Enable the modify/delete buttons
  38.     EnableButton(IPRemove,true);
  39. }
  40.  
  41. function IPCtlsEnabled(enable)
  42. {
  43.  
  44.     EnableButton(IPAdd,enable);
  45.  
  46.     //
  47.     // Only allow this button to be disabled. Be sure to remove
  48.     // selection too.
  49.     //
  50.     if (!enable)
  51.     {
  52.         EnableButton(IPRemove,enable);
  53.         IPList.SetCurSel(-1);
  54.     }
  55.  
  56.     //
  57.     // Enable radio buttons appropriately.
  58.     //
  59.     Addresses[0].checked = !enable;
  60.     Addresses[1].checked = enable;
  61. }
  62.  
  63. function UIIPLoad(xml)
  64. {
  65.     IPList_OnLoad();
  66.  
  67.     xmlIPList = xml;
  68.     xmlIPListPrivate.documentElement = xml.cloneNode(true);
  69.     
  70.     refreshIPList();
  71. }
  72.  
  73. function refreshIPList()
  74. {
  75.     //
  76.     // Reset the list control
  77.     //
  78.     IPList.DeleteAllRows();
  79.     IPList.SetColumnCount(2);
  80.  
  81.     var addressNodeList = xmlIPListPrivate.selectNodes(".//(Address|NamedAddress|AddressRange|MaskedAddress|ZoneName)");
  82.     var ChildCount = 0;
  83.     var bEnableList = false;
  84.  
  85.     for(ChildCount = 0; ChildCount < addressNodeList.length; ChildCount++)
  86.     {
  87.         var addressChildNode = addressNodeList.item(ChildCount);
  88.  
  89.         if(stricmp(addressChildNode.nodeName, "MaskedAddress") == 0)
  90.         {
  91.             bEnableList = true;
  92.             var chunks = addressChildNode.nodeTypedValue.split(":");
  93.             var text = StrID("IP") + ": " + chunks[0] + "<BR>" + StrID("Mask") + ": " + chunks[1];
  94.  
  95.             pRow = IPList.InsertRow(-1);
  96.             IPList.SetCellTextPtr(pRow, 0, StrID("NetworkAddress"));
  97.             IPList.SetCellTextPtr(pRow, 1, text);
  98.         }
  99.         else if(stricmp(addressChildNode.nodeName, "AddressRange") == 0)
  100.         {
  101.             bEnableList = true;
  102.             var chunks = addressChildNode.nodeTypedValue.split(":");
  103.             var text = StrID("From") + ": " + chunks[0] + "<BR>" + StrID("To") + ": " + chunks[1];
  104.  
  105.             pRow = IPList.InsertRow(-1);
  106.             IPList.SetCellTextPtr(pRow, 0, StrID("AddressRange"));
  107.             IPList.SetCellTextPtr(pRow, 1, text);
  108.         }
  109.         else if(stricmp(addressChildNode.nodeName, "NamedAddress") == 0)
  110.         {
  111.             bEnableList = true;
  112.             var text = StrID("Name") + ": " + addressChildNode.nodeTypedValue;
  113.  
  114.             pRow = IPList.InsertRow(-1);
  115.             IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
  116.             IPList.SetCellTextPtr(pRow, 1, text);
  117.         }
  118.         else if(stricmp(addressChildNode.nodeName, "Address") == 0)
  119.         {
  120.             bEnableList = true;
  121.             var text = StrID("IP") + ": " + addressChildNode.nodeTypedValue;
  122.  
  123.             pRow = IPList.InsertRow(-1);
  124.             IPList.SetCellTextPtr(pRow, 0, StrID("SingleAddress"));
  125.             IPList.SetCellTextPtr(pRow, 1, text);
  126.         }
  127.     }
  128.  
  129.     IPCtlsEnabled(bEnableList);
  130. }
  131.  
  132. function IPAdd_OnClick()
  133. {
  134.     var xmlOut = webWnd.showModalDialog('res://fwui.dll/IP-Popup.htm', 450, 330, currentActionState);
  135.     if (null != xmlOut)
  136.     {
  137.         var nodes = xmlOut.selectNodes("/*/*");
  138.         for (var nElem = 0; nodes.length > nElem; nElem++)
  139.         {
  140.             var appendTo = xmlIPListPrivate.selectSingleNode(".");
  141.             if (null == xmlIPListPrivate.ownerDocument)
  142.                 appendTo = xmlIPListPrivate.selectSingleNode("*");
  143.             appendTo.appendChild(nodes[nElem].cloneNode(true));
  144.  
  145.         }
  146.         refreshIPList();
  147.         IPRemove.disabled = true;            
  148.     }
  149. }
  150.  
  151. function IPRemove_OnClick()
  152. {
  153.     var nSel = IPList.GetCurSel();
  154.     var nodes = xmlIPListPrivate.selectNodes(".//(Address|NamedAddress|AddressRange|MaskedAddress)");
  155.     if (nodes.length <= nSel)
  156.     {
  157.         IPList.SetCurSel(-1);
  158.         return;
  159.     }
  160.     var nodeRemove = nodes[nSel];
  161.     nodeRemove.parentNode.removeChild(nodeRemove);
  162.     refreshIPList();
  163.  
  164.     if (IPList.GetRowCount() <= nSel)
  165.         nSel = IPList.GetRowCount()-1;
  166.     IPList.SetCurSel(nSel);        
  167. }
  168.  
  169. function IPList_OnLoad()
  170. {
  171.     IPList.SetTableClass("ListBoxClass");
  172.     IPList.OnClick = IPList_OnClick;
  173. }
  174.  
  175. function IPSetText(action)
  176. {
  177.     currentActionState = action;
  178.     switch (action)
  179.     {
  180.         case "permit":
  181.             IPPermitRule.style.display = "";
  182.             IPBlockRule.style.display = "none";
  183.             IPMonitorRule.style.display = "none";
  184.             break;
  185.         case "block":
  186.             IPPermitRule.style.display = "none";
  187.             IPBlockRule.style.display = "";
  188.             IPMonitorRule.style.display = "none";
  189.             break;
  190.         case "monitor":
  191.             IPPermitRule.style.display = "none";
  192.             IPBlockRule.style.display = "none";
  193.             IPMonitorRule.style.display = "";
  194.             break;
  195.     }
  196. }
  197.  
  198. function OKB_OnClick()
  199. {
  200.     // if the user specified any adapter, nuke the list
  201.     if (Addresses[0].checked)
  202.     {
  203.         xmlIPListPrivate.loadXML("<LocalAddresses/>");
  204.     }
  205.     returnValue = xmlIPListPrivate.documentElement.cloneNode(true);
  206.     xmlIPList.parentNode.replaceChild(returnValue, xmlIPList);
  207.     window.navigate("res://closeme.xyz");
  208. }
  209.  
  210. function CancelB_OnClick()
  211. {
  212.     returnValue = null;
  213.     window.navigate("res://closeme.xyz");
  214. }