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.

159 lines
4.5 KiB

  1. function ChangeUser()
  2. {
  3. var oUser = this.oUser;
  4. if (oUser)
  5. {
  6. top.window.g_oSelectedUser = oUser;
  7. top.window.g_Navigator.navigate("mainpage.htm");
  8. }
  9. }
  10. function SetRelativeCells(tr, td)
  11. {
  12. // Keep track of neighboring cells for arrow key navigation
  13. var iCol = td.cellIndex;
  14. if (iCol > 0)
  15. {
  16. var oLeft = tr.cells(iCol-1);
  17. td.leftElem = oLeft;
  18. oLeft.rightElem = td;
  19. }
  20. var iRow = tr.rowIndex;
  21. if (iRow > 0)
  22. {
  23. var oUp = tr.parentElement.rows(iRow-1).cells(iCol);
  24. td.upElem = oUp;
  25. oUp.downElem = td;
  26. }
  27. }
  28. function AddCell(tr, oUser, strTip, strSubtitle)
  29. {
  30. if (oUser)
  31. {
  32. //
  33. // NTRAID#NTBUG9-348526-2001/04/12-jeffreys
  34. //
  35. // Note that we put a whole bunch of stuff into the cell's title. It
  36. // is the td that gets focus when navigating via keyboard, and narrator
  37. // reads the title of the element with focus.
  38. //
  39. // At the same time, we set a different title on the table
  40. // element contained as the first child of the cell. This table
  41. // covers the entire td, so this title is displayed as a tooltip
  42. // when the user hovers the mouse over the cell.
  43. //
  44. if (!strTip)
  45. strTip = top.window.L_Account_ToolTip;
  46. var td = tr.insertCell();
  47. td.className = "Selectable";
  48. td.oUser = oUser;
  49. td.onclick = ChangeUser;
  50. td.tabIndex = -1;
  51. td.innerHTML = top.window.CreateUserDisplayHTML(oUser, strSubtitle);
  52. td.firstChild.title = strTip;
  53. td.title = td.firstChild.innerText + ". " + strTip;
  54. SetRelativeCells(tr, td);
  55. }
  56. }
  57. function CreateUserSelectionTable(oParent, cCols)
  58. {
  59. var oTable = document.createElement('<TABLE cellspacing=10 cellpadding=1 style="table-layout:fixed"></TABLE>');
  60. if (!oTable)
  61. {
  62. oParent.style.display = 'none';
  63. return;
  64. }
  65. // Defined these here so we don't incur the "top.window.xxx"
  66. // property lookup every time through the loop.
  67. var oUserList = top.window.g_oUserList;
  68. var strGuest = top.window.GetGuestName();
  69. var strLoggedOnUser = top.window.g_strLoggedOnUserName;
  70. var fIncludeSelf = (null != strLoggedOnUser);
  71. var cUsers = oUserList.length;
  72. var oGuest = null;
  73. if (!cCols || cCols < 1)
  74. cCols = 1;
  75. oTable.cols = cCols;
  76. var tr = oTable.insertRow();
  77. for (var i = 0; i < cUsers; i++)
  78. {
  79. var oUser = oUserList(i);
  80. var strLoginName = oUser.setting("LoginName").toLowerCase();
  81. // Add "Guest" later
  82. if (strGuest.toLowerCase() == strLoginName)
  83. {
  84. oGuest = oUser;
  85. continue;
  86. }
  87. var bIsLoggedOnUser = strLoggedOnUser ? (strLoginName == strLoggedOnUser) : false;
  88. //
  89. // fIncludeSelf causes the LoggedOnUser to be
  90. // placed first in the list
  91. //
  92. if (fIncludeSelf || !bIsLoggedOnUser)
  93. {
  94. if (fIncludeSelf)
  95. {
  96. if (!bIsLoggedOnUser)
  97. {
  98. oUser = oUserList.currentUser;
  99. i--;
  100. }
  101. fIncludeSelf = false;
  102. }
  103. AddCell(tr, oUser);
  104. if (tr.cells.length == cCols)
  105. tr = oTable.insertRow();
  106. }
  107. }
  108. try
  109. {
  110. // Add the "Guest" entry now
  111. if (top.window.GetLocalMachine().isGuestEnabled(1))
  112. {
  113. // Enabled Guest is a real entry (from oUserList)
  114. AddCell(tr, oGuest, top.window.L_Guest_ToolTip, top.window.L_GuestEnabled_Property);
  115. }
  116. else
  117. {
  118. // Disabled Guest is a fake entry
  119. var td = tr.insertCell();
  120. td.className = "Selectable";
  121. td.onclick = new Function("top.window.g_Navigator.navigate('enableguest.htm');");
  122. td.tabIndex = -1;
  123. td.innerHTML = top.window.CreateUserDisplayHTML2(strGuest, top.window.L_GuestDisabled_Property, "guest_disabled.bmp");
  124. td.firstChild.title = top.window.L_GuestEnable_ToolTip;
  125. td.title = td.firstChild.innerText + ". " + td.firstChild.title;
  126. SetRelativeCells(tr, td);
  127. }
  128. }
  129. catch (e)
  130. {
  131. }
  132. oTable.cells.item(0).tabIndex = 0;
  133. oParent.appendChild(oTable);
  134. }