Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.4 KiB

  1. //+--------------------------------------------------
  2. //
  3. // Dialog header file. This file contains functions
  4. // common to all the dialogs.
  5. //
  6. //---------------------------------------------------
  7. #define SEC_MOUSE_BUTTON 2
  8. #define HTML_KEY_ESC 27
  9. //+---------------------------------------------------------------------
  10. //
  11. // Synopsis: Disables or enables a button depending in
  12. // whether there is text in txtFileName.
  13. //
  14. // Arguments: fEvent Whether or not the f'n was called by an
  15. // event
  16. //
  17. // Macro Arguments: NAME Sets the name of the function
  18. // (set##NAME##State)and the name of the
  19. // constant (g_f##NAME##Enabled)
  20. // BUTTON The button we're setting the state of.
  21. // TEXTBOX The textbox querying.
  22. //
  23. // Returns: nothing
  24. //
  25. //----------------------------------------------------------------------
  26. #define setState(NAME, BUTTON, TEXTBOX) function set##NAME##State(fEvent) \
  27. { \
  28. if (fEvent && (event.propertyName != "value")) \
  29. { \
  30. return; \
  31. } \
  32. \
  33. if (("" == TEXTBOX.value) == g_f##NAME##Enabled) \
  34. { \
  35. BUTTON.disabled = g_f##NAME##Enabled; \
  36. g_f##NAME##Enabled = !g_f##NAME##Enabled; \
  37. } \
  38. } \
  39. var g_f##NAME##Enabled = false; \
  40. //+-------------------------------------------------------------------------
  41. //
  42. // Synopsis: Opens the help file with the appropriate helpid
  43. //
  44. // Arguments: elm The element we're looking for help with
  45. //
  46. // Returns: nothing
  47. //
  48. //--------------------------------------------------------------------------
  49. function callHelp(elm)
  50. {
  51. if (null != elm.helpid)
  52. {
  53. //
  54. // Have to convert the helpid to a string
  55. //
  56. window.showHelp(elm.helpfile, "" + parseInt(elm.helpid),
  57. "popup");
  58. }
  59. else
  60. {
  61. //
  62. // Walk up the tree until we reach the body tag or
  63. // an element with a help id.
  64. //
  65. if ("BODY" != elm.tagName)
  66. {
  67. callHelp(elm.parentElement);
  68. }
  69. }
  70. } // callHelp
  71. //----------------------------------------------------------------------
  72. //
  73. // Synopsis: Discard the user's changes and dismiss the dialog.
  74. //
  75. // Arguments: none
  76. //
  77. // Returns: nothing
  78. //
  79. //----------------------------------------------------------------------
  80. function btnCancelClick()
  81. {
  82. window.close();
  83. } // btnCancelClick
  84. //+----------------------------------------------------------------------
  85. //
  86. // Synopsis: Returns a range based on elm
  87. //
  88. // Arguments: elm An element
  89. //
  90. // Returns: a text range
  91. //
  92. //-----------------------------------------------------------------------
  93. function getTextRange(elm)
  94. {
  95. var r = elm.parentTextEdit.createTextRange();
  96. r.moveToElementText(elm);
  97. return r;
  98. } // getTextRange
  99. //+----------------------------------------------------------------------
  100. //
  101. // Synopsis: Checks to see if the secondary mouse button was clicked
  102. // and fires help if it was.
  103. //
  104. // Arguments: none
  105. //
  106. // Retuens: nothing
  107. //
  108. //-----------------------------------------------------------------------
  109. function mouseClick()
  110. {
  111. //
  112. // First, let's make sure we're not in a textbox
  113. //
  114. if (window.event.srcElement.id.substring(0,3)
  115. == "txt")
  116. {
  117. return;
  118. }
  119. if (window.event.button == SEC_MOUSE_BUTTON)
  120. {
  121. callHelp(window.event.srcElement);
  122. }
  123. } // mouseClick
  124. //+----------------------------------------------------------------------
  125. //
  126. // Synopsis: If the enter key is pressed while in a textbox,
  127. // we do not want the default functionality. Instead,
  128. // we close the dialog, doing nothing.
  129. //
  130. // Arguments: none
  131. //
  132. // Retutns: nothing
  133. //
  134. //-----------------------------------------------------------------------
  135. function txtDefaultESC()
  136. {
  137. if (event.keyCode == HTML_KEY_ESC)
  138. {
  139. window.close();
  140. return;
  141. }
  142. } // txtDefaultESC
  143. window.onerror = HandleError
  144. var L_Dialog_ErrorMessage = "An error has occurred in this dialog.";
  145. var L_ErrorNumber_Text = "Error: ";
  146. //+-------------------------------------------------------------------
  147. //
  148. // Synopsis: Turns off error messages in dialogs
  149. //
  150. // Arguments: none
  151. //
  152. // returns: true (tells browser not to handle message)
  153. //
  154. //--------------------------------------------------------------------
  155. function HandleError(message, url, line)
  156. {
  157. var str = L_Dialog_ErrorMessage + "\n\n"
  158. + L_ErrorNumber_Text + line + "\n"
  159. + message;
  160. alert (str);
  161. window.close();
  162. return true;
  163. }