home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Software / Freeware / Programare / paranoia / ParanoiaSetup.exe / Gui / Preferences.js < prev    next >
Text File  |  2005-04-03  |  28KB  |  1,081 lines

  1.  
  2. function OnloadPreferences(){
  3.  
  4.     CommonOnload();
  5.     
  6.     ClearStatusText();
  7.  
  8.     LoadLocalSettings();
  9.     LoadNetworkSettings();
  10.     LoadFirewallSettings();
  11.     LoadConnectionSettings();
  12.     LoadPermHost();
  13.     LoadFilterHost();
  14.     LoadSearchSettings();
  15.     LoadFilterSearchWordList();
  16.     LoadBlockedHosts();
  17.     LoadShareSettings();
  18.     LoadSharedDirs();
  19.     LoadTransferSettings();
  20.     LoadBandwidthSettings();
  21.     LoadGeneralSettings();
  22.     
  23.     
  24.  
  25.     ScreenID.innerHTML=LocalScreenID.innerHTML;
  26. }
  27.  
  28.  
  29. /*
  30.  * function: LoadLocalSettings
  31.  * Description: Loads all the settings of the Local Settings screen
  32.  */
  33. function LoadLocalSettings()
  34. {
  35.     ExecuteCommand("GetForcedIP|SEPERATOR|ForcedIPID");
  36.     ExecuteCommand("GetForcedPort|SEPERATOR|ForcedPortID");
  37.     ExecuteCommand("GetTrayOnMim|SEPERATOR|TrayOnMimID");
  38.     ExecuteCommand("GetTrayOnClose|SEPERATOR|TrayOnCloseID");            
  39.     ExecuteCommand("GetShowSplash|SEPERATOR|ShowSplashID");    
  40.     ExecuteCommand("GetStartAtStatrup|SEPERATOR|StartAtStatrupID");    
  41.     
  42.     
  43.     if(ForcedIPID.innerText != "0.0.0.0")
  44.         ForcedIPInput.value = ForcedIPID.innerText;
  45.     else
  46.         ForcedIPInput.value = "";
  47.     
  48.     
  49.     if(ForcedPortID.innerText != "0")    
  50.         ForcedPortInput.value = ForcedPortID.innerText;
  51.     else
  52.         ForcedPortInput.value = "";
  53.     
  54.         
  55.     if(TrayOnMimID.innerText == "0")
  56.         TrayOnMinInput.checked = false;
  57.     else
  58.         TrayOnMinInput.checked = true;
  59.  
  60.     if(TrayOnCloseID.innerText == "0")
  61.         TrayOnCloseInput.checked = false;
  62.     else
  63.         TrayOnCloseInput.checked = true;
  64.  
  65.     if(ShowSplashID.innerText == "0")
  66.         ShowSplashInput.checked = false;
  67.     else
  68.         ShowSplashInput.checked = true;        
  69.  
  70.     if(StartAtStatrupID.innerText == "0")
  71.         StartAtStatrupInput.checked = false;
  72.     else
  73.         StartAtStatrupInput.checked = true;                
  74.         
  75.         
  76.         
  77.  
  78. }
  79.  
  80.  
  81. /*
  82.  * function: LoadNetworkSettings
  83.  * Description: Loads all the settings of the Network Settings screen
  84.  */
  85. function LoadNetworkSettings()
  86. {
  87.     ExecuteCommand("GetConnectToGnutella|SEPERATOR|ConnectToGnutellaID");
  88.     ExecuteCommand("GetConnectToGnutella2|SEPERATOR|ConnectToGnutella2ID");
  89.     ExecuteCommand("GetAbleUltraOrHub|SEPERATOR|AbleUltraOrHubID");
  90.     ExecuteCommand("GetMaxLeaf|SEPERATOR|MaxLeafID");            
  91.     ExecuteCommand("GetForceUltraPeer|SEPERATOR|ForceUltraPeerID");    
  92.     ExecuteCommand("GetForceG2Hub|SEPERATOR|ForceG2HubID");    
  93.  
  94.     
  95.     MaxLeafInput.value = MaxLeafID.innerText;
  96.     
  97.         
  98.     if(ConnectToGnutellaID.innerText == "0")
  99.         ConnectToGnutellaInput.checked = false;
  100.     else
  101.         ConnectToGnutellaInput.checked = true;
  102.  
  103.     if(ConnectToGnutella2ID.innerText == "0")
  104.         ConnectToGnutella2Input.checked = false;
  105.     else
  106.         ConnectToGnutella2Input.checked = true;
  107.  
  108.     if(AbleUltraOrHubID.innerText == "0")
  109.         AbleUltraOrHubInput.checked = false;
  110.     else
  111.         AbleUltraOrHubInput.checked = true;        
  112.  
  113.     if(ForceUltraPeerID.innerText == "0")
  114.         ForceUltraPeerInput.checked = false;
  115.     else
  116.         ForceUltraPeerInput.checked = true;                
  117.  
  118.     if(ForceG2HubID.innerText == "0")
  119.         ForceG2HubInput.checked = false;
  120.     else
  121.         ForceG2HubInput.checked = true;                
  122.     
  123.     
  124. }
  125.  
  126.  
  127. /*
  128.  * function: LoadFirewallSettings
  129.  * Description: Loads the firewall settings
  130.  */
  131. function LoadFirewallSettings()
  132. {
  133.     ExecuteCommand("GetBehindFirewall|SEPERATOR|BehindFirewallID");
  134.  
  135.             
  136.     if(BehindFirewallID.innerText == "0")
  137.         BehindFirewallInput.checked = false;
  138.     else
  139.         BehindFirewallInput.checked = true;
  140.  
  141.     
  142. }
  143.  
  144. /*
  145.  * function: LoadConnectionSettings
  146.  * Description: Loads the connection settings
  147.  */
  148. function LoadConnectionSettings()
  149. {
  150.     ExecuteCommand("GetAutoConnect|SEPERATOR|AutoConnectID");
  151.     ExecuteCommand("GetChildKeepAtLeastConnections|SEPERATOR|ChildKeepAtLeastConnectionsID");
  152.     ExecuteCommand("GetUltraPeerKeepAtLeastConnections|SEPERATOR|UltraPeerKeepAtLeastConnectionsID");
  153.     ExecuteCommand("GetUltraPeerKeepMaxConnections|SEPERATOR|UltraPeerKeepMaxConnectionsID");            
  154.  
  155.             
  156.     if(AutoConnectID.innerText == "0")
  157.         AutoConnectInput.checked = false;
  158.     else
  159.         AutoConnectInput.checked = true;
  160.         
  161.     ChildKeepAtLeastConnectionsInput.value = ChildKeepAtLeastConnectionsID.innerText;
  162.     UltraPeerKeepAtLeastConnectionsInput.value = UltraPeerKeepAtLeastConnectionsID.innerText;
  163.     UltraPeerKeepMaxConnectionsInput.value = UltraPeerKeepMaxConnectionsID.innerText;
  164.     
  165. }
  166.  
  167.  
  168. /*
  169.  * function: SaveFirewallSettings
  170.  * Description: Saves the firewall settings 
  171.  */
  172. function SaveFirewallSettings()
  173. {
  174.     if(PreferenceForm.BehindFirewallInput.checked == true)
  175.         ExecuteCommand("SaveBehindFirewall|SEPERATOR|1");    
  176.     else
  177.         ExecuteCommand("SaveBehindFirewall|SEPERATOR|0");    
  178.         
  179.     LoadFirewallSettings();
  180.     
  181.     SetStatusText("Data was saved successfully.");
  182. }
  183.  
  184. /*
  185.  * function: SaveConnectionSettings
  186.  * Description: Saves the connection settings
  187.  */
  188. function SaveConnectionSettings()
  189. {
  190.     var lsCommand = "";
  191.     
  192.     if(PreferenceForm.AutoConnectInput.checked == true)
  193.         ExecuteCommand("SaveAutoConnect|SEPERATOR|1");    
  194.     else
  195.         ExecuteCommand("SaveAutoConnect|SEPERATOR|0");    
  196.  
  197.  
  198.     LoadConnectionSettings();
  199.     SetStatusText("Data was saved successfully.");
  200. }
  201.  
  202.  
  203. /*
  204.  * function: SaveNetworkSettings
  205.  * Description: Saves the Local Settings data
  206.  */
  207. function SaveNetworkSettings()
  208. {
  209.     var lsCommand = "";
  210.     
  211.     lsCommand = "SaveMaxLeaf|SEPERATOR|" + PreferenceForm.MaxLeafInput.value;
  212.  
  213.     ExecuteCommand(lsCommand);
  214.     
  215.     
  216.     if(PreferenceForm.ForceG2HubInput.checked == true)
  217.         ExecuteCommand("SaveForceG2Hub|SEPERATOR|1");    
  218.     else
  219.         ExecuteCommand("SaveForceG2Hub|SEPERATOR|0");    
  220.  
  221.  
  222.     if(PreferenceForm.ForceUltraPeerInput.checked == true)
  223.         ExecuteCommand("SaveForceUltraPeer|SEPERATOR|1");
  224.     else
  225.         ExecuteCommand("SaveForceUltraPeer|SEPERATOR|0");
  226.         
  227.     if(PreferenceForm.AbleUltraOrHubInput.checked == true)
  228.         ExecuteCommand("SaveAbleUltraOrHub|SEPERATOR|1");
  229.     else
  230.         ExecuteCommand("SaveAbleUltraOrHub|SEPERATOR|0");        
  231.         
  232.     if(PreferenceForm.ConnectToGnutella2Input.checked == true)
  233.         ExecuteCommand("SaveConnectToGnutella2|SEPERATOR|1");
  234.     else
  235.         ExecuteCommand("SaveConnectToGnutella2|SEPERATOR|0");                
  236.  
  237.     if(PreferenceForm.ConnectToGnutellaInput.checked == true)
  238.         ExecuteCommand("SaveConnectToGnutella|SEPERATOR|1");
  239.     else
  240.         ExecuteCommand("SaveConnectToGnutella|SEPERATOR|0");            
  241.         
  242.     LoadNetworkSettings();
  243.     
  244.     SetStatusText("Data was saved successfully.");
  245.         
  246.     
  247.         
  248.     
  249. }
  250.  
  251.  
  252. /*
  253.  * function: SaveLocalSettings
  254.  * Description: Saves the Network Settings data
  255.  */
  256. function SaveLocalSettings()
  257. {
  258.     var lsCommand = "";
  259.     
  260.     lsCommand = "SaveForcedIP|SEPERATOR|" + PreferenceForm.ForcedIPInput.value;
  261.  
  262.     ExecuteCommand(lsCommand);
  263.     
  264.     lsCommand = "SaveForcedPort|SEPERATOR|" + PreferenceForm.ForcedPortInput.value;
  265.     ExecuteCommand(lsCommand);
  266.     
  267.     if(PreferenceForm.TrayOnMinInput.checked == true)
  268.         ExecuteCommand("SaveTrayOnMim|SEPERATOR|1");    
  269.     else
  270.         ExecuteCommand("SaveTrayOnMim|SEPERATOR|0");    
  271.  
  272.  
  273.     if(PreferenceForm.TrayOnCloseInput.checked == true)
  274.         ExecuteCommand("SaveTrayOnClose|SEPERATOR|1");
  275.     else
  276.         ExecuteCommand("SaveTrayOnClose|SEPERATOR|0");
  277.         
  278.     if(PreferenceForm.ShowSplashInput.checked == true)
  279.         ExecuteCommand("SaveShowSplash|SEPERATOR|1");
  280.     else
  281.         ExecuteCommand("SaveShowSplash|SEPERATOR|0");        
  282.         
  283.     if(PreferenceForm.StartAtStatrupInput.checked == true)
  284.         ExecuteCommand("SaveStartAtStatrup|SEPERATOR|1");
  285.     else
  286.         ExecuteCommand("SaveStartAtStatrup|SEPERATOR|0");                
  287.         
  288.  
  289.     LoadLocalSettings();
  290.     SetStatusText("Data was saved successfully.");
  291.     
  292. }
  293.  
  294.  
  295. /*
  296.  * function: SetStatusText
  297.  * Description: Prints the status text
  298.  */
  299. function SetStatusText(StatusText)
  300. {
  301.     StatusTextID.innerText = StatusText;
  302.     StatusTextID.style.display = "inline";
  303. }
  304.  
  305.  
  306.  
  307. /*
  308.  * function: ClearStatusText
  309.  * Description: Clears the status text
  310.  */
  311. function ClearStatusText()
  312. {
  313.     SetStatusText("");
  314.     StatusTextID.style.display = "none";
  315. }
  316.  
  317. /*
  318.  * function: ShowNetworkSettings
  319.  * Description: Show the network settings and make sure the enable/disable status is in order.
  320.  */
  321. function ShowNetworkSettings()
  322. {
  323.     ScreenID.innerHTML=NetworkScreenID.innerHTML;
  324.     ClearStatusText();
  325.     DoUltraHubEnableDisable();
  326. }
  327.  
  328. /*
  329.  * function: DoUltraHubEnableDisable
  330.  * Description: This function disables or enables MaxLeafInput/ForceUltraPeerInput/ForceG2HubInput 
  331.  * according to its state
  332.  */
  333. function DoUltraHubEnableDisable()
  334. {
  335.  
  336.     if(PreferenceForm.AbleUltraOrHubInput.checked == true)
  337.     {
  338.         PreferenceForm.MaxLeafInput.disabled  = false;
  339.         PreferenceForm.ForceUltraPeerInput.disabled  = false;
  340.         PreferenceForm.ForceG2HubInput.disabled  = false;
  341.     }else
  342.     {
  343.         PreferenceForm.MaxLeafInput.disabled  = true;
  344.         PreferenceForm.ForceUltraPeerInput.disabled  = true;
  345.         PreferenceForm.ForceG2HubInput.disabled  = true;
  346.     }
  347.     
  348. }
  349.  
  350. /*
  351.  * function: AddPermHost
  352.  * Description: Adds a permanent host and update the GUI
  353.  */
  354. function AddPermHost()
  355. {
  356.  
  357.     if((PreferenceForm.PermHostNameInput.value.length >0) && 
  358.        (PreferenceForm.PermPortInput.value.length >0))
  359.     {
  360.         
  361.         if(isNaN(PreferenceForm.PermPortInput.value))
  362.             return;
  363.  
  364.             
  365.         var oVisibleOption = document.createElement("OPTION");
  366.         var lsText = PreferenceForm.PermHostNameInput.value + ":" + PreferenceForm.PermPortInput.value;
  367.  
  368.         var lsCmd = "AddPermHost|SEPERATOR|" + lsText;
  369.         ExecuteCommand(lsCmd);
  370.         
  371.         oVisibleOption.text = lsText;
  372.         oVisibleOption.value= lsText;
  373.         PreferenceForm.HostsList.add(oVisibleOption);
  374.         
  375.         var oHiddenOption = document.createElement("OPTION");
  376.         oHiddenOption.text = lsText;
  377.         oHiddenOption.value= lsText;
  378.         HostsList.options.add(oHiddenOption);
  379.         
  380.     }
  381. }
  382.  
  383. /*
  384.  * function: RemovePermHost
  385.  * Description: Removes a permanent host and update the GUI
  386.  */
  387. function RemovePermHost()
  388. {
  389.     var lnSelectedIndex = PreferenceForm.HostsList.selectedIndex;
  390.     if(lnSelectedIndex>-1)
  391.     {
  392.         var lsCmd = "RemovePermHost|SEPERATOR|" + PreferenceForm.HostsList.value;
  393.         ExecuteCommand(lsCmd);
  394.  
  395.         PreferenceForm.HostsList.options.remove(lnSelectedIndex);
  396.         HostsList.options.remove(lnSelectedIndex);
  397.         
  398.     }
  399.     
  400. }
  401.  
  402. /*
  403.  * function: LoadPermHost
  404.  * Description: Get the hosts list. 
  405.  * PermHostListFunction will be called with an array of hosts list
  406.  */
  407. function LoadPermHost()
  408. {
  409.     ExecuteCommand("LoadPermHost|SEPERATOR|PermHostListFunction");
  410. }
  411.  
  412. /*
  413.  * Function: PermHostListFunction
  414.  * Description: This function is called by the program (as set with LoadPermHost) with the array 
  415.  * of permanent hosts
  416.  */
  417. function PermHostListFunction(ar)
  418. {
  419.     var a = new VBArray(ar);
  420.     var b = a.toArray();
  421.     delete a;
  422.  
  423.     for (i=0; i<b.length; i++) 
  424.     {
  425.         var oOption = document.createElement("OPTION");
  426.         
  427.         oOption.text = b[i];
  428.         oOption.value= b[i];
  429.         HostsList.add(oOption);
  430.     }
  431. }
  432.  
  433. /*
  434.  * function: LoadFilterHost
  435.  * Description: Get the filtered hosts list. 
  436.  * FilterHostListFunction will be called with an array of hosts list
  437.  */
  438. function LoadFilterHost()
  439. {
  440.     ExecuteCommand("LoadFilterHost|SEPERATOR|FilterHostListFunction");
  441. }
  442.  
  443. /*
  444.  * Function: FilterHostListFunction
  445.  * Description: This function is called by the program (as set with LoadFilterHost) with the array 
  446.  * of filtered hosts
  447.  */
  448. function FilterHostListFunction(ar)
  449. {
  450.     var a = new VBArray(ar);
  451.     var b = a.toArray();
  452.     delete a;
  453.  
  454.     for (i=0; i<b.length; i++) 
  455.     {
  456.         var oOption = document.createElement("OPTION");
  457.         oOption.text = b[i];
  458.         oOption.value= b[i];
  459.         FilterHostsList.add(oOption);
  460.     }
  461. }
  462.  
  463. /*
  464.  * function: AddFilterHost
  465.  * Description: Adds a filtered host and update the GUI
  466.  */
  467. function AddFilterHost()
  468. {
  469.  
  470.     if((PreferenceForm.FilterHostNameInput.value.length >0))
  471.     {
  472.         /* Checking if its a valid IP */
  473.         lsTempIPParts = PreferenceForm.FilterHostNameInput.value.split(".");
  474.         if(lsTempIPParts.length != 4)
  475.             return;
  476.         
  477.         for(i=0;i<4;i++)
  478.         {
  479.             if(lsTempIPParts[i] != "*")
  480.             {
  481.                 if(isNaN(lsTempIPParts[i]))
  482.                     return;
  483.                 
  484.                 if(parseInt(lsTempIPParts[i]) <0 || parseInt(lsTempIPParts[i]) > 255)
  485.                     return;
  486.             }
  487.         }
  488.         
  489.         /* End of IP text */
  490.         
  491.         
  492.         var oVisibleOption = document.createElement("OPTION");
  493.         
  494.         var lsText = PreferenceForm.FilterHostNameInput.value + ":" + PreferenceForm.FilterRulesList.value;
  495.         
  496.         var lsCmd = "AddFilterHost|SEPERATOR|" + lsText; 
  497.         ExecuteCommand(lsCmd);
  498.         
  499.         oVisibleOption.text = lsText;
  500.         oVisibleOption.value= lsText;
  501.         PreferenceForm.FilterHostsList.add(oVisibleOption);
  502.         
  503.         var oHiddenOption = document.createElement("OPTION");
  504.         oHiddenOption.text = lsText;
  505.         oHiddenOption.value= lsText;
  506.         FilterHostsList.options.add(oHiddenOption);
  507.         
  508.     }
  509. }
  510.  
  511. /*
  512.  * function: RemoveFilterHost
  513.  * Description: Removes a filtered host and update the GUI
  514.  */
  515. function RemoveFilterHost()
  516. {
  517.     var lnSelectedIndex = PreferenceForm.FilterHostsList.selectedIndex;
  518.     if(lnSelectedIndex>-1)
  519.     {
  520.         var lsCmd = "RemoveFilterHost|SEPERATOR|" + PreferenceForm.FilterHostsList.value;
  521.         ExecuteCommand(lsCmd);
  522.  
  523.         PreferenceForm.FilterHostsList.options.remove(lnSelectedIndex);
  524.         FilterHostsList.options.remove(lnSelectedIndex);
  525.         
  526.     }
  527.     
  528. }
  529.  
  530. /*
  531.  * function: LoadSearchSettings
  532.  * Description: Loads the search settings
  533.  */
  534. function LoadSearchSettings()
  535. {
  536.     ExecuteCommand("GetDoubleCheckResults|SEPERATOR|DoubleCheckResultsID");
  537.     
  538.     if(DoubleCheckResultsID.innerText == "0")
  539.         DoubleCheckResultsInput.checked = false;
  540.     else
  541.         DoubleCheckResultsInput.checked = true;
  542.         
  543.  
  544.     ExecuteCommand("GetDontDisplayFiltered|SEPERATOR|DontDisplayFilteredID");
  545.     
  546.     if(DontDisplayFilteredID.innerText == "0")
  547.         DontDisplayFilteredInput.checked = false;
  548.     else
  549.         DontDisplayFilteredInput.checked = true;        
  550.         
  551. }
  552.  
  553.  
  554. /*
  555.  * function: SaveSearchSettings
  556.  * Description: Saves the search settings
  557.  */
  558. function SaveSearchSettings()
  559. {
  560.     
  561.     if(PreferenceForm.DoubleCheckResultsInput.checked == true)
  562.         ExecuteCommand("SaveDoubleCheckResults|SEPERATOR|1");    
  563.     else
  564.         ExecuteCommand("SaveDoubleCheckResults|SEPERATOR|0");    
  565.         
  566.     if(PreferenceForm.DontDisplayFilteredInput.checked == true)
  567.         ExecuteCommand("SaveDontDisplayFiltered|SEPERATOR|1");    
  568.     else
  569.         ExecuteCommand("SaveDontDisplayFiltered|SEPERATOR|0");    
  570.  
  571.  
  572.     LoadSearchSettings();
  573.     SetStatusText("Data was saved successfully.");
  574. }
  575.  
  576.  
  577.  
  578. /*
  579.  * function: LoadFilterSearchWordList
  580.  * Description: Get the filtered search words list. 
  581.  * FilterSearchWordListFunction will be called with an array of filtered words list
  582.  */
  583. function LoadFilterSearchWordList()
  584. {
  585.     ExecuteCommand("LoadFilterSearchWordList|SEPERATOR|FilterSearchWordListFunction");
  586. }
  587.  
  588.  
  589. /*
  590.  * Function: FilterSearchWordListFunction
  591.  * Description: This function is called by the program (as set with LoadFilterSearchWordList) with the array 
  592.  * of filtered search words
  593.  */
  594. function FilterSearchWordListFunction(ar)
  595. {
  596.     var a = new VBArray(ar);
  597.     var b = a.toArray();
  598.     delete a;
  599.  
  600.     for (i=0; i<b.length; i++) 
  601.     {
  602.         var oOption = document.createElement("OPTION");
  603.         oOption.text = b[i];
  604.         oOption.value= b[i];
  605.         FilterSearchWordList.add(oOption);
  606.     }
  607. }
  608.  
  609. /*
  610.  * function: AddFilterSearchWord
  611.  * Description: Adds a word to filter and update the GUI
  612.  */
  613. function AddFilterSearchWord()
  614. {
  615.  
  616.     if((PreferenceForm.FilterSearchWordInput.value.length >0))
  617.     {
  618.         var oVisibleOption = document.createElement("OPTION");
  619.         
  620.         var lsCmd = "AddFilterSearchWord|SEPERATOR|" + PreferenceForm.FilterSearchWordInput.value;
  621.         ExecuteCommand(lsCmd);
  622.         
  623.         oVisibleOption.text = PreferenceForm.FilterSearchWordInput.value;
  624.         oVisibleOption.value= PreferenceForm.FilterSearchWordInput.value;
  625.         PreferenceForm.FilterSearchWordList.add(oVisibleOption);
  626.         
  627.         var oHiddenOption = document.createElement("OPTION");
  628.         oHiddenOption.text = PreferenceForm.FilterSearchWordInput.value;
  629.         oHiddenOption.value= PreferenceForm.FilterSearchWordInput.value;
  630.         FilterSearchWordList.options.add(oHiddenOption);
  631.         
  632.     }
  633. }
  634.  
  635. /*
  636.  * function: RemoveFilterSearchWord
  637.  * Description: Removes a filtered word and update the GUI
  638.  */
  639. function RemoveFilterSearchWord()
  640. {
  641.     var lnSelectedIndex = PreferenceForm.FilterSearchWordList.selectedIndex;
  642.     if(lnSelectedIndex>-1)
  643.     {
  644.         var lsCmd = "RemoveFilterSearchWord|SEPERATOR|" + PreferenceForm.FilterSearchWordList.value;
  645.         ExecuteCommand(lsCmd);
  646.  
  647.         PreferenceForm.FilterSearchWordList.options.remove(lnSelectedIndex);
  648.         FilterSearchWordList.options.remove(lnSelectedIndex);
  649.         
  650.     }
  651.     
  652. }
  653.  
  654. /*
  655.  * function: LoadBlockedHosts
  656.  * Description: Get the blocked hosts list. 
  657.  * BlockedHostListFunction will be called with an array of blocked hosts
  658.  */
  659. function LoadBlockedHosts()
  660. {
  661.     ExecuteCommand("LoadBlockedHosts|SEPERATOR|BlockedHostListFunction");
  662. }
  663.  
  664. /*
  665.  * Function: BlockedHostListFunction
  666.  * Description: This function is called by the program (as set with LoadBlockedHosts) with the array 
  667.  * of blocked hosts
  668.  */
  669. function BlockedHostListFunction(ar)
  670. {
  671.     var a = new VBArray(ar);
  672.     var b = a.toArray();
  673.     delete a;
  674.     
  675.     var optStrings = new Array(b.length);
  676.  
  677.     /* From:
  678.        PRB: CreateElement() for SELECT Options Is Slow in Internet Explorer 5 
  679.        ID: Q255610.
  680.     */
  681.     for (i=0; i<b.length; i++) 
  682.     {
  683.         optStrings[i] = "<option value=\"" + b[i] + "\">" + b[i] + "</option>";
  684.     }
  685.  
  686.     BlockHostsListID.innerHTML  = "<select name='BlockHostsList' size='15' style='width:40ex' >" + optStrings.join()  + "</select>";
  687. }
  688.  
  689. /*
  690.  * function: AddBlockedHost
  691.  * Description: Adds a blocked host and update the GUI
  692.  */
  693. function AddBlockedHost()
  694. {
  695.  
  696.     if((PreferenceForm.HostRangeInput.value.length >0) &&
  697.        (PreferenceForm.HostBlockReasonInput.value.length >0))
  698.     {
  699.         
  700.         
  701.         var oVisibleOption = document.createElement("OPTION");
  702.         
  703.         var lsTxt = PreferenceForm.HostRangeInput.value + ":" + PreferenceForm.HostBlockReasonInput.value;
  704.         var lsCmd = "AddBlockedHost|SEPERATOR|" + lsTxt;
  705.         ExecuteCommand(lsCmd);
  706.         
  707.         oVisibleOption.text = lsTxt;
  708.         oVisibleOption.value= lsTxt;
  709.         PreferenceForm.BlockHostsList.add(oVisibleOption);
  710.         
  711.         var oHiddenOption = document.createElement("OPTION");
  712.         oHiddenOption.text = lsTxt;
  713.         oHiddenOption.value= lsTxt;
  714.         BlockHostsList.options.add(oHiddenOption);
  715.         
  716.     }
  717. }
  718.  
  719. /*
  720.  * function: RemoveBlockedHost
  721.  * Description: Removes a blocked host
  722.  */
  723. function RemoveBlockedHost()
  724. {
  725.     var lnSelectedIndex = PreferenceForm.BlockHostsList.selectedIndex;
  726.     
  727.     if(lnSelectedIndex>-1)
  728.     {
  729.         var lsCmd = "RemoveBlockedHost|SEPERATOR|" + PreferenceForm.BlockHostsList.value;
  730.         ExecuteCommand(lsCmd);
  731.  
  732.         PreferenceForm.BlockHostsList.options.remove(lnSelectedIndex);
  733.         BlockHostsList.options.remove(lnSelectedIndex);
  734.         
  735.     }
  736.     
  737. }
  738.  
  739. /*
  740.  * function: LoadShareSettings
  741.  * Description: Loads the share settings
  742.  */
  743. function LoadShareSettings()
  744. {
  745.     ExecuteCommand("GetMaxReply|SEPERATOR|MaxReplyID");
  746.     
  747.     MaxReplyInput.value = MaxReplyID.innerText;
  748.         
  749.  
  750.     ExecuteCommand("GetSendResultsWhenAvailable|SEPERATOR|SendResultsWhenAvailableID");
  751.     
  752.     if(SendResultsWhenAvailableID.innerText == "0")
  753.         SendResultsWhenAvailableInput.checked = false;
  754.     else
  755.         SendResultsWhenAvailableInput.checked = true;    
  756.  
  757.     ExecuteCommand("GetIncludePath|SEPERATOR|IncludePathID");
  758.     
  759.     if(IncludePathID.innerText == "0")
  760.         IncludePathInput.checked = false;
  761.     else
  762.         IncludePathInput.checked = true;        
  763.         
  764.     ExecuteCommand("GetHashSpeed|SEPERATOR|HashSpeedID");
  765.     HashSpeedInput.value = HashSpeedID.innerText;    
  766.         
  767.         
  768.         
  769. }
  770.  
  771.  
  772. /*
  773.  * function: SaveSharingSettings
  774.  * Description: Saves the share Settings data
  775.  */
  776. function SaveSharingSettings()
  777. {
  778.     var lsCommand = "";
  779.     
  780.     lsCommand = "SaveMaxReply|SEPERATOR|" + PreferenceForm.MaxReplyInput.value;
  781.     ExecuteCommand(lsCommand);
  782.     
  783.     lsCommand = "SaveHashSpeed|SEPERATOR|" + PreferenceForm.HashSpeedInput.value;
  784.     ExecuteCommand(lsCommand);
  785.     
  786.     if(PreferenceForm.IncludePathInput.checked == true)
  787.         ExecuteCommand("SaveIncludePath|SEPERATOR|1");    
  788.     else
  789.         ExecuteCommand("SaveIncludePath|SEPERATOR|0");    
  790.  
  791.  
  792.     if(PreferenceForm.SendResultsWhenAvailableInput.checked == true)
  793.         ExecuteCommand("SaveSendResultsWhenAvailable|SEPERATOR|1");
  794.     else
  795.         ExecuteCommand("SaveSendResultsWhenAvailable|SEPERATOR|0");
  796.         
  797.     LoadShareSettings();
  798.     SetStatusText("Data was saved successfully.");
  799.     
  800.  
  801. }
  802.  
  803. /*
  804.  * function: LoadSharedDirs
  805.  * Description: Get the shared directories list. 
  806.  * SharedDirsFunction will be called with an array of shared dirs
  807.  */
  808. function LoadSharedDirs()
  809. {
  810.     ExecuteCommand("LoadSharedDirs|SEPERATOR|SharedDirsFunction");
  811. }
  812.  
  813. /*
  814.  * Function: SharedDirsFunction
  815.  * Description: This function is called by the program (as set with LoadSharedDirs) with the array 
  816.  * of shared dirs
  817.  */
  818. function SharedDirsFunction(ar)
  819. {
  820.     var a = new VBArray(ar);
  821.     var b = a.toArray();
  822.     delete a;
  823.  
  824.     for (i=0; i<b.length; i++) 
  825.     {
  826.         var oOption = document.createElement("OPTION");
  827.         
  828.         oOption.text = b[i];
  829.         oOption.value= b[i];
  830.         SharedDirList.add(oOption);
  831.     }
  832. }
  833.  
  834. /*
  835.  * function: AddSharedDir
  836.  * Description: Adds a shared directory 
  837.  */
  838. function AddSharedDir()
  839. {
  840.     var lsCmd;
  841.     if(PreferenceForm.SubDirectoriesInput.checked == true)
  842.         lsCmd = "AddSharedDir|SEPERATOR|SharedDirID|SEPERATOR|1";
  843.     else
  844.         lsCmd = "AddSharedDir|SEPERATOR|SharedDirID|SEPERATOR|0";
  845.         
  846.     ExecuteCommand(lsCmd);    
  847.  
  848.  
  849.     if(SharedDirID.innerText.length>0)
  850.     {
  851.         var oOption = document.createElement("OPTION");
  852.         
  853.         oOption.text = SharedDirID.innerText;
  854.         oOption.value= SharedDirID.innerText;
  855.         PreferenceForm.SharedDirList.add(oOption);
  856.         
  857.         SharedDirID.innerText = "";
  858.         
  859.     }
  860.  
  861. /*
  862.  * function: RemoveSharedDir
  863.  * Description: Removes a shared directory
  864.  */
  865. function RemoveSharedDir()
  866. {
  867.     var lnSelectedIndex = PreferenceForm.SharedDirList.selectedIndex;
  868.     
  869.     if(lnSelectedIndex>-1)
  870.     {
  871.         var lsCmd = "RemoveSharedDir|SEPERATOR|" + PreferenceForm.SharedDirList.value;
  872.         ExecuteCommand(lsCmd);
  873.  
  874.         PreferenceForm.SharedDirList.options.remove(lnSelectedIndex);
  875.         SharedDirList.options.remove(lnSelectedIndex);
  876.         
  877.     }
  878. }
  879.  
  880. /*
  881.  * function: LoadTransferSettings
  882.  * Description: Loads the transfer settings
  883.  */
  884. function LoadTransferSettings()
  885. {
  886.     ExecuteCommand("GetSaveDownloadsDir|SEPERATOR|SaveDownloadsDirID");
  887.     SaveDownloadsDirInput.value = SaveDownloadsDirID.innerText;
  888.     
  889.     ExecuteCommand("GetSavePartialsDir|SEPERATOR|SavePartialsDirID");
  890.     SavePartialsDirInput.value = SavePartialsDirID.innerText;
  891.     
  892.     ExecuteCommand("GetMaxSimDownloads|SEPERATOR|MaxSimDownloadsID");
  893.     MaxSimDownloadsInput.value = MaxSimDownloadsID.innerText;
  894.  
  895.     ExecuteCommand("GetMaxSimUploads|SEPERATOR|MaxSimUploadsID");
  896.     MaxSimUploadsInput.value = MaxSimUploadsID.innerText;
  897.         
  898.  
  899.     ExecuteCommand("GetDisableMultiSource|SEPERATOR|DisableMultiSourceID");
  900.     
  901.     if(DisableMultiSourceID.innerText == "0")
  902.         DisableMultiSourceInput.checked = false;
  903.     else
  904.         DisableMultiSourceInput.checked = true;    
  905.         
  906. }
  907.  
  908.  
  909. /*
  910.  * function: SaveTransferSettings
  911.  * Description: Saves the transfer Settings data
  912.  */
  913. function SaveTransferSettings()
  914. {
  915.     var lsCommand = "";
  916.     
  917.     lsCommand = "SaveSaveDownloadsDir|SEPERATOR|" + PreferenceForm.SaveDownloadsDirInput.value;
  918.     ExecuteCommand(lsCommand);
  919.     
  920.     lsCommand = "SaveSavePartialsDir|SEPERATOR|" + PreferenceForm.SavePartialsDirInput.value;
  921.     ExecuteCommand(lsCommand);
  922.     
  923.     lsCommand = "SaveMaxSimDownloads|SEPERATOR|" + PreferenceForm.MaxSimDownloadsInput.value;
  924.     ExecuteCommand(lsCommand);
  925.     
  926.     lsCommand = "SaveMaxSimUploads|SEPERATOR|" + PreferenceForm.MaxSimUploadsInput.value;
  927.     ExecuteCommand(lsCommand);
  928.     
  929.     if(PreferenceForm.DisableMultiSourceInput.checked == true)
  930.         ExecuteCommand("SaveDisableMultiSource|SEPERATOR|1");    
  931.     else
  932.         ExecuteCommand("SaveDisableMultiSource|SEPERATOR|0");    
  933.  
  934.         
  935.     LoadTransferSettings();
  936.     SetStatusText("Data was saved successfully.");
  937.     
  938. }
  939.  
  940. /*
  941.  * function: BrowseDownloadToDir
  942.  * Description: Shows the browse folder dialog and sets the value to 
  943.  * SaveDownloadsDirInput
  944.  */
  945. function BrowseDownloadToDir()
  946. {
  947.     ExecuteCommand("ShowBrowseDialog|SEPERATOR|SaveDownloadsDirID");
  948.     PreferenceForm.SaveDownloadsDirInput.value = SaveDownloadsDirID.innerText;
  949.     
  950. }
  951.  
  952. /*
  953.  * function: BrowsePartrialsDir
  954.  * Description: Shows the browse folder dialog and sets the value to 
  955.  * SaveDownloadsDirInput
  956.  */
  957. function BrowsePartrialsDir()
  958. {
  959.     ExecuteCommand("ShowBrowseDialog|SEPERATOR|SavePartialsDirID");
  960.     PreferenceForm.SavePartialsDirInput.value = SavePartialsDirID.innerText;
  961.     
  962. }
  963.  
  964. /*
  965.  * function: LoadBandwidthSettings
  966.  * Description: Loads the bandwidth settings
  967.  */
  968. function LoadBandwidthSettings()
  969. {
  970.     ExecuteCommand("GetLimitDownload|SEPERATOR|LimitDownloadID");
  971.     LimitDownloadInput.value = LimitDownloadID.innerText;
  972.     
  973.     ExecuteCommand("GetLimitUpload|SEPERATOR|LimitUploadID");
  974.     LimitUploadInput.value = LimitUploadID.innerText;
  975.     
  976.     ExecuteCommand("GetDropDownloadsUnder|SEPERATOR|DropDownloadsUnderID");
  977.     DropDownloadsUnderInput.value = DropDownloadsUnderID.innerText;
  978.  
  979.     ExecuteCommand("GetDropUploadsUnder|SEPERATOR|DropUploadsUnderID");
  980.     DropUploadsUnderInput.value = DropUploadsUnderID.innerText;
  981.  
  982.         
  983. }
  984.  
  985. /*
  986.  * function: SaveBandWidthSettings
  987.  * Description: Saves the bandwidth Settings data
  988.  */
  989. function SaveBandWidthSettings()
  990. {
  991.     var lsCommand = "";
  992.     
  993.     lsCommand = "SaveLimitDownload|SEPERATOR|" + PreferenceForm.LimitDownloadInput.value;
  994.     ExecuteCommand(lsCommand);
  995.     
  996.     lsCommand = "SaveLimitUpload|SEPERATOR|" + PreferenceForm.LimitUploadInput.value;
  997.     ExecuteCommand(lsCommand);
  998.     
  999.     lsCommand = "SaveDropDownloadsUnder|SEPERATOR|" + PreferenceForm.DropDownloadsUnderInput.value;
  1000.     ExecuteCommand(lsCommand);
  1001.     
  1002.     lsCommand = "SaveDropUploadsUnder|SEPERATOR|" + PreferenceForm.DropUploadsUnderInput.value;
  1003.     ExecuteCommand(lsCommand);
  1004.     
  1005.     LoadBandwidthSettings();
  1006.     SetStatusText("Data was saved successfully.");
  1007.     
  1008. }
  1009.  
  1010.  
  1011. /*
  1012.  * function: LoadGeneralSettings
  1013.  * Description: Loads the general settings
  1014.  */
  1015. function LoadGeneralSettings()
  1016. {
  1017.     ExecuteCommand("GetSwitchToTransfer|SEPERATOR|SwitchToTransferID");
  1018.     
  1019.     if(SwitchToTransferID.innerText == "0")
  1020.         SwitchToTransferInput.checked = false;
  1021.     else
  1022.         SwitchToTransferInput.checked = true;    
  1023.         
  1024.     ExecuteCommand("GetOpenMagnetLinks|SEPERATOR|OpenMagnetLinksID");
  1025.     
  1026.     if(OpenMagnetLinksID.innerText == "0")
  1027.         OpenMagnetLinksInput.checked = false;
  1028.     else
  1029.         OpenMagnetLinksInput.checked = true;    
  1030.         
  1031.     ExecuteCommand("GetOpenGnutellaLinks|SEPERATOR|OpenGnutellaLinksID");
  1032.     
  1033.     if(OpenGnutellaLinksID.innerText == "0")
  1034.         OpenGnutellaLinksInput.checked = false;
  1035.     else
  1036.         OpenGnutellaLinksInput.checked = true;    
  1037.     
  1038.     
  1039.     
  1040.     ExecuteCommand("GetRecordsPerPage|SEPERATOR|RecordsPerPageID");
  1041.     RecordsPerPageInput.value = RecordsPerPageID.innerText;
  1042.  
  1043.     
  1044.  
  1045.         
  1046. }
  1047.  
  1048. /*
  1049.  * function: SaveGeneralSettings
  1050.  * Description: Saves the general Settings data
  1051.  */
  1052. function SaveGeneralSettings()
  1053. {
  1054.     var lsCommand = "";
  1055.     
  1056.     if(PreferenceForm.SwitchToTransferInput.checked == true)
  1057.         ExecuteCommand("SaveSwitchToTransfer|SEPERATOR|1");    
  1058.     else
  1059.         ExecuteCommand("SaveSwitchToTransfer|SEPERATOR|0");    
  1060.     
  1061.     if(PreferenceForm.OpenMagnetLinksInput.checked == true)
  1062.         ExecuteCommand("SaveOpenMagnetLinks|SEPERATOR|1");    
  1063.     else
  1064.         ExecuteCommand("SaveOpenMagnetLinks|SEPERATOR|0");    
  1065.     
  1066.     if(PreferenceForm.OpenGnutellaLinksInput.checked == true)
  1067.         ExecuteCommand("SaveOpenGnutellaLinks|SEPERATOR|1");    
  1068.     else
  1069.         ExecuteCommand("SaveOpenGnutellaLinks|SEPERATOR|0");    
  1070.     
  1071.     
  1072.     
  1073.     lsCommand = "SaveRecordsPerPage|SEPERATOR|" + PreferenceForm.RecordsPerPageInput.value;
  1074.     ExecuteCommand(lsCommand);
  1075.     
  1076.     
  1077.     LoadGeneralSettings();
  1078.     SetStatusText("Data was saved successfully.");
  1079.     
  1080. }