Source code of Windows XP (NT5)
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.

172 lines
4.7 KiB

  1. // These are used frequently in the links on mainpage.htm
  2. var _oNav = top.window.g_Navigator;
  3. var _bRunningAsOwner = top.window.g_bRunningAsOwner;
  4. var _bUserHasPassword;
  5. var _bUserIsAdmin;
  6. var _bUserIsGuest;
  7. var _bUserIsOwner;
  8. var _oPassportMgr = null;
  9. var _strPassport = null;
  10. function InitTasks(bSelf, szInitialTask)
  11. {
  12. var aTasks = bSelf ? idSelfTaskLinks : idTaskLinks;
  13. var cTasks = aTasks.length;
  14. var oInitialTask = null;
  15. for (var i = 0; i < cTasks; i++)
  16. {
  17. var oTask = aTasks[i];
  18. if (eval(oTask.expression))
  19. {
  20. // Show the task
  21. oTask.style.display = 'block';
  22. // If an initial task was specified and this is it,
  23. // redirect to that page.
  24. if (szInitialTask && szInitialTask == oTask.task)
  25. {
  26. oInitialTask = oTask;
  27. szInitialTask = null;
  28. }
  29. }
  30. else
  31. {
  32. // Hide the task
  33. oTask.style.display = 'none';
  34. }
  35. }
  36. top.window.SetRelativeTasks(aTasks);
  37. if (oInitialTask)
  38. oInitialTask.firstChild.click();
  39. }
  40. function PageInit()
  41. {
  42. var oUser = top.window.g_oSelectedUser;
  43. var bSelf = top.window.IsSelf();
  44. var strLoginName = oUser.setting("LoginName").toLowerCase();
  45. _bUserHasPassword = oUser.passwordRequired;
  46. _bUserIsAdmin = (strLoginName == top.window.GetAdminName().toLowerCase());
  47. _bUserIsGuest = (strLoginName == top.window.GetGuestName().toLowerCase());
  48. _bUserIsOwner = (3 == oUser.setting("AccountType"));
  49. if (bSelf)
  50. {
  51. try
  52. {
  53. _oPassportMgr = new ActiveXObject("UserAccounts.PassportManager");
  54. _strPassport = _oPassportMgr.currentPassport;
  55. if (_strPassport && 0 == _strPassport.length)
  56. _strPassport = null;
  57. }
  58. catch (e)
  59. {
  60. }
  61. }
  62. // Owners and non-owners see different stuff in the left pane.
  63. var szRelatedTaskContent = bSelf ? idSelfRelatedTaskContent.innerHTML : "";
  64. var szLearnAboutContent;
  65. if (_bRunningAsOwner)
  66. {
  67. szRelatedTaskContent += idRelatedTaskContent.innerHTML;
  68. szLearnAboutContent = bSelf ? idOwnerLearnAboutContent.innerHTML : null;
  69. }
  70. else
  71. {
  72. if (!bSelf)
  73. szRelatedTaskContent = null;
  74. szLearnAboutContent = idLearnAboutContent.innerHTML;
  75. }
  76. top.window.PopulateLeftPane(szRelatedTaskContent, szLearnAboutContent);
  77. // Set the title
  78. var szTitle = bSelf ? (_bRunningAsOwner ? idOwnerSelfTitle.innerHTML : idPageTitle.innerHTML)
  79. : (_bUserIsGuest ? idGuestPageTitle.innerHTML : idAltPageTitle.innerHTML);
  80. idPageTitle.innerHTML = szTitle.replace(/%1/g, top.window.GetUserDisplayName(oUser));
  81. // Create a new user infomation display element
  82. idUser.innerHTML = top.window.CreateUserDisplayHTML(oUser);
  83. // Special text for the Administrator account
  84. if (_bUserIsAdmin)
  85. idAdminText.style.display = 'block';
  86. // See if there is an initial task to do
  87. var szInitialTask = top.window.g_szInitialTask;
  88. if (szInitialTask)
  89. {
  90. // Protect against doing the initial task more than once, but remember
  91. // what the initial task was (i.e. never reset g_szInitialTask).
  92. if (top.window.g_bInitialTaskCompleted)
  93. szInitialTask = null;
  94. else
  95. top.window.g_bInitialTaskCompleted = true;
  96. // Note that g_bInitialTaskCompleted is always true here, even if we
  97. // never actually go to the task page (it may be an invalid task).
  98. }
  99. // Set the tasks
  100. InitTasks(bSelf, szInitialTask);
  101. // No buttons or edit boxes on this page to give focus to, but
  102. // focus has to go somewhere for the onkeydown handler to work.
  103. window.focus();
  104. }
  105. function DeleteUser()
  106. {
  107. if (top.window.GetLocalMachine().isMultipleUsersEnabled && top.window.g_oSelectedUser.isLoggedOn)
  108. {
  109. alert(top.window.L_DeleteInUse_ErrorMessage);
  110. return false;
  111. }
  112. _oNav.navigate('DeletePage.htm');
  113. }
  114. function OnKeyDown()
  115. {
  116. if (event.keyCode == 27) // VK_ESCAPE
  117. top.window.g_Navigator.back();
  118. }
  119. function OnKeySelect()
  120. {
  121. top.window.OnKeySelect(0, event);
  122. }
  123. function CreatePassport()
  124. {
  125. _oPassportMgr.showWizard(top.window.document.title);
  126. _strPassport = _oPassportMgr.currentPassport;
  127. if (_strPassport && 0 == _strPassport.length)
  128. _strPassport = null;
  129. InitTasks(true);
  130. }
  131. function ShowKeyManager()
  132. {
  133. _oPassportMgr.showKeyManager(top.window.document.title);
  134. _strPassport = _oPassportMgr.currentPassport;
  135. if (_strPassport && 0 == _strPassport.length)
  136. _strPassport = null;
  137. InitTasks(true);
  138. }