home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet Web Designer 86 / PIWD86.iso / pc / contents / dreamweaver / software / dwmx2004.exe / Disk1 / data1.cab / Configuration_En / Commands / EditASPNETSprocParam.js < prev    next >
Encoding:
JavaScript  |  2003-09-05  |  5.9 KB  |  242 lines

  1. // Copyright 2002, 2003 Macromedia, Inc. All rights reserved.
  2.  
  3. var helpDoc = MM.HELP_cmdASPNetSprocParam;
  4.  
  5. var _ParamName = null;
  6. var _ParamType = null;
  7. var _ParamSize = null;
  8. var _ParamDirection = null;
  9. var _ParamTestValue = null;
  10. var _ParamValue = null;
  11. var _BuildButton = null;
  12.  
  13. //*************************API**************************
  14.  
  15. //--------------------------------------------------------------------
  16. // FUNCTION:
  17. //   commandButtons
  18. //
  19. // DESCRIPTION:
  20. //   Returns the array of buttons that should be displayed on the
  21. //   right hand side of the dialog.  The array is comprised
  22. //   of name, handler function name pairs.
  23. //
  24. // ARGUMENTS:
  25. //   none
  26. //
  27. // RETURNS:
  28. //   array of strings - name, handler function name pairs
  29. //--------------------------------------------------------------------
  30.  
  31. function commandButtons()
  32. {                          
  33.   return new Array(MM.BTN_OK,     "okClicked()",
  34.                    MM.BTN_Cancel, "cancelClicked()",
  35.                    MM.BTN_Help,   "displayHelp()" );
  36. }
  37.  
  38. //--------------------------------------------------------------------
  39. // FUNCTION:
  40. //   okClicked
  41. //
  42. // DESCRIPTION:
  43. //   Sets the return value to the selected DSN and closes the window.
  44. //
  45. // ARGUMENTS:
  46. //   none
  47. //
  48. // RETURNS:
  49. //   nothing
  50. //--------------------------------------------------------------------
  51.  
  52. function okClicked()
  53. {
  54.   do
  55.   {
  56.     var paramName = _ParamName.value;
  57.   
  58.     if (paramName == "")
  59.     {
  60.       alert(MM.MSG_NeedParamName);
  61.       _ParamName.focus();
  62.       break;
  63.     }
  64.     
  65.     var direction = _ParamDirection.getValue();
  66.  
  67.     if (direction.toUpperCase().indexOf("INPUT") != (-1))
  68.     {
  69.       var paramTestValue = _ParamTestValue.value;
  70.  
  71.       if (paramTestValue == "")
  72.       {
  73.         alert(MM.MSG_NeedParamTestValue);
  74.         _ParamTestValue.focus();
  75.         break;
  76.       }
  77.     
  78.       var paramValue = _ParamValue.value;
  79.  
  80.       if (paramValue == "")
  81.       {
  82.         alert(MM.MSG_NeedParamValue);
  83.         _ParamValue.focus();
  84.         break;
  85.       }
  86.     }
  87.     
  88.     var retVal = new Array();
  89.  
  90.     retVal.push(_ParamName.value);
  91.     retVal.push(_ParamType.getValue());
  92.     retVal.push(_ParamSize.value);
  93.     retVal.push(_ParamDirection.getValue());
  94.     retVal.push(_ParamTestValue.value);
  95.     retVal.push(_ParamValue.value);
  96.  
  97.     dwscripts.setCommandReturnValue(retVal);
  98.     window.close();
  99.   }
  100.   while (false);
  101. }
  102.  
  103. //--------------------------------------------------------------------
  104. // FUNCTION:
  105. //   cancelClicked
  106. //
  107. // DESCRIPTION:
  108. //   Closes the window and returns nothing
  109. //
  110. // ARGUMENTS:
  111. //   none
  112. //
  113. // RETURNS:
  114. //   nothing
  115. //--------------------------------------------------------------------
  116.  
  117. function cancelClicked()
  118. {
  119.   dwscripts.setCommandReturnValue("");
  120.   window.close();
  121. }
  122.  
  123. //--------------------------------------------------------------------
  124. // FUNCTION:
  125. //   updateUI
  126. //
  127. // DESCRIPTION:
  128. //   This function is called by the UI controls to handle UI updates
  129. //
  130. // ARGUMENTS:
  131. //   control - string - the name of the control sending the event
  132. //   event - string - the event which is being sent
  133. //
  134. // RETURNS:
  135. //   nothing
  136. //--------------------------------------------------------------------
  137.  
  138. function updateUI(control, event)
  139. {
  140. }
  141.  
  142. //--------------------------------------------------------------------
  143. // FUNCTION:
  144. //   initializeUI
  145. //
  146. // DESCRIPTION:
  147. //   This function is called in the onLoad event.  It is responsible
  148. //   for initializing the UI.  If we are inserting a recordset, this
  149. //   is a matter of populating the connection drop down.
  150. //
  151. //   If we are modifying a recordset, this is a matter of inspecting
  152. //   the recordset tag and setting all the form elements.
  153. //
  154. // ARGUMENTS:
  155. //   none
  156. //
  157. // RETURNS:
  158. //   nothing
  159. //--------------------------------------------------------------------
  160.  
  161. function initializeUI()
  162. {
  163.   // Initialize UI elements
  164.  
  165.   _ParamName = dwscripts.findDOMObject("ParamName"); 
  166.   _ParamType = new ListControl("ParamType");
  167.   _ParamSize = dwscripts.findDOMObject("ParamSize");
  168.   _ParamDirection = new ListControl("ParamDirection");
  169.   _ParamTestValue = dwscripts.findDOMObject("ParamTestValue");
  170.   _ParamValue = dwscripts.findDOMObject("ParamValue");
  171.   _BuildButton = dwscripts.findDOMObject("BuildValue"); 
  172.  
  173.   var directions = ["Input", "Output", "InputOutput", "ReturnValue"];
  174.   _ParamDirection.setAll(directions, directions);
  175.  
  176.   var cmdArgs = dwscripts.getCommandArguments();
  177.  
  178.   if (cmdArgs && (cmdArgs.length > 6))
  179.   {
  180.     var databaseType = cmdArgs[6];
  181.     var types = SBDatabaseCallASPNET.getParamTypeList(databaseType);
  182.  
  183.     _ParamType.setAll(types, types);
  184.  
  185.     _ParamName.value = cmdArgs[0];
  186.     _ParamType.pickValue(cmdArgs[1]);
  187.     _ParamSize.value = cmdArgs[2];
  188.     _ParamDirection.pickValue(cmdArgs[3]);
  189.     _ParamTestValue.value = cmdArgs[4];
  190.     _ParamValue.value = cmdArgs[5];
  191.   }
  192.   else
  193.   {
  194.     _ParamName.value = "";
  195.     _ParamType.setIndex(0);
  196.     _ParamSize.value = "";
  197.     _ParamDirection.setIndex(0);
  198.     _ParamTestValue.value = "";
  199.     _ParamValue.value = "";
  200.   }
  201.  
  202.   onParamDirectionChanged();
  203.  
  204.   _ParamName.focus();
  205. }
  206.  
  207. function onBuildValueClicked()
  208. {
  209.   var cmdArgs = new Array();
  210.   
  211.   cmdArgs.push(_ParamName.value);
  212.   cmdArgs.push(_ParamTestValue.value);
  213.  
  214.   cmdArgs = dwscripts.callCommand("AddASPNETParamRuntime", cmdArgs);
  215.  
  216.   if (cmdArgs)
  217.   {
  218.     _ParamValue.value = cmdArgs;
  219.   }
  220. }
  221.  
  222. function onParamDirectionChanged()
  223. {
  224.   var direction = _ParamDirection.getValue();
  225.  
  226.   if (direction.toUpperCase().indexOf("INPUT") != (-1))
  227.   {
  228.     _ParamTestValue.removeAttribute("disabled");
  229.     _ParamValue.removeAttribute("disabled");
  230.     _BuildButton.removeAttribute("disabled");   
  231.   }
  232.   else
  233.   {
  234.     _ParamTestValue.value = "";
  235.     _ParamValue.value = "";
  236.  
  237.     _ParamTestValue.setAttribute("disabled", "disabled");
  238.     _ParamValue.setAttribute("disabled", "disabled");
  239.     _BuildButton.setAttribute("disabled", "disabled");   
  240.   }
  241. }
  242.