home *** CD-ROM | disk | FTP | other *** search
/ Chip 2009 November / Chip_2009.11_CD.iso / I386 / nusrmgr.cp_ / nusrmgr.cpl / HTML / PW_COMMON.JS < prev    next >
Encoding:
Text File  |  2008-04-14  |  2.3 KB  |  102 lines

  1. function GetText(oTextInput)
  2. {
  3. var szValue = oTextInput.value;
  4. return szValue ? szValue : '';
  5. }
  6. function PWInit(bSelf)
  7. {
  8. var oUser = top.window.g_oSelectedUser;
  9. var szName = top.window.GetUserDisplayName(oUser);
  10. idPageTitle.innerHTML = idPageTitle.innerHTML.replace(/%1/g, szName);
  11. top.window.PopulateLeftPane(null, idLearnAboutContent.innerHTML);
  12. idHintDefn.ttText = bSelf ? top.window.L_SelfHint_ToolTip : top.window.L_NonSelfHint_ToolTip;
  13. if (!bSelf)
  14. {
  15. var strReset = (top.window.g_bOsPersonal ? L_Personal_Message : L_Pro_Message) + (oUser.isPasswordResetAvailable ? L_Backup_Message : L_NoBackup_Message);
  16. idResetWarning.innerHTML = strReset.replace(/%1/g, szName);
  17. }
  18. idNewPassword1Input.focus();
  19. }
  20. function ApplyPasswordChange()
  21. {
  22. var szNewPassword1 = GetText(idNewPassword1Input);
  23. var szNewPassword2 = GetText(idNewPassword2Input);
  24. if (szNewPassword1 == szNewPassword2)
  25. {
  26. var oUser = top.window.g_oSelectedUser;
  27. var bSelf = top.window.IsSelf();
  28. var bOldPW = oUser.passwordRequired;
  29. var nErr = 0;
  30. try
  31. {
  32. oUser.changePassword(szNewPassword1, (bSelf && bOldPW) ? GetText(idOldPasswordInput) : "");
  33. oUser.setting("Hint") = GetText(idHintInput);
  34. }
  35. catch (e)
  36. {
  37. nErr = (e.number & 0xffff);
  38. }
  39. if (0 == nErr)
  40. {
  41. if (top.window.g_szInitialTask != "ChangePassword" &&
  42. bSelf && !bOldPW &&
  43. top.window.g_bRunningAsOwner)
  44. {
  45. var bPrivate = false;
  46. var bCanMakePrivate = true;
  47. try
  48. {
  49. bPrivate = oUser.isProfilePrivate;
  50. }
  51. catch (e)
  52. {
  53. bCanMakePrivate = false;
  54. }
  55. if (bCanMakePrivate && !bPrivate)
  56. {
  57. top.window.g_Navigator.navigate("passwordpage2.htm");
  58. return;
  59. }
  60. }
  61. top.window.g_Navigator.navigate("mainpage.htm", true);
  62. }
  63. else
  64. {
  65. idNewPassword1Input.value = '';
  66. idNewPassword2Input.value = '';
  67. idHintInput.value = '';
  68. idNewPassword1Input.focus();
  69. var strMsg = top.window.L_ChangePassword_ErrorMessage;
  70. switch (nErr)
  71. {
  72. case 86: 
  73. case 1323: 
  74. if (bSelf && bOldPW)
  75. {
  76. idOldPasswordInput.value = '';
  77. idOldPasswordInput.focus();
  78. strMsg = top.window.L_InvalidPassword_Message;
  79. }
  80. break;
  81. case 1324: 
  82. case 1325: 
  83. case 1327: 
  84. case 2243: 
  85. case 2244: 
  86. case 2245: 
  87. case 2246: 
  88. strMsg = top.window.L_PasswordTooShort_Message;
  89. break;
  90. }
  91. alert(strMsg);
  92. }
  93. }
  94. else
  95. {
  96. idNewPassword1Input.value = '';
  97. idNewPassword2Input.value = '';
  98. idNewPassword1Input.focus();
  99. alert(top.window.L_PasswordMismatch_Message);
  100. }
  101. }
  102.