home *** CD-ROM | disk | FTP | other *** search
/ Your Business Pak / BusinessPak2.iso / Netscape / CD / as.z / asw.jar / register.js < prev    next >
Text File  |  1998-10-15  |  11KB  |  290 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. var    globals = parent.parent.globals;
  21. var plugin = globals.document.setupPlugin;
  22. var documentVars = globals.document.vars;
  23.  
  24. function go( msg )
  25. {
  26.     if ( documentVars.editMode.value == "yes" )
  27.         return true;
  28.     else
  29.         return checkData();
  30. }
  31.  
  32. function checkData()
  33. {
  34.     return true;
  35. }
  36.  
  37. function loadData()
  38. {
  39.     netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" );
  40.  
  41.     if ( parent.controls.generateControls )
  42.         parent.controls.generateControls();
  43.  
  44.     if ( documentVars.editMode.value != "yes" )
  45.     {        // only connect to reggie if editmode is off
  46.  
  47.         var connectStatusFlag = plugin.IsDialerConnected();
  48.         if ( connectStatusFlag == true )
  49.         {
  50.             if ( confirm( "Account Setup can't connect until you close your current connection. Close the connection now?" ) == false )
  51.                 return;
  52.             plugin.DialerHangup();
  53.         }
  54.  
  55.         var language = plugin.GetISPLanguage( globals.selectedISP );
  56.         var acctSetupFile = globals.getAcctSetupFilename( self );
  57.         var acctSetupFolder = globals.getFolder( self ) + "isp/" + language + "/" + globals.selectedISP + "/client_data/config/";
  58.         var regFile = acctSetupFolder + "config.ias.r";
  59.         
  60.         // determine name of scripting file
  61.         var scriptEnabledFlag = "FALSE";
  62.         var scriptFile = globals.GetNameValuePair( regFile, "Dial-In Configuration", "ScriptFileName" );
  63.         if ( scriptFile != null && scriptFile != "" )
  64.         {
  65.             scriptFile = acctSetupFolder + scriptFile;
  66.             scriptEnabledFlag = "TRUE";
  67.         }
  68.         else
  69.         {
  70.             scriptFile = "";
  71.             scriptEnabledFlag = "FALSE";
  72.         }
  73.     
  74.     
  75.         // determine tty
  76.         var ttyFlag = globals.GetNameValuePair( regFile, "Security", "SecurityDevice" );
  77.         ttyFlag = ttyFlag.toLowerCase();
  78.         if ( ttyFlag == "yes" )
  79.             ttyFlag = "TRUE";
  80.         else
  81.             ttyFlag = "FALSE";
  82.             
  83.         // determine outside line access string    
  84.         var outsideLineAccessStr = "";
  85.         if ( documentVars.prefixData.value != "" )
  86.         {
  87.             outsideLineAccessStr = documentVars.prefixData.value;
  88.             x = outsideLineAccessStr.indexOf( "," );
  89.             if ( x < 0 )
  90.                 outsideLineAccessStr = outsideLineAccessStr + ",";
  91.         }
  92.     
  93.         // configure dialer for Registration Server    
  94.         dialerData = plugin.newStringArray( 28 );        // increment this # as new dialer strings are added
  95.         dialerData[0]  = "FileName=" + regFile;
  96.         dialerData[1]  = "AccountName=" + globals.GetNameValuePair( regFile, "Dial-In Configuration", "SiteName" );
  97.         dialerData[2]  = "ISPPhoneNum=" + globals.GetNameValuePair( regFile, "Dial-In Configuration", "Phone" );
  98.         dialerData[3]  = "LoginName=" + globals.GetNameValuePair( regFile, "Dial-In Configuration", "Name" );
  99.         dialerData[4]  = "Password=" + globals.GetNameValuePair( regFile, "Dial-In Configuration", "Password" );
  100.         dialerData[5]  = "DNSAddress=" + globals.GetNameValuePair( regFile, "IP", "DNSAddress" );
  101.         dialerData[6]  = "DNSAddress2=" + globals.GetNameValuePair( regFile, "IP", "DNSAddress2" );
  102.         dialerData[7]  = "DomainName=" + globals.GetNameValuePair( regFile, "IP", "DomainName" );
  103.         dialerData[8]  = "IPAddress=" + globals.GetNameValuePair( regFile, "IP", "IPAddress" );
  104.         dialerData[9]  = "IntlMode=" + ( ( intlFlag=="yes" ) ? "TRUE" : "FALSE" );
  105.         dialerData[10] = "DialOnDemand=TRUE";
  106.         dialerData[11] = "ModemName=" + documentVars.modem.value;
  107.         dialerData[12] = "ModemType=" + plugin.GetModemType( documentVars.modem.value );
  108.         dialerData[13] = "DialType=" + documentVars.dialMethod.value;
  109.         dialerData[14] = "OutsideLineAccess=" + outsideLineAccessStr; 
  110.         dialerData[15] = "DisableCallWaiting=" + ( ( documentVars.cwData.value != "" ) ? "TRUE" : "FALSE" );
  111.         dialerData[16] = "DisableCallWaitingCode=" + documentVars.cwData.value;
  112.         dialerData[17] = "UserAreaCode=" + documentVars.modemAreaCode.value;                // XXX what to do if international mode?
  113.         dialerData[18] = "CountryCode=" + documentVars.countryCode.value;
  114.         dialerData[19] = "LongDistanceAccess=1";                                    // XXX
  115.         dialerData[20] = "DialAsLongDistance=TRUE";                                    // XXX
  116.         dialerData[21] = "DialAreaCode=TRUE";                                        // XXX
  117.         dialerData[22] = "ScriptEnabled=" + scriptEnabledFlag;
  118.         dialerData[23] = "ScriptFileName=" + scriptFile;
  119.         dialerData[24] = "NeedsTTYWindow=" + ttyFlag;
  120.         dialerData[25] = "Location=Home";
  121.          dialerData[26] = "DisconnectTime=" + globals.GetNameValuePair( acctSetupFile, "Mode Selection", "Dialer_Disconnect_After" );
  122.         dialerData[27] = "Path=Server";
  123.     
  124.         // write out dialer data to Java Console
  125.         if ( documentVars.debugMode.value.toLowerCase() == "yes" )
  126.         {
  127.             globals.debug( "\nDialer data (for Registration Server): " );
  128.             var numElements = dialerData.length;
  129.             for ( var x = 0; x < numElements; x++ )
  130.                 globals.debug( "        " + x + ": " + dialerData[ x ] );
  131.         }
  132.     
  133.         plugin.DialerConfig( dialerData, true );
  134.     
  135.         // check if we need to reboot
  136.         
  137.         if ( plugin.NeedReboot() == true )
  138.         {
  139.             globals.forceReboot( "2step.htm" );            // XXX hardcode in name of next screen???
  140.             return;
  141.         }
  142.     
  143.         if ( plugin.DialerConnect() == false )
  144.         {
  145.             plugin.DialerHangup();
  146.             window.location.replace( "error.htm" );        // XXX hardcode in name of next screen???
  147.             return;
  148.         }
  149.     
  150.     
  151.         // get platform (XXX Macintosh should not be uppercased?)
  152.         platform = globals.getPlatform();
  153.         
  154.         if ( platform == "Win16" )
  155.             platform = "WIN31";
  156.         else if ( platform == "Win95" )
  157.             platform = "WIN95";
  158.         else if ( platform == "WinNT" )
  159.             platform = "WINNT";
  160.     
  161.         // get registration server reference
  162.     /*
  163.         var theFolder = parent.parent.globals.getConfigFolder(self);
  164.         var theRegFile = parent.parent.globals.GetNameValuePair(theFile,"New Acct Mode","RegServer");
  165.         var theRegServer = "";
  166.         if (theRegFile == null || theRegFile == "")    {
  167.             theRegFile = parent.parent.globals.document.vars.regServer.value;
  168.             }
  169.         if (theRegFile == null || theRegFile == "")    {
  170.             alert("Internal problem determining the Registration Server.");
  171.             return;
  172.             }    
  173.         theRegFile = theFolder + theRegFile;
  174.     */
  175.         regServer = globals.GetNameValuePair( regFile, "IP", "RegCGI" );
  176.     
  177.         if ( regServer == null || regServer == "" )
  178.         {
  179.             alert( "Internal problem determining the Registration Server." );
  180.             return;
  181.         }
  182.         
  183.         // build TAPI phone number
  184.         var theHomePhone="";
  185.         var thePhone="";
  186.         var theCountry="";
  187.         var intlFlag = parent.parent.globals.GetNameValuePair( acctSetupFile, "Mode Selection", "IntlMode" );
  188.         intlFlag = intlFlag.toLowerCase();
  189.         if ( intlFlag == "yes" )
  190.         {
  191.             theHomePhone = documentVars.phoneNumber.value;
  192.             thePhone = documentVars.modemPhoneNumber.value;
  193.             theCountry = documentVars.country.value;
  194.         }
  195.         else
  196.         {
  197.             theHomePhone = "(" + documentVars.areaCode.value + ") " + documentVars.phoneNumber.value;
  198.             thePhone = "(" + documentVars.modemAreaCode.value + ") " + documentVars.modemPhoneNumber.value;
  199.             theCountry = "USA";
  200.         }
  201.     
  202.         // mangle year and month for submission to registration server
  203.     
  204.         var year = parseInt( documentVars.year.value );
  205.         while ( year >= 100 )
  206.             year -= 100;
  207.         if ( year < 10 )
  208.             year = "0" + year;
  209.     
  210.         var month = parseInt( documentVars.month.value );
  211.         month += 1;
  212.     
  213.     // the following values are commented out as the values are set in HTML
  214.     /*
  215.         document.forms[0].RS_FORM_TYPE.value            = "custinfo";
  216.         document.forms[0].REG_SETUP_NAME.value            = "Account Setup";
  217.         document.forms[0].REG_SIGNUP_VERSION.value        = "4.0";
  218.         document.forms[0].REG_SCRIPTING.value            = "Yes";
  219.         document.forms[0].REG_SOURCE.value                = "test";
  220.         document.forms[0].REG_CHANNEL.value                = "";
  221.     */
  222.     
  223.         // fill out custinfo form elements, then submit
  224.     
  225.         document.forms[0].REG_PLATFORM.value            = platform;
  226.         document.forms[0].AS_INTLMODE.value                = intlFlag;
  227.     
  228.         document.forms[0].CST_LAST_NAME.value            = documentVars.last.value;
  229.         document.forms[0].CST_FIRST_NAME.value            = documentVars.first.value;
  230.         document.forms[0].CST_ORGANIZATION_NAME.value    = documentVars.company.value;
  231.         document.forms[0].CST_STREET_1.value            = documentVars.address1.value;
  232.         document.forms[0].CST_STREET_2.value            = documentVars.address2.value;
  233.         document.forms[0].CST_STREET_3.value            = documentVars.address3.value;
  234.         document.forms[0].CST_CITY.value                = documentVars.city.value;
  235.         document.forms[0].CST_STATE_PROVINCE.value        = documentVars.state.value;
  236.         document.forms[0].CST_POSTAL_CODE.value            = documentVars.zip.value;
  237.         document.forms[0].CST_COUNTRY.value                = theCountry;
  238.         document.forms[0].CST_PHONE.value                = thePhone;
  239.         document.forms[0].CST_HOMEPHONE.value            = theHomePhone;        
  240.         document.forms[0].CST_CC_NO.value                = documentVars.cardnumber.value;
  241.         document.forms[0].CST_CC_TYPE.value                = documentVars.cardcode.value;
  242.         document.forms[0].CST_CC_MTH_EXPIRE.value        = month;
  243.         document.forms[0].CST_CC_YEAR_EXPIRE.value        = year;
  244.         document.forms[0].CST_CC_CARDHOLDER.value        = documentVars.cardname.value;
  245.         document.forms[0].CST_JUNK_MAIL.value            = "";            // XXX
  246.     
  247.         document.forms[0].action = regServer;
  248.         
  249.         // for win32 platforms make sure we don't get ISP's with scripting
  250.         if ( ( platform == "WIN95" ) || ( platform == "WINNT" ) )
  251.             document.forms[0].REG_SCRIPTING.value        = "No";
  252.  
  253.         // declare animation support for appropriate platform
  254.         if ( platform == "Macintosh" )
  255.         {
  256.             document.forms[0].AS_MAC_ANIMATION_SUPPORT.value = "YES";
  257.             document.forms[0].AS_WIN_ANIMATION_SUPPORT.value = "NO";
  258.         }
  259.         else
  260.         {
  261.             document.forms[0].AS_MAC_ANIMATION_SUPPORT.value = "NO";
  262.             document.forms[0].AS_WIN_ANIMATION_SUPPORT.value = "YES";
  263.         }
  264.  
  265.  
  266.         // write out Milan data to Java Console
  267.         if ( documentVars.debugMode.value.toLowerCase() == "yes" )
  268.         {
  269.             globals.debug( "\nRegServer (Milan) data: " + document.forms[ 0 ].action );
  270.             var numElements = document.forms[ 0 ].length;
  271.             for ( var x = 0; x < document.forms[ 0 ].length; x++ )
  272.                 globals.debug( "        " + x + ": " + document.forms[ 0 ].elements[ x ].name + "=" + document.forms[ 0 ].elements[ x ].value );
  273.         }
  274.     
  275.         // submit Milan data
  276.         navigator.preference( "security.warn_submit_insecure", false );
  277.         navigator.preference( "security.warn_entering_secure", false );
  278.         navigator.preference( "security.warn_leaving_secure", false );
  279.  
  280.         parent.parent.globals.setRegisterMode( 1 );
  281.         document.forms[ 0 ].submit();                                        // automatically submit form to registration server
  282.     }
  283. }
  284.  
  285. function saveData()
  286. {
  287. }
  288.  
  289. // end hiding contents from old browsers  -->
  290.