home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 July / 07_02.iso / software / mdmx / files / DreamweaverMXInstaller.exe / Disk1 / data1.cab / Configuration_En / Commands / ConnectionVariable.js < prev    next >
Encoding:
JavaScript  |  2002-05-01  |  2.0 KB  |  104 lines

  1. // Copyright 2000 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. var _Name = null
  6. var _ConnectionName = new CFDataSourceMenu("", "ConnectionName");
  7.  
  8. var NAME_LIST = null;
  9.  
  10. //******************* API **********************
  11.  
  12. function commandButtons()
  13. {
  14.   return new Array(MM.BTN_OK,    "okClicked()",
  15.                    MM.BTN_Cancel,"window.close()");
  16. }
  17.  
  18.  
  19.  
  20. //***************** LOCAL FUNCTIONS  ******************
  21.  
  22.  
  23. function initializeUI()
  24. {
  25.   _Name = dwscripts.findDOMObject("theName");
  26.   _ConnectionName.initializeUI(null, true);
  27.   
  28.   args = dwscripts.getCommandArguments();
  29.   if (args.defaultName)
  30.   {
  31.     _Name.value = args.defaultName;
  32.   }
  33.   
  34.   if (args.nameList)
  35.   {
  36.     NAME_LIST = args.nameList;
  37.   }
  38.   
  39.   if (args.name)
  40.   {
  41.     // re-edit, so disable the name field
  42.     _Name.value = args.name;
  43.     _Name.setAttribute("disabled", true);
  44.   }
  45.   
  46.   if (args.dataSource)
  47.   {
  48.     _ConnectionName.pickValue(args.dataSource);
  49.   }
  50. }
  51.  
  52.  
  53. function updateUI(itemName, event)
  54. {
  55.   if (itemName == "ConnectionName" && event == "onChange")
  56.   {
  57.     if (!_Name.value)
  58.     {
  59.       _Name.value = _ConnectionName.getValue();
  60.     }
  61.   }
  62. }
  63.  
  64.  
  65. function okClicked()
  66. {
  67.   if (_Name.value)
  68.   {
  69.     if (dwscripts.isValidServerVarName(_Name.value))
  70.     {
  71.       if (!NAME_LIST || dwscripts.findInArray(NAME_LIST, _Name.value) == -1)
  72.       {
  73.         if (_ConnectionName.getValue())
  74.         {
  75.           var retVal = new Object();
  76.           retVal.name = _Name.value;
  77.           retVal.dataSource = _ConnectionName.getValue();
  78.  
  79.           dwscripts.setCommandReturnValue(retVal);
  80.           window.close();
  81.         }
  82.         else
  83.         {
  84.           alert(MM.MSG_NoDataSource);
  85.         }
  86.       }
  87.       else
  88.       {
  89.         alert(dwscripts.sprintf(MM.MSG_ParamNameAlreadyExists,_Name.value));
  90.       }
  91.     } 
  92.     else
  93.     {
  94.       alert(_Name.value + " " + MM.MSG_InvalidParamName);
  95.     }
  96.   } 
  97.   else
  98.   {
  99.     alert(MM.MSG_NoName);
  100.   }
  101. }
  102.  
  103.  
  104.