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.

359 lines
8.7 KiB

  1. //
  2. // Copyright (c) 2001 Microsoft Corporation
  3. //
  4. function Server_Generate()
  5. {
  6. try
  7. {
  8. Server_PrepareNode( idTaxo, idTaxo, null, null );
  9. Server_Build( idTaxo );
  10. }
  11. catch(e)
  12. {
  13. }
  14. idTopLevelTable.style.display = "";
  15. }
  16. function Server_Build( node )
  17. {
  18. var qrc = pchealth.Database.LookupNodesAndTopics( node.HC_PARENT ? node.HC_PAYLOAD.FullPath : "", true );
  19. var html = "";
  20. var fLarge = (node.HC_PARENT != null);
  21. if(qrc.Count == 0)
  22. {
  23. node.HC_FLYOUT = false;
  24. node.HC_SUBNODES = null;
  25. }
  26. for(var e = new Enumerator( qrc ); !e.atEnd(); e.moveNext())
  27. {
  28. var qr = e.item();
  29. var fFlyout = (qr.Entry && qr.Subsite == false);
  30. html += Server_CreateNode( qr.FullPath, qr.Title, qr.Description, fFlyout, fLarge );
  31. }
  32. if(node.HC_PARENT)
  33. {
  34. node.HC_CHILDREN = Server_CreateFlyout( node, html );
  35. }
  36. else
  37. {
  38. node.innerHTML = html;
  39. node.HC_CHILDREN = node.firstChild;
  40. }
  41. Server_LocateNodes( node, qrc );
  42. }
  43. function Server_CreateNode( node, title, description, fFlyout, fLarge )
  44. {
  45. var html;
  46. node = pchealth.TextHelpers.QuoteEscape( node );
  47. title = pchealth.TextHelpers.HTMLEscape ( title );
  48. description = pchealth.TextHelpers.QuoteEscape( description );
  49. html = "<SPAN tabindex=-1 class='Taxo-Block' HC_NODE=\"" + node + "\" title=\"" + description + "\">";
  50. html += "<TABLE" + (fLarge ? " width=100%" : "" ) + " border=0 cellpadding=0 cellspacing=0>";
  51. html += "<TR class=Taxo-Cell>";
  52. html += "<TD VALIGN='top' class='sys-font-body-bold Taxo-Bullet'><LI></TD><TD class='sys-font-body-bold Taxo-Title'>";
  53. if(fFlyout)
  54. {
  55. var arrow = (window.document.documentElement.dir == "rtl") ? "3" : "4";
  56. html += "<SPAN ID=_IDFOCUS TABINDEX=100>" + title + " <SPAN style='font-family: marlett'>" + arrow + "</SPAN></SPAN>";
  57. }
  58. else
  59. {
  60. html += "<A class='Taxo-Title sys-homepage-color' ID=_IDFOCUS TABINDEX=100 HREF='hcp://services/subsite?node=" + node + "'>" + title + "</A>";
  61. }
  62. html += "</TD>";
  63. html += "<TD style='display:none; width: 0px'>";
  64. html += "</TD>";
  65. html += "</TR>";
  66. html += "</TABLE>";
  67. html += "</SPAN>";
  68. return html;
  69. }
  70. function Server_CreateFlyout( node, nodes )
  71. {
  72. var tbl = node.firstChild;
  73. var row = tbl.rows(0);
  74. var cell = row.cells(2);
  75. var html = "";
  76. html += "<DIV class='sys-background-strong sys-toppane-color-border' style='width: 10em; position:absolute; z-index: 1; margin: 0px; border: 1pt solid'>";
  77. html += nodes;
  78. html += "</DIV>";
  79. node.HC_ATTACHFLYOUT = cell;
  80. cell.innerHTML = html;
  81. return cell.firstChild.firstChild;
  82. }
  83. function Server_PrepareNode( elem, root, parent, qr )
  84. {
  85. elem.HC_PARENT = parent;
  86. elem.HC_ROOT = root;
  87. elem.HC_PAYLOAD = qr;
  88. elem.HC_SUBNODES = null;
  89. elem.HC_CHILDREN = null;
  90. elem.HC_ATTACHFLYOUT = null;
  91. elem.HC_HIGHLIGHTED = 0;
  92. if(!root.HC_COLL)
  93. {
  94. root.HC_COLL = [];
  95. root.HC_CHAIN = [];
  96. root.HC_SELECTED = null;
  97. root.HC_PENDING = false;
  98. }
  99. root.HC_COLL[elem.uniqueID] = elem;
  100. if(qr)
  101. {
  102. elem.HC_FLYOUT = (qr.Entry && qr.Subsite == false);
  103. elem.onclick = node_Server_click;
  104. elem.oncontextmenu = node_Server_contextmenu;
  105. elem.onmouseover = node_Server_over;
  106. elem.onmouseout = node_Server_out;
  107. if(elem.all._IDFOCUS)
  108. {
  109. elem.all._IDFOCUS.onfocus = node_Server_over;
  110. elem.all._IDFOCUS.onblur = node_Server_out;
  111. }
  112. }
  113. else
  114. {
  115. elem.HC_FLYOUT = true;
  116. }
  117. }
  118. function Server_LocateNodes( node, qrc )
  119. {
  120. var obj = node.HC_CHILDREN;
  121. var e = new Enumerator( qrc );
  122. var array = [];
  123. var first = null;
  124. var last = null;
  125. while(obj && !e.atEnd())
  126. {
  127. if(!first) first = obj;
  128. Server_PrepareNode( obj, node.HC_ROOT, node, e.item() ); e.moveNext();
  129. array[array.length] = obj;
  130. obj.HC_POSITION = node.HC_PARENT ? "middle" : "root";
  131. last = obj;
  132. obj = obj.nextSibling;
  133. }
  134. if(array.length)
  135. {
  136. node.HC_SUBNODES = array;
  137. if(node.HC_PARENT)
  138. {
  139. if(first == last) // only one node
  140. {
  141. first.HC_POSITION = "single";
  142. }
  143. else
  144. {
  145. first.HC_POSITION = "first";
  146. last .HC_POSITION = "last";
  147. }
  148. }
  149. }
  150. }
  151. function node_Server_find( node )
  152. {
  153. while(node && !node.HC_PAYLOAD) node = node.parentElement;
  154. return node;
  155. }
  156. function node_Server_click()
  157. {
  158. var node = node_Server_find( event.srcElement ); if(!node) return;
  159. Common_CancelEvent();
  160. if(node.HC_FLYOUT) return;
  161. try
  162. {
  163. var qr = node.HC_PAYLOAD;
  164. if(qr)
  165. {
  166. if(qr.Entry)
  167. {
  168. pchealth.HelpSession.ChangeContext( "SubSite", qr.FullPath, qr.TopicURL );
  169. }
  170. else
  171. {
  172. window.navigate( qr.TopicURL );
  173. }
  174. }
  175. }
  176. catch(e)
  177. {
  178. }
  179. }
  180. function node_Server_contextmenu()
  181. {
  182. var node = node_Server_find( event.srcElement ); if(!node) return;
  183. Common_CancelEvent();
  184. try
  185. {
  186. var qr = node.HC_PAYLOAD;
  187. if(qr)
  188. {
  189. pchealth.UI_NavBar.content.parentWindow.DoCommonContextMenu( -1, "subsite", qr );
  190. }
  191. }
  192. catch(e)
  193. {
  194. }
  195. }
  196. function node_Server_over()
  197. {
  198. var node = node_Server_find( event.srcElement ); if(!node) return;
  199. {
  200. var root = node.HC_ROOT;
  201. var top = node;
  202. var sel = [];
  203. var i;
  204. if(root.HC_SELECTED == node)
  205. {
  206. root.HC_PENDING = false;
  207. return;
  208. }
  209. while(top.HC_PARENT)
  210. {
  211. sel[top.uniqueID] = 1;
  212. top = top.HC_PARENT;
  213. }
  214. for(i in root.HC_CHAIN)
  215. {
  216. if(!sel[i])
  217. {
  218. node_Server_out_final( root.HC_COLL[i] );
  219. }
  220. }
  221. root.HC_CHAIN = sel;
  222. root.HC_SELECTED = node;
  223. root.HC_PENDING = false;
  224. }
  225. if(node.HC_FLYOUT && !node.HC_SUBNODES)
  226. {
  227. Server_Build( node );
  228. }
  229. switch(node.HC_POSITION)
  230. {
  231. case "root" : node.className = "Taxo-Block sys-background-strong sys-toppane-color-border Taxo-Block-Highlight" ; break;
  232. case "single": node.className = "Taxo-Block sys-background-strong sys-toppane-color-border Taxo-Block-Highlight-Single"; break;
  233. case "first" : node.className = "Taxo-Block sys-background-strong sys-toppane-color-border Taxo-Block-Highlight-First" ; break;
  234. case "middle": node.className = "Taxo-Block sys-background-strong sys-toppane-color-border Taxo-Block-Highlight-Middle"; break;
  235. case "last" : node.className = "Taxo-Block sys-background-strong sys-toppane-color-border Taxo-Block-Highlight-Last" ; break;
  236. }
  237. var cell = node.HC_ATTACHFLYOUT;
  238. if(cell && cell.style.display == "none")
  239. {
  240. cell.style.display = "";
  241. var div = cell.firstChild;
  242. var left = Common_GetLeftPosition( cell, true ) + cell.offsetWidth - 1;
  243. var top = Common_GetTopPosition ( cell, true ) - 1;
  244. var room;
  245. room = document.body.clientHeight - (top - document.body.scrollTop);
  246. if(room < div.offsetHeight)
  247. {
  248. top += room - div.offsetHeight; if(top < 0) top = 0;
  249. }
  250. if(window.document.documentElement.dir == "rtl")
  251. {
  252. div.style.right = document.body.clientWidth - left;
  253. }
  254. else
  255. {
  256. div.style.left = left;
  257. }
  258. div.style.top = top;
  259. }
  260. }
  261. function node_Server_out()
  262. {
  263. var node = node_Server_find( event.srcElement ); if(!node) return;
  264. var root = node.HC_ROOT;
  265. root.HC_PENDING = true;
  266. window.setTimeout( "node_Server_out_timeout( " + root.uniqueID + " )", 100 );
  267. }
  268. function node_Server_out_timeout( root )
  269. {
  270. if(root && root.HC_PENDING)
  271. {
  272. for(i in root.HC_CHAIN)
  273. {
  274. node_Server_out_final( root.HC_COLL[i] );
  275. }
  276. root.HC_CHAIN = [];
  277. root.HC_SELECTED = null;
  278. root.HC_PENDING = false;
  279. }
  280. }
  281. function node_Server_out_final( node )
  282. {
  283. node.className = "Taxo-Block";
  284. var cell = node.HC_ATTACHFLYOUT;
  285. if(cell && cell.style.display == "")
  286. {
  287. cell.style.display = "none";
  288. }
  289. }