home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / INTERNET / COMMUNIC / AS.Z / register.js < prev    next >
Encoding:
Text File  |  1998-01-22  |  11.4 KB  |  288 lines

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