home *** CD-ROM | disk | FTP | other *** search
/ Online Praxis 1998 March / Image.iso / CD-ROM / NETSCAPE / CCK / ASE.Z / nciglob.js < prev    next >
Encoding:
Text File  |  1997-08-21  |  22.1 KB  |  731 lines

  1. <!--  to hide script contents from old browsers
  2.  
  3. // the file that includes this must also include settings.js!
  4.  
  5. // nciglob.js
  6.  
  7. //THE FOLLOWING FUNCTION IS LOCATION DEPENDANT
  8.  
  9. function refreshConfigFrame(fileName)
  10. {
  11.     if (parent.nci)
  12.     {
  13.         parent.nci.refreshNCIList();
  14.         if (fileName != null)
  15.             parent.nci.setNCIList(fileName);
  16.     } 
  17.     else if (parent.parent.nci)
  18.     {
  19.         parent.parent.nci.refreshNCIList();
  20.         if (fileName != null)
  21.             parent.parent.nci.setNCIList(fileName);
  22.     
  23.     }
  24. }
  25.  
  26. //THE FOLLOWING FUNCTION IS LOCATION DEPENDANT
  27. //returns the filename that we are working with - from the 
  28. //editfield in the parent's "config" frame
  29. //NOT any more, now that we run inside a window, we get the name from 
  30. //ACCTSET.INI
  31. function getNCINameFromOpener()
  32. {
  33.     var outValue = "";
  34.     var tempValue = GetNameValuePair("ACCTSET.INI", "Mode Selection", "ExistingSRFile");
  35.     if ((tempValue != null))
  36.         outValue = tempValue;
  37.     return outValue;
  38. }
  39.  
  40.  
  41. ////////////////Interaction functions////////////////
  42. // these functions are for other files to access and load the global data
  43. // we store in the nciglobals frame
  44.  
  45. function getGlobal(fieldName)
  46. {
  47.     var outValue = "";
  48.     //debug("parent.nciglobals: " + parent.nciglobals);
  49.     //debug("parent.parent.nciglobals: " + parent.parent.nciglobals);
  50.     //debug("parent.parent.parent.nciglobals: " + parent.parent.parent.nciglobals);
  51.     //debug("parent.parent.parent.parent.nciglobals: " + parent.parent.parent.parent.nciglobals);
  52.     if (parent.parent.nciglobals)
  53.     {
  54.         //debug ("option 1: parent.parent.nciglobals " + fieldName);
  55.         outValue = parent.parent.nciglobals.document.nciTempVars[fieldName].value;
  56.         //debug("out: " + outValue);
  57.     }
  58.     else if (parent.nciglobals && parent.nciglobals.document && parent.nciglobals.document.nciTempVars && parent.nciglobals.document.nciTempVars[fieldName])
  59.     {
  60.         //debug ("option 2: parent.nciglobals");
  61.         outValue = parent.nciglobals.document.nciTempVars[fieldName].value;
  62.     }
  63.     else
  64.     {
  65.         //debug("getGlobal - Warning: NCIGLOBALS not found.");
  66.         //debug("parent.nciglobals: " + parent.nciglobals);
  67.         //debug("parent.parent.nciglobals: " + parent.parent.nciglobals);
  68.         //debug("parent.parent.parent.nciglobals: " + parent.parent.parent.nciglobals);
  69.         //debug("parent.parent.parent.parent.nciglobals: " + parent.parent.parent.parent.nciglobals);    
  70.     }
  71.     
  72.     if (outValue == null) outValue = "";
  73.         debug("getGlobal: " + fieldName + " is " + outValue);
  74.  
  75.     return outValue;
  76.     
  77. }
  78.  
  79.  
  80. function setGlobal(fieldName, inValue)
  81. {
  82.     //alert("setGlobal " + fieldName + " " +inValue);
  83.     if (inValue == null)
  84.         inValue = "";
  85.  
  86.     if (parent.parent.nciglobals)
  87.     {
  88.         //debug ("SetGobal: option 1: parent.parent.nciglobals");
  89.         parent.parent.nciglobals.document.nciTempVars[fieldName].value = inValue;
  90.     }
  91.     else if (parent.nciglobals)
  92.     {
  93.         //debug ("SetGobal: option 2: parent.nciglobals");
  94.         parent.nciglobals.document.nciTempVars[fieldName].value = inValue;
  95.     }
  96.     else
  97.     {
  98.         debug("setGlobal - Warning: NCIGLOBALS not found.");
  99.         debug("parent.nciglobals: " + parent.nciglobals);
  100.         debug("parent.parent.nciglobals: " + parent.parent.nciglobals);
  101.         debug("parent.parent.parent.nciglobals: " + parent.parent.parent.nciglobals);
  102.         debug("parent.parent.parent.parent.nciglobals: " + parent.parent.parent.parent.nciglobals);    
  103.     }
  104. }
  105.  
  106. //call this to force a save of the data, and refresh the frames.
  107. function saveAndRefresh()
  108. {
  109.     //alert("in saveandrefresh");
  110.     //flush the current child frame
  111.     if (parent.tabs && parent.tabs.tabbody && parent.tabs.tabbody.saveData)
  112.         parent.tabs.tabbody.saveData();
  113.     else if (parent.parent.tabs.tabbody)
  114.         parent.tabs.tabbody.saveData();
  115.     
  116.     //save the file
  117.     var fileName = saveNewOrOldFile();
  118.     
  119.     //refresh the popup
  120.     if ((fileName != null))
  121.         refreshConfigFrame(fileName);
  122. }
  123.  
  124. //specifies whether the data has been tainted - i.e. whether we should 
  125. // save the data on unload
  126. // usage:     nciDirty(true) sets dirtiness (returns old dirtiness state)
  127. //            nciDirty(false) clears dirtiness (returns old dirtiness state)
  128. //            nciDirty(null) returns current dirtiness state
  129. function nciDirty(inDirt)
  130. {
  131.     var isDirty = getGlobal("GlobalsDirty");
  132.     
  133.     if ((inDirt != null) && (inDirt == true))
  134.         setGlobal("GlobalsDirty", "yes");
  135.     else if ((inDirt != null) && (inDirt == false))
  136.         setGlobal("GlobalsDirty", "no");
  137.         
  138.     if ((isDirty != null) && (isDirty == "yes"))
  139.         return true;
  140.     else
  141.         return false;
  142. }
  143.  
  144.  
  145.  
  146. /////////////End Interaction functions////////////////
  147.  
  148.  
  149. ////////FILE I/O FUNCTIONS/////////
  150.  
  151. //get all the data from some file in the Config folder
  152. //fill in the values in our globals form
  153. function readFileData(fileName)
  154. {
  155.     //alert("in readFileData");
  156.     var saved = saveIfDirty();
  157.     
  158.     debug("saved : " + saved);
  159.     
  160.     if (saved == false)
  161.     {
  162.         var siteName = getGlobal("NciFileName");
  163.         if ((siteName == null) || (siteName == "") || (siteName == "null"))
  164.         {
  165.             siteName = "_new_";
  166.         }
  167.         refreshConfigFrame(siteName);
  168.         return false;
  169.     }
  170.     
  171.     if ((saved != null) && (saved != "") && saved != false)
  172.     {
  173.         refreshConfigFrame(fileName);
  174.     }
  175.  
  176.     
  177.     var tempFlagValue         =     "";
  178.     
  179.     var dicSectionName         =     "Dial-In Configuration";
  180.     var optionsSectionName    =    "Options"
  181.     var scriptSectionName    =    "Script";
  182.     var servicesSectionName    =    "Services";
  183.     var ipSectionName        =    "IP";
  184.  
  185.     //if we decide to support per POP CFG Files, uncomment these lines
  186.     var configurationSectionName    =     "Configuration"; 
  187.     var publishingSectionName =    "Publishing";
  188.  
  189.     //var ipxSectionName        =    "IPX";
  190.     //var netbeuiSectionName    =    "NetBEUI";
  191.     //var securitySectionName    =    "Security";                
  192.     
  193.     if (fileName == null) fileName = "";
  194.     
  195.     setGlobal("NciFileName", fileName);
  196.  
  197.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "SiteName");
  198.     setGlobal("SiteName", tempFlagValue);
  199.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "Description");
  200.     setGlobal("Description", tempFlagValue);
  201.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "Name");
  202.     setGlobal("Name", tempFlagValue);
  203.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "Password");
  204.     setGlobal("Password", tempFlagValue);
  205.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "Phone");
  206.     setGlobal("Phone", tempFlagValue);
  207.     tempFlagValue = GetNameValuePair(fileName, dicSectionName, "SupportPhone");
  208.     setGlobal("SupportPhone", tempFlagValue);
  209.  
  210.     tempFlagValue = GetNameValuePair(fileName, optionsSectionName, "EnableVJCompression");
  211.     setGlobal("EnableVJCompression", tempFlagValue);
  212.  
  213.  
  214. //    Nope, don't need these 3.0 things anymore
  215. //
  216. //    tempFlagValue = GetNameValuePair(fileName, ipxSectionName, "Enabled");
  217. //    setGlobal("IPXEnabled", tempFlagValue);
  218.  
  219.     tempFlagValue = GetNameValuePair(fileName, ipSectionName, "Enabled");
  220.     setGlobal("IPEnabled", tempFlagValue);
  221.     tempFlagValue = GetNameValuePair(fileName, ipSectionName, "IPAddress");
  222.     setGlobal("IPAddress", tempFlagValue);
  223.     tempFlagValue = GetNameValuePair(fileName, ipSectionName, "DomainName");
  224.     setGlobal("DomainName", tempFlagValue);
  225.     tempFlagValue = GetNameValuePair(fileName, ipSectionName, "DNSAddress");
  226.     setGlobal("DNSAddress", tempFlagValue);
  227.     tempFlagValue = GetNameValuePair(fileName, ipSectionName, "DNSAddress2");
  228.     setGlobal("DNSAddress2", tempFlagValue);
  229.     
  230.     // don't _want_ these, in here for legacy reasons - so old files still work
  231.     //actually - we do want them now.
  232.     tempFlagValue = GetNameValuePair(fileName, servicesSectionName, "SMTP_Server");
  233.     setGlobal("SMTP_Server", tempFlagValue);
  234.     tempFlagValue = GetNameValuePair(fileName, servicesSectionName, "NNTP_Server");
  235.     setGlobal("NNTP_Server", tempFlagValue);
  236.     tempFlagValue = GetNameValuePair(fileName, servicesSectionName, "POP_Server");
  237.     setGlobal("POP_Server", tempFlagValue);
  238.     tempFlagValue = GetNameValuePair(fileName, servicesSectionName, "IMAP_Server");
  239.     setGlobal("IMAP_Server", tempFlagValue);
  240.     
  241.     //Maybe we will want this in the near future:
  242.     tempFlagValue = GetNameValuePair(fileName, servicesSectionName, "Default_Mail_Protocol");
  243.     setGlobal("Default_Mail_Protocol", tempFlagValue);
  244.     
  245.  
  246.     tempFlagValue = GetNameValuePair(fileName, publishingSectionName, "Publish_URL");
  247.     setGlobal("Publish_URL", tempFlagValue);
  248.     tempFlagValue = GetNameValuePair(fileName, publishingSectionName, "Publish_Password");
  249.     setGlobal("Publish_Password", tempFlagValue);
  250.     tempFlagValue = GetNameValuePair(fileName, publishingSectionName, "View_URL");
  251.     setGlobal("View_URL", tempFlagValue);
  252.  
  253.  
  254. //    these are things 3.0 used to support that we don't, and things
  255. //    that I thought we might want to support, but currently don't
  256. //
  257. //    setLDAPServers(fileName);
  258. //    
  259. //
  260. //    tempFlagValue = GetNameValuePair(fileName, netbeuiSectionName, "Enabled");
  261. //    setGlobal("NetBEUIEnabled", tempFlagValue);
  262. //
  263. //    tempFlagValue = GetNameValuePair(fileName, securitySectionName, "SecurityDevice");
  264. //    setGlobal("SecurityDevice", tempFlagValue);
  265.  
  266.     tempFlagValue = GetNameValuePair(fileName, scriptSectionName, "ScriptEnabled");
  267.     setGlobal("ScriptEnabled", tempFlagValue);
  268.     tempFlagValue = GetNameValuePair(fileName, scriptSectionName, "ScriptFileName");
  269.     setGlobal("ScriptFileName", tempFlagValue);
  270.     
  271.     //if we decide to support per POP CFG Files, uncomment these lines
  272.     tempFlagValue = GetNameValuePair(fileName, configurationSectionName, "ConfigurationFileName");
  273.     setGlobal("ConfigurationFileName", tempFlagValue);
  274.  
  275.  
  276.     //get the flag from ACCTSET.INI
  277.     tempFlagValue = GetNameValuePair("ACCTSET.INI", "Existing Acct Mode", "RegPodURL");
  278.     setGlobal("RegPodURL", tempFlagValue);
  279.  
  280.     //set the flag in ACCTSET.INI to indicate THIS is the new file
  281.     if (fileName != "_new_")
  282.         SetNameValuePair("ACCTSET.INI", "Mode Selection", "ExistingSRFile", fileName);
  283.  
  284.     //set the dirty bit to clean
  285.     nciDirty(false);
  286.     
  287.     //reload the parent's tabs frame
  288.     debug("parent.tabs: " + parent.tabs);
  289.     debug("parent.parent.tabs: " + parent.parent.tabs);
  290.  
  291.     if (parent.tabs && parent.tabs.tabbody && parent.tabs.tabbody.loadData) 
  292.         parent.tabs.tabbody.loadData();
  293.     else if (parent.parent.tabs && parent.parent.tabs.tabbody && parent.parent.tabs.tabbody.loadData)
  294.         parent.parent.tabs.tabbody.loadData();
  295.         
  296.     return true;
  297. }
  298.  
  299. ////////////FILE NAMING FUNCTIONS/////////////////
  300.  
  301. //helper function for suggesting fileNames
  302. function isAlphaNumeric(inLetter)
  303. {
  304.  
  305.     debug("inAlphaNumeric");
  306.     var outValue = false;
  307.     
  308.     if ((inLetter != null) && (inLetter != ""))
  309.     {
  310.  
  311.         if ((!isNaN(parseInt(inLetter))) && (parseInt(inLetter >= 0)) && (parseInt(inLetter <=9)))
  312.             outValue = true;
  313.         else
  314.         {
  315.             var let = inLetter.toLowerCase();
  316.             if ((let <= "z") && ( let >= "a"))
  317.                 outValue = true;
  318.             else if (let == "_")
  319.                 outValue = true;
  320.         }
  321.     }
  322.     return outValue;
  323. }
  324.  
  325. //takes the first eight non-whitespace characters of SiteName, and turns them into a filename
  326. //ending with a .NCI
  327. function suggestNCIFileName(sName)
  328. {
  329.     
  330.     debug("suggesting");
  331.     if ((sName == null) || (sName == ""))
  332.         sName     =     getGlobal("SiteName");
  333.  
  334.     var nciName =    "";
  335.     
  336.     if ((sName != null) && (sName != ""))
  337.     {
  338.         var len     =     sName.length;
  339.         var finLen    =    0;
  340.         
  341.         for (var i = 0; i < len; i++)
  342.         {
  343.             if (isAlphaNumeric(sName.charAt(i)))
  344.             {
  345.                 nciName = nciName + sName.charAt(i);
  346.                 finLen++;
  347.             }
  348.             if (finLen >= 8)
  349.                 break;
  350.         }
  351.         nciName = (nciName + ".NCI");             
  352.     }
  353.     return nciName;
  354. }
  355.  
  356.  
  357. function checkIfNCIFileExists(inFileName)
  358. {
  359.     var outValue = false;
  360.     
  361.     if ((inFileName != null) && (inFileName != ""))
  362.     {    
  363.         fileList = getFileListFromConfigFolder(".NCI");
  364.         
  365.         if (fileList != null)    
  366.         {
  367.             for (var i=0; i<fileList.length; i++)    
  368.             {
  369.                 if (fileList[i] == inFileName)
  370.                     outValue = true;
  371.             }
  372.         }
  373.     }
  374.     return outValue;
  375. }
  376.  
  377. ////////////////FILE SAVING FUNCTIONS///////////////
  378.  
  379. function askNCIFileNameAndSave()
  380. {
  381.     var sName     =     getGlobal("SiteName");
  382.     var save     =     null;
  383.     
  384.     //flush data from currenly open tab into globals
  385.     if (parent.tabs && parent.tabs.tabbody && parent.tabs.tabbody.saveData)
  386.     {
  387.         parent.tabs.tabbody.saveData();
  388.     }
  389.  
  390.     //first check if there is a sitename, if not, prompt for one
  391.     if ((sName == null) || (sName == ""))
  392.     {
  393.         var pName = prompt("Please enter a name for this configuration (this will be shown to the end user):", "");
  394.         if ((pName != null) && (pName != ""))
  395.         {
  396.             setGlobal("SiteName", pName);
  397.             setGlobal("Description", pName);
  398.             sName = pName;
  399.         }
  400.         else
  401.         {
  402.             save = false;
  403.         }    
  404.     }
  405.     
  406.     //now, if there is a sitename, suggest an NCI fileName, prompt for confirmation
  407.     debug( "about to suggest..." );
  408.     while (save == null)
  409.     {
  410.         debug( "in that while loop..." );
  411.         if ((sName != null) && (sName != ""))
  412.         {
  413.             var sgName = getGlobal("NciFileName");
  414.             if ((sgName == null) || (sgName == "") || (sgName == "_new_"))
  415.                 sgName = suggestNCIFileName(null);
  416.  
  417.             var fName = prompt("Enter the file name for this configuration (must end with .NCI)", sgName);
  418.             
  419.             //if they entered an improper suffix, prompt again, and again
  420.             while ((fName != null) && (fName.substring(fName.length-4, fName.length)  != ".NCI"))
  421.             {
  422.                 sgName = suggestNCIFileName(fName);
  423.                 fName = prompt("Enter the fileName for this configuration (must end with .NCI)", sgName);
  424.             }
  425.             
  426.             // if the name exists, prompt to replace
  427.             
  428.             if ((fName != null) && (checkIfNCIFileExists(fName)))
  429.             {
  430.                 var conf = confirm("The file: " + fName + " already exists.  Replace?");
  431.                 if (conf)
  432.                 { 
  433.                     save = true;
  434.                 }
  435.                 else
  436.                     save = null;
  437.             }
  438.             else if(fName != null)
  439.             {
  440.                 //fileName doesn't exist - we can save
  441.                 save = true;
  442.             }
  443.             else
  444.             {
  445.                 //user canceled - name = null
  446.                 save = false;        
  447.             }
  448.         }
  449.     }    
  450.     
  451.  
  452.     //now save the file if the user didn't cancel
  453.     if (save == true)
  454.     {
  455.         //save the file
  456.         writeToFile(fName);
  457.         refreshConfigFrame(fName);
  458.         return fName;
  459.     }
  460.     else
  461.     {
  462.         //alert("Could not save this configuration because you did not provide a Name");
  463.         return null;
  464.     }
  465. }
  466.  
  467.  
  468. //writes all data to an existing file
  469. function writeToFile(fileName)
  470. {
  471.     
  472.     // Request privilege
  473.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  474.  
  475.     var dicSectionName         =     "Dial-In Configuration";
  476.     var optionsSectionName    =    "Options"
  477.     var servicesSectionName    =    "Services";
  478.     var scriptSectionName    =    "Script";
  479.     var ipSectionName        =    "IP";
  480.     
  481.     //if we decide to support per POP CFG Files, uncomment these lines
  482.     var configurationSectionName    =     "Configuration"; 
  483.     
  484.     //var ipxSectionName        =    "IPX";
  485.     //var netbeuiSectionName    =    "NetBEUI";
  486.     //var securitySectionName    =    "Security";                
  487.     var publishingSectionName =    "Publishing";
  488.  
  489.     SetNameValuePair(fileName, dicSectionName, "SiteName", getGlobal("SiteName"));
  490.     SetNameValuePair(fileName, dicSectionName, "Description", getGlobal("Description"));
  491.     SetNameValuePair(fileName, dicSectionName, "Name", getGlobal("Name"));
  492.     SetNameValuePair(fileName, dicSectionName, "Password", getGlobal("Password"));
  493.     SetNameValuePair(fileName, dicSectionName, "Phone", getGlobal("Phone"));
  494.     SetNameValuePair(fileName, dicSectionName, "SupportPhone", getGlobal("SupportPhone"));
  495.  
  496.     SetNameValuePair(fileName, optionsSectionName, "EnableVJCompression", getGlobal("EnableVJCompression"));
  497.  
  498.     //Obselete
  499.     //SetNameValuePair(fileName, ipxSectionName, "Enabled", getGlobal("IPXEnabled"));
  500.  
  501.     SetNameValuePair(fileName, ipSectionName, "Enabled", getGlobal("IPEnabled"));
  502.     SetNameValuePair(fileName, ipSectionName, "IPAddress", getGlobal("IPAddress"));
  503.     SetNameValuePair(fileName, ipSectionName, "DomainName", getGlobal("DomainName"));
  504.     SetNameValuePair(fileName, ipSectionName, "DNSAddress", getGlobal("DNSAddress"));
  505.     SetNameValuePair(fileName, ipSectionName, "DNSAddress2", getGlobal("DNSAddress2"));
  506.     
  507.     //don't really want to keep these around, just here for backwards compatibility,
  508.     // they are not exposed in the UI
  509.     SetNameValuePair(fileName, servicesSectionName, "SMTP_Server", getGlobal("SMTP_Server"));
  510.     SetNameValuePair(fileName, servicesSectionName, "NNTP_Server", getGlobal("NNTP_Server"));
  511.     SetNameValuePair(fileName, servicesSectionName, "POP_Server", getGlobal("POP_Server"));
  512.     SetNameValuePair(fileName, servicesSectionName, "IMAP_Server", getGlobal("IMAP_Server"));
  513.     //may want this soon
  514.     SetNameValuePair(fileName, servicesSectionName, "Default_Mail_Protocol", getGlobal("Default_Mail_Protocol"));
  515.     
  516.  
  517.  
  518. //
  519. //    setLDAPServers(fileName);    //never had this either
  520. //    
  521.     SetNameValuePair(fileName, publishingSectionName, "Publish_URL", getGlobal("Publish_URL"));
  522.     SetNameValuePair(fileName, publishingSectionName, "Publish_Password", getGlobal("Publish_Password"));
  523.     SetNameValuePair(fileName, publishingSectionName, "View_URL", getGlobal("View_URL"));
  524. //
  525. //    Legacy stuff, won't use it no more
  526. //    SetNameValuePair(fileName, netbeuiSectionName, "Enabled", getGlobal("NetBEUIEnabled"));
  527. //
  528. //    SetNameValuePair(fileName, securitySectionName, "SecurityDevice", getGlobal("SecurityDevice"));
  529. //
  530. //    SetNameValuePair(fileName, scriptSectionName, "ScriptEnabled", getGlobal("ScriptEnabled"));
  531.     SetNameValuePair(fileName, scriptSectionName, "ScriptFileName", getGlobal("ScriptFileName"));
  532.     
  533.     //if we decide to support per POP CFG Files, uncomment these lines
  534.     SetNameValuePair(fileName, configurationSectionName, "ConfigurationFileName", getGlobal("ConfigurationFileName"));
  535.  
  536.     
  537.     //set the flag from ACCTSET.INI
  538.     SetNameValuePair("ACCTSET.INI", "Existing Acct Mode", "RegPodURL", getGlobal("RegPodURL"));
  539.     nciDirty(false);
  540. }
  541.  
  542.  
  543.  
  544. //EVENT HANDLERS
  545.  
  546. //this is the onLoad event Handler
  547. function loadData()
  548. {
  549.     if (parent.nci && parent.nci.loadData)
  550.     {
  551.         parent.nci.loadData();
  552.  
  553.         //generate toolbar controls (and load help file if needed)
  554.         if (parent.parent && parent.parent.controls && parent.parent.controls.generateToolBarControls)
  555.             parent.parent.controls.generateToolBarControls();
  556.         
  557.     }
  558.     else
  559.         setTimeout("loadData()", 500);
  560.     //debug("in getdata of nciglob.js");
  561. }
  562.  
  563. //checks validity of entered data to see if we're ready to unload
  564. function checkData()
  565. {
  566.     if (nciDirty(null))
  567.     {
  568.         if (parent.tabs.tabbody.checkData)
  569.         {
  570.             //alert("checkdata exists");
  571.             var checkResult = parent.tabs.tabbody.checkData();
  572.             if (checkResult != true)
  573.                 return checkResult;
  574.         }
  575.         else
  576.             return true;
  577.     }
  578.     else 
  579.         return true;
  580. }
  581.  
  582. //checks to see if globals are dirty - if so, asks if you wanna save
  583. function saveIfDirty()
  584. {
  585.     //alert("in saveifdirty");
  586.     var fName = null; 
  587.     
  588.     if (nciDirty(null))
  589.     {
  590.         if (confirm("You have made changes to this configuration.  Would you like to save them?"))
  591.             fName = saveNewOrOldFile();
  592.         nciDirty(false);
  593.     }
  594.     else
  595.         debug("Won't save - NCI not dirty");
  596.  
  597.     return fName;
  598. }
  599.  
  600.  
  601. // checks if fileName exists, if not asks about saving to a new file, 
  602. // else saves over an old file (no prompting)
  603. function saveNewOrOldFile()
  604. {
  605.     //flush data from currenly open tab into globals
  606.     if (parent.tabs && parent.tabs.tabbody && parent.tabs.tabbody.saveData)
  607.     {
  608.         parent.tabs.tabbody.saveData();
  609.     }
  610.  
  611.     nciDirty(false);
  612.  
  613.     var fileName = getGlobal("NciFileName");
  614.     if ((fileName == null) || (fileName == "") || (fileName == "_new_"))
  615.     {
  616.         //debug("Saving: must ask for FileName");
  617.         var theName = askNCIFileNameAndSave();
  618.         fileName = theName;
  619.     }
  620.     else if ((fileName != null) && (fileName != "") && (fileName != "_new_"))
  621.     {
  622.         //debug("Saving: without asking to: " + fileName);
  623.         writeToFile(fileName);
  624.     }
  625.     return fileName;
  626. }
  627.  
  628.  
  629. //this is the onUnLoad event Handler
  630. function saveData()
  631. {
  632.     //do a checkdata
  633.     var checkResult = checkData();
  634.     if (checkResult != true)
  635.         return false;
  636.             
  637.     //first make sure any current changes in the open tab are reflected in the globals
  638.     if(parent.tabs.tabbody.saveData)
  639.     {
  640.         parent.tabs.tabbody.saveData();
  641.     }
  642.     
  643.     saveIfDirty();    //save, if need be
  644.     return true;    
  645. }
  646.  
  647.  
  648. ////*DEFUNCT FUNCTION GRAVEYARD BELOW*////
  649.  
  650. // Decided not to do LDAPs here, since they can be done in the Config Editor - 
  651. // but let's keep this code around in case we ever do decide
  652. //function setLDAPServers(fileName)
  653. //{
  654. //    var servicesSectionName    =    "Services";
  655. //    var curLdap                =    "";
  656. //    var allLdaps            =    "";
  657. //    var curFlagName            =    "";
  658. //
  659. //    var num_Ldaps = parseInt(GetNameValuePair(fileName, servicesSectionName, "NUM_LDAP_Servers"));
  660. //    if ((!(num_Ldaps)) || (isNaN(num_Ldaps)))
  661. //        num_Ldaps = 0;
  662. //    
  663. //    setGlobal("NUM_LDAP_Servers", num_Ldaps.toString());
  664. //    
  665. //    for (var index = 1; index <= num_Ldaps; index++)    
  666. //    {
  667. //    
  668. //        curFlagName = ("LDAP_Server_"+(index));
  669. //        
  670. //        curLdap = GetNameValuePair(fileName, servicesSectionName, curFlagName);
  671. //        
  672. //        //might need some platform specific newline code in here
  673. //        if ((curLdap != null) && (curLdap != ""))
  674. //        {
  675. //            //curLdap = unescape(curLdap);
  676. //            allLdaps = (allLdaps +  curLdap + "\r");
  677. //        }
  678. //    }
  679. //    
  680. //    setGlobal("LDAP_Servers", allLdaps);
  681. //}
  682.  
  683. //function setLDAPServers(fileName)
  684. //{
  685. //    var servicesSectionName    =    "Services";
  686. //    var curLdap                =    "";
  687. //    var allLdaps            =    "";
  688. //    var curFlagName            =    "";
  689. //
  690. //    var num_LDAPS = parseInt(getGlobal("NUM_LDAP_Servers"));
  691. //    
  692. //    if ((!num_LDAPS) || (isNaN(num_LDAPS)))
  693. //        num_LDAPS = 0;
  694. //    
  695. //    SetNameValuePair(fileName, servicesSectionName, "NUM_LDAP_Servers", num_LDAPS.toString());
  696. //    
  697. //    //FIXME FIXME - may need platform specific newline handling code here
  698. //    
  699. //    var allLdaps = getGlobal("LDAP_Servers").split("\r");
  700. //    
  701. //    for (var index = 0; index < num_LDAPS; index++)    
  702. //    {
  703. //        curLdap = allLdaps[index];
  704. //        if ((curLdap != null) && (curLDap))
  705. //        {
  706. //            curLdap = escape(curLdap);
  707. //            curFlagName = ("LDAP_Server_"+(index+1));
  708. //            SetNameValuePair(fileName, servicesSectionName, curFlagName, curLdap);
  709. //        }
  710. //    }
  711. //}
  712. //
  713.  
  714. //returns the filename  that we are working with - from the 
  715. //editfield in the parent's "config" frame
  716. //function getNCINameFromConfigFrame()
  717. //{
  718.     
  719. //    //get the configName from the select list
  720. //    var selectedIndex    = parent.parent.document.NCICONFIGSELECT.NCICONFIGLIST.selectedIndex;
  721. //    //var cConfigName     = parent.parent.document.NCICONFIGSELECT.NCICONFIGLIST[selectedIndex];
  722. //    var name            = parent.parent.document.NCICONFIGSELECT.NCICONFIGLIST[selectedIndex].text;
  723. //    var cConfigName        = parent.parent.document.NCICONFIGSELECT.NCICONFIGLIST[selectedIndex].value;
  724. //    
  725. //    debug("config name is: " + cConfigName + ", name is: " +  name + ", val: " + cConfigName);
  726.     
  727. //    return cConfigName;
  728. //}
  729.  
  730. // end hiding contents from old browsers  -->
  731.