home *** CD-ROM | disk | FTP | other *** search
/ Your Business Pak / BusinessPak2.iso / Netscape / CD / as.z / asw.jar / useAcct.js < prev    next >
Text File  |  1998-10-15  |  12KB  |  327 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. var globals = parent.parent.globals;
  22.  
  23. function go(msg)
  24. {
  25.     if (globals.document.vars.editMode.value == "yes")    {
  26.         return(true);
  27.         }
  28.     else    {
  29.         return(checkData());
  30.         }
  31. }
  32.  
  33.  
  34.  
  35. function checkData()
  36. {
  37.     var theIndex = document.forms[0].providerlist.selectedIndex;
  38.     if (theIndex < 0)    {
  39.         alert("Please select from the list before continuing.");
  40.         globals.setFocus(document.forms[0].providerlist);
  41.         return(false);
  42.         }
  43.     var theProviderName = document.forms[0].providerlist.options[theIndex].text;
  44.     var theProviderFilename = document.forms[0].providerlist.options[theIndex].value;
  45.     if (theProviderFilename == "")    {
  46.         theProviderName = "";
  47.         globals.debug("User chose none of the above.");
  48.         }
  49.     else    {
  50.         globals.debug("ISP Name: " + theProviderName);
  51.         globals.debug("ISP Filename: " + theProviderFilename);
  52.         }
  53.     return(true);
  54. }
  55.  
  56.  
  57.  
  58. function loadData()
  59. {
  60.     // make sure all data objects/element exists and valid; otherwise, reload.
  61.  
  62.     if ((document.forms[0].providerlist == "undefined") || (document.forms[0].providerlist == "[object InputArray]"))    {
  63.         parent.controls.reloadDocument();
  64.         return;
  65.         }
  66.  
  67.     globals.setFocus(document.forms[0].providerlist);
  68.     if (parent.controls.generateControls)    parent.controls.generateControls();
  69. }
  70.  
  71.  
  72.  
  73. function saveData()
  74. {
  75.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  76.  
  77.     // make sure all data objects/element exists and valid; otherwise, reload.
  78.  
  79.     if ((document.forms[0].providerlist == "undefined") || (document.forms[0].providerlist == "[object InputArray]"))    {
  80.         parent.controls.reloadDocument();
  81.         return;
  82.         }
  83.  
  84.     var theFile = globals.getAcctSetupFilename(self);
  85.     var intlFlag = globals.GetNameValuePair(theFile,"Mode Selection","IntlMode");
  86.     if (intlFlag != null && intlFlag != "")    {
  87.         intlFlag = intlFlag.toLowerCase();
  88.         }
  89.  
  90.     var theProviderName = "";
  91.     var theProviderFilename = "";
  92.     if (document.forms[0].providerlist.selectedIndex >=0)    {
  93.         theProviderName = document.forms[0].providerlist.options[document.forms[0].providerlist.selectedIndex].text;
  94.         theProviderFilename = document.forms[0].providerlist.options[document.forms[0].providerlist.selectedIndex].value;
  95.         if (theProviderFilename == "")    {
  96.             theProviderName = "";
  97.             }
  98.         }
  99.     globals.document.vars.providername.value = theProviderName;
  100.     globals.document.vars.providerFilename.value = theProviderFilename;
  101.  
  102.     // clear fields before reading in data from .NCI file
  103.     
  104.     globals.document.vars.accountAreaCode.value = "";
  105.     globals.document.vars.accountPhoneNumber.value = "";
  106.     globals.document.vars.domainName.value = "";
  107.     globals.document.vars.primaryDNS.value = "";
  108.     globals.document.vars.secondaryDNS.value = "";
  109.     globals.document.vars.ipAddress.value = "";
  110.     globals.document.vars.SMTP.value = "";
  111.     globals.document.vars.mailServer.value = "";
  112.     globals.document.vars.mailProtocol.value = "";
  113.     globals.document.vars.NNTP.value = "";
  114.     globals.document.vars.publishURL.value = "";
  115.     globals.document.vars.publishPassword.value = "";
  116.     globals.document.vars.viewURL.value = "";
  117.     globals.document.vars.scriptEnabled.value = "";
  118.     globals.document.vars.scriptFile.value = "";
  119.     globals.document.vars.lckFilename.value = "";
  120.  
  121.     var data="";
  122.     if (theProviderFilename != "")    {
  123.         
  124.         // read default values from selected .NCI file
  125.  
  126.         data = "" + globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Dial-In Configuration","Phone");
  127.         if (data != null && data != "")    {
  128.             globals.document.vars.accountAreaCode.value = "";
  129.             globals.document.vars.accountPhoneNumber.value = data;
  130.             if (intlFlag != "yes")    {
  131.                 var x = data.indexOf("(");
  132.                 if (x>=0)    {
  133.                     var y = data.indexOf(")");
  134.                     if (y>x)    {
  135.                         var areaCode = data.substring(x+1,y);
  136.                         data = data.substring(y+1,data.length);
  137.                         if (data.charAt(0) == ' ')    {
  138.                             data = data.substring(1,data.length);
  139.                             }
  140.                         globals.document.vars.accountAreaCode.value = areaCode;
  141.                         globals.document.vars.accountPhoneNumber.value = data;
  142.                         }
  143.                     }
  144.                 }
  145.             }
  146.  
  147.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"IP","DomainName");
  148.         globals.debug("ISP DomainName: " + data);
  149.         globals.document.vars.domainName.value = data;
  150.  
  151.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"IP","DNSAddress");
  152.         globals.debug("ISP DNSAddress: " + data);
  153.         globals.document.vars.primaryDNS.value = data;
  154.  
  155.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"IP","DNSAddress2");
  156.         globals.debug("ISP DNSAddress2: " + data);
  157.         globals.document.vars.secondaryDNS.value = data;
  158.  
  159.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"IP","IPAddress");
  160.         globals.debug("ISP IPAddress: " + data);
  161.         globals.document.vars.ipAddress.value = data;
  162.  
  163.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","SMTP_Server");
  164.         globals.debug("ISP smtpHost: " + data);
  165.         globals.document.vars.SMTP.value = data;
  166.  
  167.         globals.document.vars.mailServer.value = "";
  168. /*
  169.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","POP_Server");
  170.         globals.debug("ISP popHost: " + data);
  171.         globals.document.vars.POP.value = data;
  172.  
  173.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","IMAP_Server");
  174.         globals.debug("ISP imapHost: " + data);
  175.         globals.document.vars.IMAP.value = data;
  176. */
  177.  
  178.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","Default_Mail_Protocol");
  179.         globals.debug("ISP Default_Mail_Protocol: " + data);
  180.         globals.document.vars.mailProtocol.value = data;
  181.  
  182.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","NNTP_Server");
  183.         globals.debug("ISP nntpHost: " + data);
  184.         globals.document.vars.NNTP.value = data;
  185.  
  186. /*
  187.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services","NUM_LDAP_Servers");
  188.         if (data != null && data != "")    {
  189.             var numLDAPHosts = parseInt(data);
  190.             if (numLDAPHosts>0)    {
  191.                 var LDAPdata = "";
  192.                 for (var x=1; x<=numLDAPHosts; x++)    {
  193.                     var theLDAPstring = "LDAP_Server_" + x;
  194.                     data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Services",theLDAPstring);
  195.                     if (data != null && data != "")    {
  196.                         globals.debug("ISP LDAP_Server_" + x + ": " + data);
  197.                         LDAPdata += data + "\r";
  198.                         }
  199.                     }
  200.                 globals.document.vars.LDAP.value = LDAPdata;
  201.                 }
  202.             }
  203. */
  204.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Publishing","Publish_URL");
  205.         globals.debug("ISP Publish_URL: " + data);
  206.         globals.document.vars.publishURL.value = data;
  207.  
  208.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Publishing","Publish_Password");
  209.         globals.debug("ISP Publish_Password: " + data);
  210.         globals.document.vars.publishPassword.value = data;
  211.  
  212.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Publishing","View_URL");
  213.         globals.debug("ISP View_URL: " + data);
  214.         globals.document.vars.viewURL.value = data;
  215.     
  216.         // scripting support
  217.     
  218.         var theScriptFile = "";
  219.         var theScriptEnabledFlag = "FALSE";
  220.         data = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Script","ScriptEnabled");
  221.         if (data != null && data != "")    {
  222.             data = data.toLowerCase();
  223.             }
  224.         if (data == "yes")    {
  225.             theScriptFile = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Script","ScriptFileName");
  226.             if (theScriptFile != null && theScriptFile != "")    {
  227.                 theScriptEnabledFlag = "TRUE";
  228.                 theScriptFile = globals.getConfigFolder(self) + theScriptFile;
  229.                 globals.debug("ISP ScriptFileName: " + theScriptFile);
  230.                 }
  231.             }
  232.         globals.document.vars.scriptEnabled.value = theScriptEnabledFlag;
  233.         globals.document.vars.scriptFile.value = theScriptFile;
  234.     
  235.         // profile lockfile support
  236.         
  237.         globals.document.vars.lckFilename.value = globals.document.setupPlugin.GetNameValuePair(theProviderFilename,"Configuration","ConfigurationFileName");
  238.         }
  239. }
  240.  
  241.  
  242.  
  243. function ISP(theProviderFilename,name)
  244. {
  245.     this.theProviderFilename=theProviderFilename;
  246.     this.name=name;
  247. }
  248.  
  249.  
  250.  
  251. function ISPcompare(a,b)
  252. {
  253.     if (a.name < b.name)    return(-1);
  254.     else if (a.name == b.name)    return(0);
  255.     return(1);
  256. }
  257.  
  258.  
  259.  
  260. function generateISPList()
  261. {
  262.     netscape.security.PrivilegeManager.enablePrivilege( "AccountSetup" );
  263.     
  264.     for ( x = document.forms[ 0 ].providerlist.length; x >= 0; x-- )
  265.         document.forms[ 0 ].providerlist[ x ] = null;
  266.     
  267.     var theAcctSetupFile = globals.getAcctSetupFilename( self );
  268.     var showPhonesFlag = globals.GetNameValuePair( theAcctSetupFile, "Existing Acct Mode", "ShowPhones" );
  269.     if ( showPhonesFlag != null && showPhonesFlag != "" )
  270.         showPhonesFlag = showPhonesFlag.toLowerCase();
  271.     
  272.     var pathName = globals.getConfigFolder( self );
  273.     //globals.debug( "path: " + pathName );
  274.     
  275.     var theList = globals.document.setupPlugin.GetFolderContents( pathName, ".NCI" );
  276.     
  277.     if ( theList != null )
  278.     {
  279.         //globals.debug( "GetFolderContents returned " + theList.length + " items" );
  280.     
  281.         var name = "";
  282.         var ISParray = new Array();
  283.         for ( var i = 0, j = 0; i < theList.length; i++ )
  284.         {
  285.             var theProviderFilename = pathName + theList[ i ];
  286.             //globals.debug( "theProviderFilename " + i + ": " +theProviderFilename );
  287.     
  288.             name = "";
  289.             if ( showPhonesFlag == "yes" )
  290.                 name = globals.document.setupPlugin.GetNameValuePair( theProviderFilename, "Dial-In Configuration", "Phone" );
  291.             if ( name == null || name == "" )
  292.                 name = globals.document.setupPlugin.GetNameValuePair( theProviderFilename, "Dial-In Configuration", "SiteName" );
  293.             //globals.debug( "name: " + name );
  294.  
  295.             if ( theProviderFilename != null && theProviderFilename != "" && name != null && name != "" )
  296.                 ISParray[ j++ ] = new ISP( theProviderFilename, name );
  297.         }
  298.     }
  299.     
  300.     // un-comment the following line to sort the ISP array
  301.     // Note: for large (more than a dozen or so) lists, this is AMAZINGLY slow
  302.     // (unsorted data takes seconds; sorted data can take more than a minute)
  303.     
  304.     //        ISParray.sort(ISPcompare);
  305.     
  306.     for ( var x = 0; x < ISParray.length; x++ )
  307.     {
  308.         var y = document.forms[ 0 ].providerlist.length;
  309.         document.forms[ 0 ].providerlist.options[ y ] = new Option( ISParray[ x ].name, ISParray[ x ].theProviderFilename, false, false );
  310.         document.forms[ 0 ].providerlist.options[ y ].selected = ( ( ISParray[ x ].name == globals.document.vars.providername.value) ? true : false );
  311.     }
  312.     
  313.     var showNoneAboveFlag = globals.document.setupPlugin.GetNameValuePair( theAcctSetupFile, "Existing Acct Mode", "ShowNoneAbove" );
  314.     if ( showNoneAboveFlag != null && showNoneAboveFlag != "" )
  315.         showNoneAboveFlag = showNoneAboveFlag.toLowerCase();
  316.     if ( showNoneAboveFlag != "no" )
  317.     {
  318.         x = document.forms[ 0 ].providerlist.options.length;
  319.         document.forms[ 0 ].providerlist.options[ x ] = new Option( "(None of the above)", "", false, false );
  320.         document.forms[ 0 ].providerlist.options[ x ].selected = false;
  321.     }
  322. }
  323.  
  324.  
  325.  
  326. // end hiding contents from old browsers  -->
  327.