home *** CD-ROM | disk | FTP | other *** search
/ Your Business Pak / BusinessPak2.iso / Netscape / CD / as.z / asw.jar / modem1.js < prev    next >
Text File  |  1998-10-15  |  6KB  |  219 lines

  1. /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18. <!--  to hide script contents from old browsers
  19.  
  20. function go( msg )
  21. {
  22.     if ( parent.parent.globals.document.vars.editMode.value == "yes" )
  23.         return true;
  24.     else
  25.         return checkData();
  26. }
  27.  
  28. function checkData()
  29. {
  30.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  31.  
  32.     if (document.forms[0].modem.selectedIndex >= 0) {
  33.         if (parent.parent.globals.document.vars.path.value == "New Path")    {
  34.             var theModem = document.forms[0].modem[document.forms[0].modem.selectedIndex].value;
  35. /*
  36.             var theModemType = parent.parent.globals.document.setupPlugin.GetModemType(theModem);
  37.             if (theModemType != null)    {
  38.                 theModemType = theModemType.toUpperCase();
  39.                 if (theModemType == "ISDN")    {
  40.                     alert("ISDN modems can not be used to connect to the Internet account server.");
  41.                     return(false);
  42.                     }
  43.                 }
  44. */
  45.             if (theModem != "")    {
  46.                 if (theModem.indexOf("ISDN-")>=0)    {            // magic "ISDN-" check
  47.                     alert("ISDN modems can not be used to connect to the Internet account server.");
  48.                     return(false);
  49.                     }
  50.                 }
  51.  
  52.             }
  53.         }
  54.     else    {
  55.         alert("Please select a modem, or install a modem if no modem is installed!");
  56.         return(false);
  57.         }
  58.  
  59.     return(true);
  60. }
  61.  
  62.  
  63.  
  64. function loadData()
  65. {
  66.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  67.  
  68.     var thePlatform = parent.parent.globals.getPlatform();
  69.  
  70.     if ( thePlatform != "WinNT" )
  71.         document.layers[ "ModemSetup" ].visibility = "show";
  72.  
  73.     updateModemStatus( true );
  74.     if ( parent.controls.generateControls )
  75.         parent.controls.generateControls();
  76. }
  77.  
  78.  
  79.  
  80. function saveData()
  81. {
  82.     netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" );
  83.  
  84.     if ( document.forms[ 0 ].modem.selectedIndex >= 0 )
  85.         parent.parent.globals.document.vars.modem.value = document.forms[ 0 ].modem[ document.forms[ 0 ].modem.selectedIndex ].value;
  86.  
  87.     parent.parent.globals.document.setupPlugin.CloseModemWizard();
  88. }
  89.  
  90.  
  91.  
  92. function generateModems()
  93. {
  94.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  95.  
  96.     var modemList = parent.parent.globals.document.setupPlugin.GetModemList();
  97.     var thePopup = document.forms[0]["modem"];
  98.  
  99.     if (modemList != null && thePopup) 
  100.     {
  101.         //remove all old options
  102.         for (var i = (thePopup.length -1); i >= 0 ; i--)
  103.         {
  104.             thePopup.options[i] = null;
  105.         }    
  106.  
  107.         //add the modems
  108.         for(var index = 0; index < modemList.length; index++)
  109.         {
  110.             thePopup.options[thePopup.options.length] = new Option(modemList[index],modemList[index], false, false);
  111.         }
  112.         
  113.         //select the current modem
  114.         selectCurrentModem();
  115.  
  116.     }
  117. }
  118.  
  119.  
  120. function selectCurrentModem()
  121. {
  122.     netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" );
  123.  
  124.     var found = false;
  125.     var thePopup = document.forms[ 0 ][ "modem" ];
  126.     var globalModem = parent.parent.globals.document.vars.modem.value;
  127.     var pluginModem = parent.parent.globals.document.setupPlugin.GetCurrentModemName();
  128.  
  129.     var thePlatform = parent.parent.globals.getPlatform();
  130.  
  131.     var selectIndex = 0;
  132.     if ( thePlatform != "Macintosh" )        // work around for window's list index bug
  133.         selectIndex = thePopup.options.length - 1;
  134.  
  135.     //alert("globalModem: " + globalModem + ", pluginModem: " + pluginModem);
  136.     for( var index = 0; index < thePopup.options.length; index ++ )
  137.     {
  138.         if ( ( globalModem == thePopup.options[ index ] ) || ( selectIndex == 0 && pluginModem == thePopup.options[ index ] ) )
  139.             selectIndex = index;
  140.     }
  141.  
  142.     thePopup.options[ selectIndex ].selected = true;    
  143. }
  144.  
  145. function OLDgenerateModems()
  146. {
  147.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  148.  
  149.     var modemList = parent.parent.globals.document.setupPlugin.GetModemList();
  150.  
  151.     if (modemList != null) {
  152.         var theModem = parent.parent.globals.document.vars.modem.value;
  153.         var selectedStr = "";
  154.  
  155.         for (var x=0; x<modemList.length; x++)    {
  156.             if (modemList[x] == theModem)    {
  157.                 selectedStr=" SELECTED";
  158.                 }
  159.             else    {
  160.                 selectedStr="";
  161.                 }
  162.             document.writeln("<OPTION VALUE='" + modemList[x] + "'" + selectedStr + ">" + modemList[x]);
  163.             }
  164.     }
  165. }
  166.  
  167. function updateModemStatus(loadingFlag)
  168. {
  169.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  170.  
  171.     if (parent.parent.globals.document.setupPlugin.IsModemWizardOpen() == true)    {
  172.         setTimeout("updateModemStatus(false)",1000);
  173.         }
  174.     else    {
  175.         for (x=document.forms[0].modem.length-1; x>=0; x--)    {
  176.             document.forms[0].modem.options[x]=null;
  177.             }
  178.  
  179.     if (loadingFlag == false)    {
  180.         var selectedModem=parent.parent.globals.document.setupPlugin.GetCurrentModemName();
  181.         if (selectedModem != null && selectedModem != "")    {
  182.             parent.parent.globals.document.vars.modem.value = selectedModem;
  183.             }
  184.         }
  185.  
  186.     var theModem = parent.parent.globals.document.setupPlugin.GetModemList();
  187.     if (theModem != null)    {
  188.         var theSelectedIndex=-1;
  189.         for (x=0; x<theModem.length; x++)    {
  190.             var selectedFlag = (parent.parent.globals.document.vars.modem.value==theModem[x]);
  191.         if (selectedFlag==true)    theSelectedIndex=x;
  192.             document.forms[0].modem.options[x] = new Option(theModem[x],theModem[x],selectedFlag,selectedFlag);
  193.             }
  194.         if (theSelectedIndex>=0)    {
  195.             document.forms[0].modem.selectedIndex=theSelectedIndex;
  196.             }
  197.         }
  198.     
  199.     //generateModems();
  200.     
  201.     }
  202. }
  203.  
  204. function callModemWizard()
  205. {
  206.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  207.  
  208.     if (document.forms[0].modem.selectedIndex >= 0) {
  209.         parent.parent.globals.document.vars.modem.value = document.forms[0].modem[document.forms[0].modem.selectedIndex].value;
  210.     }
  211.     parent.parent.globals.document.setupPlugin.OpenModemWizard();
  212.     setTimeout("updateModemStatus(false)",1000);
  213.     return(false);
  214. }
  215.  
  216.  
  217.  
  218. // end hiding contents from old browsers  -->
  219.