home *** CD-ROM | disk | FTP | other *** search
/ Your Business Pak / BusinessPak2.iso / Netscape / CD / as.z / asw.jar / dialinf1.js < prev    next >
Text File  |  1998-10-15  |  9KB  |  295 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.     var theFile = parent.parent.globals.getAcctSetupFilename(self);
  25.     var onestepMode = parent.parent.globals.GetNameValuePair(theFile, "Mode Selection", "OneStepMode");
  26.     var retval = false;
  27.  
  28.     if (msg == "2step")
  29.     {
  30.         if (onestepMode == "no" || onestepMode == "" || onestepMode == null)
  31.         {
  32.             retval = true;
  33.         }
  34.     }
  35.     else if (msg == "1step")
  36.     {
  37.         if (onestepMode == "yes")
  38.         {
  39.             retval = true;
  40.         }
  41.     }    
  42.     
  43.     return retval;
  44. }
  45.  
  46.  
  47.  
  48. function verifyCallWaiting(cwData)
  49. {
  50.     var    validFlag=true;
  51.  
  52.     if (cwData.length > 0)    {
  53.         for (var x=0; x<cwData.length; x++)    {
  54.             if ("0123456789*#,".indexOf(cwData.charAt(x)) <0)    {
  55.                 validFlag=false;
  56.                 break;
  57.                 }
  58.             }
  59.         }
  60.     return(validFlag);
  61. }
  62.  
  63.  
  64.  
  65. function verifyPrefix(prefixData)
  66. {
  67.     var    validFlag=true;
  68.  
  69.     if (prefixData.length > 0)    {
  70.         for (var x=0; x<prefixData.length; x++)    {
  71.             if ("0123456789,".indexOf(prefixData.charAt(x)) <0)    {
  72.                 validFlag=false;
  73.                 break;
  74.                 }
  75.             }
  76.         }
  77.     return(validFlag);
  78. }
  79.  
  80.  
  81.  
  82. function checkData()
  83. {
  84.     if (verifyCallWaiting(document.forms[0].cwData.value) == false)    {
  85.         alert("Please enter a valid call waiting string. (It may contain numbers, asterisks, pound signs and commas.)");
  86.         parent.parent.globals.setFocus(document.forms[0].cwData);
  87.         return(false);
  88.         }
  89.     if (verifyPrefix(document.forms[0].prefixData.value) == false)    {
  90.         alert("Please enter a valid outside line string. (It may contain numbers and commas.)");
  91.         parent.parent.globals.setFocus(document.forms[0].prefixData);
  92.         return(false);
  93.         }
  94.     return(true);
  95. }
  96.  
  97.  
  98.  
  99. function loadData()
  100. {
  101.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  102.  
  103.     // make sure all data objects/element exists and valid; otherwise, reload.  SUCKS!
  104.     if (((document.forms[0].cwData == "undefined") || (document.forms[0].cwData == "[object InputArray]")) ||
  105.         ((document.forms[0].cwOptions == "undefined") || (document.forms[0].cwOptions == "[object InputArray]")) ||
  106.         ((document.forms[0].prefixData == "undefined") || (document.forms[0].prefixData == "[object InputArray]")))
  107.     {
  108.         parent.controls.reloadDocument();
  109.         return;
  110.     }
  111.  
  112.     document.forms[0].cwData.value=parent.parent.globals.document.forms[0].cwData.value;
  113. //    document.forms[0].cwOFF.checked=parent.parent.globals.document.forms[0].cwOFF.checked;
  114. //    document.forms[0].cwOFF.checked=(document.forms[0].cwData.value=="") ? 0:1;
  115.  
  116.     var found=false;
  117.     for (var i = 0; i < document.forms[0].cwOptions.length; i++)    {
  118.         if (document.forms[0].cwOptions[i].value==parent.parent.globals.document.forms[0].cwData.value)    {
  119.             document.forms[0].cwOptions[i].selected=true;
  120.             found=true;
  121.             }
  122.         else    {
  123.             document.forms[0].cwOptions[i].selected=false;
  124.             }
  125.         }
  126.     if (found==false)    {
  127.         if (document.forms[0].cwData.value == "")    {
  128.             document.forms[0].cwOptions[0].text = "(Line Doesn't Have Call Waiting)";
  129.             document.forms[0].cwOptions[0].value = "";
  130.             }
  131.         else    {
  132.             document.forms[0].cwOptions[0].text = document.forms[0].cwData.value;
  133.             document.forms[0].cwOptions[0].value = document.forms[0].cwData.value;
  134.             }
  135.         document.forms[0].cwOptions[0].selected=true;
  136.         }
  137.     document.forms[0].prefixData.value=parent.parent.globals.document.forms[0].prefixData.value;
  138. //    document.forms[0].prefix.checked=parent.parent.globals.document.forms[0].prefix.checked;
  139. //    document.forms[0].prefix.checked=(document.forms[0].prefixData.value=="") ? 0:1;
  140.  
  141.     var theModem = parent.parent.globals.document.vars.modem.value;
  142.     var theModemType = parent.parent.globals.document.setupPlugin.GetModemType(theModem);
  143.     if (theModemType != null)    {
  144.         theModemType = theModemType.toUpperCase();
  145.         if (theModemType == "ISDN")    {
  146.             // do nothing
  147.             }
  148.         else    {
  149.             if (parent.parent.globals.document.forms[0].dialMethod.value == "PULSE")    {
  150.                 document.layers["dialingMethods"].document.forms[0].dialMethod[0].checked=false;
  151.                 document.layers["dialingMethods"].document.forms[0].dialMethod[1].checked=true;
  152.                 }
  153.             else    {
  154.  
  155.                 document.layers["dialingMethods"].document.forms[0].dialMethod[0].checked=true;
  156.                 document.layers["dialingMethods"].document.forms[0].dialMethod[1].checked=false;
  157.                 }
  158.             }
  159.         }
  160.     parent.parent.globals.setFocus(document.forms[0].cwData);
  161.     if (parent.controls.generateControls)    parent.controls.generateControls();
  162. }
  163.  
  164.  
  165.  
  166. function saveData()
  167. {
  168.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  169.  
  170.     // make sure all form element are valid objects, otherwise just skip & return!
  171.     if (((document.forms[0].cwData == "undefined") || (document.forms[0].cwData == "[object InputArray]")) ||
  172.         ((document.forms[0].cwOptions == "undefined") || (document.forms[0].cwOptions == "[object InputArray]")) ||
  173.         ((document.forms[0].prefixData == "undefined") || (document.forms[0].prefixData == "[object InputArray]")))
  174.     {
  175.         parent.controls.reloadDocument();
  176.         return;
  177.     }
  178.  
  179. //    parent.parent.globals.document.forms[0].cwOFF.checked = document.forms[0].cwOFF.checked;
  180.     parent.parent.globals.document.forms[0].cwData.value = document.forms[0].cwData.value;
  181. //    parent.parent.globals.document.forms[0].prefix.checked = document.forms[0].prefix.checked;
  182.     parent.parent.globals.document.forms[0].prefixData.value = document.forms[0].prefixData.value;
  183.  
  184.     var theModem = parent.parent.globals.document.vars.modem.value;
  185.     var theModemType = parent.parent.globals.document.setupPlugin.GetModemType(theModem);
  186.     if (theModemType != null)    {
  187.         theModemType = theModemType.toUpperCase();
  188.         if (theModemType == "ISDN")    {
  189.             parent.parent.globals.document.forms[0].dialMethod.value = theModemType;
  190.             }
  191.         else    {
  192.             if (document.layers["dialingMethods"].document.forms[0].dialMethod[1].checked == true)    {
  193.                 parent.parent.globals.document.forms[0].dialMethod.value = document.layers["dialingMethods"].document.forms[0].dialMethod[1].value;
  194.                 }
  195.             else    {
  196.                 parent.parent.globals.document.forms[0].dialMethod.value = document.layers["dialingMethods"].document.forms[0].dialMethod[0].value;
  197.                 }
  198.             }
  199.         }
  200. }
  201.  
  202.  
  203.  
  204. function updateCWOptions(theObject)
  205. {
  206. /*
  207.     if (theObject.name=="cwOFF")    {
  208.         if (theObject.checked)    {
  209.             parent.parent.globals.setFocus(document.forms[0].cwData);
  210.             }
  211.         else    {
  212.             document.forms[0].cwData.value="";
  213.             document.forms[0].cwOFF.checked=0;
  214.             }
  215.         }
  216.     else
  217. */
  218.     if (theObject.name=="cwData")    {
  219.         document.forms[0].cwOptions[0].text = "(Line Doesn't Have Call Waiting)";
  220.         document.forms[0].cwOptions[0].value = "";
  221.         if (document.forms[0].cwData.value=="")    {
  222.             document.forms[0].cwOptions.selectedIndex = 0;
  223.             }
  224.         else    {
  225.             var found=0;
  226.             for (var x=1; x<document.forms[0].cwOptions.length; x++)    {
  227.                 if (document.forms[0].cwOptions[x].text == document.forms[0].cwData.value)    {
  228.                     found=x;
  229.                     break;
  230.                     }
  231.                 }
  232.             if (found<1)    {
  233.                 document.forms[0].cwOptions[0].text = document.forms[0].cwData.value;
  234.                 document.forms[0].cwOptions[0].value = document.forms[0].cwData.value;
  235.                 }
  236.             document.forms[0].cwOptions.selectedIndex = found;
  237.             }
  238.         }
  239.     else
  240.      if (theObject.name=="cwOptions")    {
  241.         document.forms[0].cwData.value=document.forms[0].cwOptions[document.forms[0].cwOptions.selectedIndex].value;
  242.         parent.parent.globals.setFocus(document.forms[0].cwData);
  243. //        document.forms[0].cwOFF.checked=1;
  244.         }
  245.     return(true);
  246. }
  247.  
  248.  
  249.  
  250. function updatePrefix(theObject)
  251. {
  252. /*
  253.     if (theObject.name=="prefix")    {
  254.         if (theObject.checked)    {
  255.             parent.parent.globals.setFocus(document.forms[0].prefixData);
  256.             }
  257.         else    {
  258.             document.forms[0].prefixData.value="";
  259.             document.forms[0].prefix.checked=0;
  260.             }
  261.         }
  262.     else if (theObject.name=="prefixData")    {
  263.         if (document.forms[0].prefixData.value=="")    {
  264.             document.forms[0].prefix.checked=0;
  265.             }
  266.         else    {
  267.             document.forms[0].prefix.checked=1;
  268.             }
  269.         }
  270. */
  271.     return(false);
  272. }
  273.  
  274.  
  275.  
  276. function generateDialingMethods()
  277. {
  278.     netscape.security.PrivilegeManager.enablePrivilege("AccountSetup");
  279.  
  280.     var theModem = parent.parent.globals.document.vars.modem.value;
  281.     var theModemType = parent.parent.globals.document.setupPlugin.GetModemType(theModem);
  282.     if (theModemType != null && theModemType.toUpperCase() != "ISDN")    
  283.     {
  284.         document.layers["dialingMethods"].visibility = "show";
  285.     }
  286.     else
  287.     {
  288.         document.layers["dialingMethods"].visibility = "hide";
  289.     }
  290. }
  291.  
  292.  
  293.  
  294. // end hiding contents from old browsers  -->
  295.