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