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.

196 lines
5.7 KiB

  1. var parent = null;
  2. var currentMenu = null;
  3. var count = 0;
  4. var initialized = false;
  5. function OffsetLeftToClientLeft( e )
  6. {
  7. if( null == e )
  8. return 0;
  9. return OffsetLeftToClientLeft( e.offsetParent ) + e.offsetLeft;
  10. }
  11. function OffsetTopToClientTop( e )
  12. {
  13. if( null == e )
  14. return 0;
  15. return OffsetTopToClientTop( e.offsetParent ) + e.offsetTop;
  16. }
  17. function CreateMenu( id )
  18. {
  19. var e;
  20. e = document.createElement( "DIV" );
  21. e.id = id;
  22. e.style.position = "absolute";
  23. e.style.width = 100;
  24. e.style.left = 0;
  25. e.style.top = 0;
  26. e.style.display = "none";
  27. e.style.border = "5px solid #000000";
  28. e.style.color = "#ffffff";
  29. e.style.backgroundColor = "#000000";
  30. document.body.appendChild( e );
  31. }
  32. function AddMenuItem( menuid, name, url )
  33. {
  34. var p = document.all[ menuid ];
  35. var e;
  36. e = document.createElement( "DIV" );
  37. e.id = "_mnuitm" + count;
  38. e.style.paddingTop = "2px";
  39. e.style.paddingLeft = "10px";
  40. e.style.paddingRight = "10px";
  41. e.style.paddingBottom = "2px";
  42. e.innerHTML = "<A href='" + url + "' id='_mnulnk" + count + "' style='color: #ffffff; text-decoration: none' onmouseover='this.style.color=\"#ff0000\"' onmouseout='this.style.color=\"#ffffff\"'>" + name.replace( " ", "&nbsp;" ) + "</A>";
  43. count ++;
  44. p.appendChild( e );
  45. }
  46. function AddSeparator( menuid )
  47. {
  48. var p = document.all[ menuid ];
  49. var e;
  50. e = document.createElement( "DIV" );
  51. e.id = "_mnuSeparator" + count;
  52. e.style.paddingLeft = "10px";
  53. e.style.paddingRight = "10px";
  54. e.innerHTML = "<HR id='_mnusep" + count + "' style='height: 1px; color: #ffffff'>";
  55. count ++;
  56. p.appendChild( e );
  57. }
  58. function ShowMenu( id )
  59. {
  60. if( !initialized )
  61. InitializeMenus();
  62. var e = document.all[ id ];
  63. var p = window.event.srcElement;
  64. //
  65. // See if we need to clean up a previously displayed
  66. // menu first.
  67. //
  68. if( null != currentMenu )
  69. {
  70. //
  71. // We can simply return if we are already showing the menu.
  72. //
  73. if( e.id == currentMenu.id )
  74. return;
  75. //
  76. // Hide the previous menu first.
  77. //
  78. HideMenu( currentMenu.id );
  79. }
  80. //
  81. // Display the appropriate menu.
  82. //
  83. e.style.display = "";
  84. var left = OffsetLeftToClientLeft( window.event.srcElement ) - 15;
  85. var width = e.clientWidth;
  86. var windowRight = document.body.clientWidth + document.body.scrollLeft;
  87. if( left + width > windowRight )
  88. {
  89. left = windowRight - width - 5;
  90. }
  91. e.style.left = left;
  92. e.style.top = OffsetTopToClientTop( window.event.srcElement ) + window.event.srcElement.offsetHeight;
  93. p.style.color = "#ff0000";
  94. //
  95. // Keep track of the current menu.
  96. //
  97. parent = p;
  98. currentMenu = e;
  99. //
  100. // We handled the event, so no need to process again.
  101. //
  102. window.event.cancelBubble = true;
  103. }
  104. function HideMenu( id )
  105. {
  106. var e = document.all[ id ];
  107. //
  108. // Hide the menu item and remove the highlight from the
  109. // parent.
  110. //
  111. e.style.display = "none";
  112. parent.style.color = "#ffffff";
  113. currentMenu = null;
  114. }
  115. function InitializeMenus()
  116. {
  117. CreateMenu( "_mnuProducts" );
  118. AddMenuItem( "_mnuProducts", "Downloads", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/downloads/" );
  119. AddMenuItem( "_mnuProducts", "MS Product Catalog", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/catalog/default.asp?subid=22" );
  120. AddMenuItem( "_mnuProducts", "Microsoft Accessibility", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/enable/" );
  121. AddSeparator( "_mnuProducts" );
  122. AddMenuItem( "_mnuProducts", "Server Products", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/servers/" );
  123. AddMenuItem( "_mnuProducts", "Developer Tools", "http://msdn.microsoft.com/isapi/gomsdn.asp?target=/vstudio/" );
  124. AddMenuItem( "_mnuProducts", "Office Family", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/office/" );
  125. AddMenuItem( "_mnuProducts", "Windows Family", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/windows/" );
  126. AddMenuItem( "_mnuProducts", "MSN", "http://www.msn.com/" );
  127. CreateMenu( "_mnuSearch" );
  128. AddMenuItem( "_mnuSearch", "Search microsoft.com", "http://msdn.microsoft.com/isapi/gosearch.asp?target=/us/default.asp" );
  129. AddMenuItem( "_mnuSearch", "MSN Web Search", "http://search.msn.com/" );
  130. CreateMenu( "_mnuMSDN" );
  131. AddMenuItem( "_mnuMSDN", "msdn.microsoft.com Home", "http://msdn.microsoft.com/default.asp" );
  132. AddMenuItem( "_mnuMSDN", "Tech-Ed", "http://msdn.microsoft.com/events/teched/default.asp" );
  133. CreateMenu( "_mnuMicrosoft" );
  134. AddMenuItem( "_mnuMicrosoft", "microsoft.com Home", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/" );
  135. AddMenuItem( "_mnuMicrosoft", "MSN Home", "http://www.msn.com/" );
  136. AddSeparator( "_mnuMicrosoft" );
  137. AddMenuItem( "_mnuMicrosoft", "Contact Us", "http://msdn.microsoft.com/isapi/goregwiz.asp?target=/regwiz/forms/contactus.asp" );
  138. AddMenuItem( "_mnuMicrosoft", "Events", "http://www.microsoft.com/usa/events/default.asp" );
  139. AddMenuItem( "_mnuMicrosoft", "Newsletters", "http://msdn.microsoft.com/isapi/goregwiz.asp?target=/regsys/pic.asp?sec=0" );
  140. AddMenuItem( "_mnuMicrosoft", "Profile Center", "http://msdn.microsoft.com/isapi/goregwiz.asp?target=/regsys/pic.asp" );
  141. AddMenuItem( "_mnuMicrosoft", "Training & Certification", "http://msdn.microsoft.com/isapi/gomscom.asp?target=/train_cert/" );
  142. AddMenuItem( "_mnuMicrosoft", "Free E-mail Account", "http://www.hotmail.com/" );
  143. initialized = true;
  144. }
  145. function Document_OnLoad()
  146. {
  147. if( !initialized )
  148. InitializeMenus();
  149. }
  150. function Document_OnMouseMove()
  151. {
  152. var e = window.event.srcElement;
  153. if( ( null == e.id || "_mnu" != e.id.substring( 0, 4 ) ) && null != currentMenu )
  154. {
  155. HideMenu( currentMenu.id );
  156. }
  157. }