console.log("javascript added"); $(document).ready(function () { requestAccount(); setupPwdTogglers(); setupLoginForm(); setupExpiredInvitation(); setupCaseResponse(); setupEmailValidation(); setupPasswordReset(); setupQRCodePage(); setupPhoneVerification(); setupAuthenticatorVerificationPage(); setUpChangeMFA(); }); // Single function to handle all password toggle functionality function addPasswordToggle(passwordInput) { if (!passwordInput) return; const div = document.createElement('div'); div.style.cssText = "display: flex"; const pwFieldParent = passwordInput.parentElement; const errorLevel = pwFieldParent.querySelector(".itemLevel"); // Create and style the image button const image = document.createElement('img'); image.src = portalURL + '/showpw.png'; image.alt = "Show password"; image.style.cssText = "height: 41px;"; image.setAttribute("id", "viewPasswordButton"); // Style the password input passwordInput.style.cssText = "max-width: 96%; border-top-right-radius:0px; border-bottom-right-radius:0px;"; // Insert elements in correct order if (errorLevel) { errorLevel.insertAdjacentElement("afterend", div); } else { pwFieldParent.appendChild(div); } div.appendChild(passwordInput); passwordInput.insertAdjacentElement("afterend", image); // Add toggle functionality image.onclick = function () { if (passwordInput.type === 'password') { passwordInput.type = 'text'; } else { passwordInput.type = 'password'; } }; } // Setup function to initialize password toggles function setupPwdTogglers() { // Handle login page password field const loginPassword = document.querySelector('#password'); if (loginPassword) { addPasswordToggle(loginPassword); } // Handle password reset fields const newPassword = document.querySelector('#newPassword'); const reenterPassword = document.querySelector('#reenterPassword'); if (newPassword) addPasswordToggle(newPassword); if (reenterPassword) addPasswordToggle(reenterPassword); // If no password fields found yet, retry if (!loginPassword && !newPassword && !reenterPassword) { setTimeout(setupPwdTogglers, 400); } } function requestAccount(retryCount = 0, maxRetries = 20) { var form = document.getElementById('next'); if (!form) { if (retryCount < maxRetries) { setTimeout(() => requestAccount(retryCount + 1, maxRetries), 100); } return; } var signInButton = document.getElementById("next"); var div = document.createElement('div'); var anchor = document.createElement('a'); if (signInButton !== null) { anchor.href = portalURL + "/Help/Contact-Us/Support-Request/?req=NeedAccount"; anchor.textContent = "Request a Partner Portal account"; anchor.style.cssText = "text-decoration: underline; font-ize:16px;" div.innerText = "Don't have an account yet?"; div.style.cssText = "font-weight: 700; font-size: 20px; padding-top:15px;"; signInButton.insertAdjacentElement("afterend", div); div.insertAdjacentElement("afterend", anchor); var divSupport = document.createElement('div'); var anchorSupport = document.createElement('a'); anchorSupport.href = portalURL + "/Help/Contact-Us/Support-Request/"; anchorSupport.textContent = "Open a support request to get help with your account"; anchorSupport.style.cssText = "text-decoration: underline; font-ize:16px;" divSupport.innerText = "Having trouble logging in?"; divSupport.style.cssText = "font-weight: 700; font-size: 20px; padding-top:15px;"; anchor.insertAdjacentElement("afterend", divSupport); divSupport.insertAdjacentElement("afterend", anchorSupport); } } function setupPasswordReset(retryCount = 0, maxRetries = 20) { var form = document.getElementById('attributeVerification'); if (!form) { if (retryCount < maxRetries) { setTimeout(() => setupPasswordReset(retryCount + 1, maxRetries), 100); } return; } // Check if we're on the password reset page var emailInput = document.getElementById('email'); if (emailInput) { // Style email input structure var listItem = document.querySelector('li.TextBox.email'); listItem.style.cssText = ` display: block !important; padding-left: 32px !important; width: calc(100% - 64px) !important; margin: 0 !important; box-sizing: border-box !important; text-align: left !important; list-style-type: none !important; `; // Then style the attrEntry var attrEntry = listItem.querySelector('.attrEntry'); attrEntry.style.cssText = ` display: block !important; width: 100% !important; margin: 0 !important; padding: 0 !important; box-sizing: border-box !important; min-width: 0 !important; `; // Trigger an input event to force styles to apply if (emailInput) { var event = new Event('input', { bubbles: true, cancelable: true, }); emailInput.dispatchEvent(event); } // Also ensure the parent ul has correct styles var parentUl = listItem.parentElement; parentUl.style.cssText = ` list-style-type: none; margin: 0; padding: 0; `; // Always hide send new code button var sendNewCodeButton = document.getElementById('emailVerificationControl_but_send_new_code'); if (sendNewCodeButton) { sendNewCodeButton.style.display = 'none'; } // Add observer to keep it hidden at all times var buttonObserver = new MutationObserver(function () { if (sendNewCodeButton) { sendNewCodeButton.style.display = 'none'; } }); if (sendNewCodeButton) { buttonObserver.observe(sendNewCodeButton, { attributes: true, attributeFilter: ['style'] }); } // Add heading before the attributeList var attributeList = document.getElementById("attributeList"); if (attributeList && !document.querySelector('h2')) { var headingDiv = document.createElement('div'); headingDiv.style.cssText = "padding-left: 32px; margin-bottom: 10px;"; headingDiv.innerHTML = '

Forgot Your Password?

'; attributeList.parentNode.insertBefore(headingDiv, attributeList); } // Hide main continue and cancel buttons var mainButtonsDiv = form.querySelector('.buttons:not(.verificationControlContent .buttons)'); if (mainButtonsDiv) { mainButtonsDiv.style.display = 'none'; } // Show verification info message and all its parent containers var verificationControl = document.getElementById('emailVerificationControl'); var verificationInfoText = document.querySelector('.verificationInfoText'); var verificationIntro = document.getElementById("emailVerificationControl_info_message"); function showVerificationMessage() { if (verificationControl) { verificationControl.style.display = 'block'; } if (verificationInfoText) { verificationInfoText.style.display = 'block'; } if (verificationIntro) { verificationIntro.style.display = 'inline'; verificationIntro.setAttribute('aria-hidden', 'false'); verificationIntro.setAttribute('role', 'alert'); } } // Initial setup showVerificationMessage(); if (verificationIntro) { verificationIntro.innerHTML = `Enter your email address to get a verification code and begin the process to reset your password.

If you have forgotten the email address you use to log in, you may use your recovery email address instead. If you do not have a recovery email address, or cannot remember it, you will need to open a support request to get assistance.`; } // Show send verification code button and its container var verificationButtonsContainer = document.querySelector('.verificationControlContent .buttons'); if (verificationButtonsContainer) { verificationButtonsContainer.style.display = 'block'; var sendCodeButton = document.getElementById('emailVerificationControl_but_send_code'); if (sendCodeButton) { sendCodeButton.style.display = 'inline'; sendCodeButton.setAttribute('aria-hidden', 'false'); } } // Watch for any changes to the verification intro visibility var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'style' && verificationIntro.style.display === 'none') { // Only show message if we're still in Stage 1 if (!document.querySelector('.TextBox.VerificationCode[style*="display: inline"]')) { showVerificationMessage(); } } }); }); if (verificationIntro) { observer.observe(verificationIntro, { attributes: true, attributeFilter: ['style'] }); } // Update email label var emailLabel = document.getElementById("email_label"); if (emailLabel) { emailLabel.innerHTML = `Email Address *`; } // Watch for verification code input to become visible (Stage 2) var verificationInput = document.querySelector('.TextBox.VerificationCode'); var verificationLabel = document.getElementById('VerificationCode_label'); // Create MutationObserver for the verification input var verificationObserver = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.attributeName === 'style' && verificationInput.style.display === 'inline') { // Stage 2 setup handleStage2(); } }); }); // Watch for change claims button (Stage 3) var changeClaimsButton = document.getElementById('emailVerificationControl_but_change_claims'); if (changeClaimsButton) { new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.attributeName === 'style' && changeClaimsButton.style.display === 'inline') { // Stage 3 setup handleStage3(); } }); }).observe(changeClaimsButton, { attributes: true, attributeFilter: ['style'] }); } // Start observing the verification input if (verificationInput) { verificationObserver.observe(verificationInput, { attributes: true, attributeFilter: ['style'] }); } // Watch for change button click (return to Stage 1) if (changeClaimsButton) { changeClaimsButton.addEventListener('click', function () { // Reset heading var heading = document.querySelector('h2'); if (heading) { heading.textContent = 'Forgot Your Password?'; } // Enable email input var emailInput = document.getElementById('email'); if (emailInput) { emailInput.disabled = false; } // Show verification intro message and hide success message var verificationIntro = document.getElementById('emailVerificationControl_info_message'); var successMessage = document.getElementById('emailVerificationControl_success_message'); if (verificationIntro) { verificationIntro.style.display = 'inline'; verificationIntro.setAttribute('aria-hidden', 'false'); } // Hide continue/cancel buttons and their container var mainButtonsDiv = document.querySelector('.buttons:not(.verificationControlContent .buttons)'); if (mainButtonsDiv) { mainButtonsDiv.style.display = 'none'; var continueButton = document.getElementById('continue'); var cancelButton = document.getElementById('cancel'); if (continueButton) continueButton.style.display = 'none'; if (cancelButton) cancelButton.style.display = 'none'; } // Show send code button var sendCodeButton = document.getElementById('emailVerificationControl_but_send_code'); if (sendCodeButton) { sendCodeButton.style.display = 'inline'; sendCodeButton.setAttribute('aria-hidden', 'false'); } }); } // Add observer for the main buttons to keep them hidden after change button click var mainButtonsDiv = document.querySelector('.buttons:not(.verificationControlContent .buttons)'); if (mainButtonsDiv) { new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.attributeName === 'style' && mainButtonsDiv.style.display === 'block') { // Only hide if we're not in Stage 3 var changeButton = document.getElementById('emailVerificationControl_but_change_claims'); if (!changeButton || changeButton.style.display !== 'inline') { mainButtonsDiv.style.display = 'none'; } } }); }).observe(mainButtonsDiv, { attributes: true, attributeFilter: ['style'] }); } } } function handleStage2() { // Update heading var heading = document.querySelector('h2'); if (heading) { heading.textContent = 'Enter Verification Code'; } // Hide email input and label var emailLabel = document.getElementById('email_label'); var emailInput = document.getElementById('email'); if (emailLabel) emailLabel.style.display = 'none'; if (emailInput) emailInput.style.display = 'none'; // Update verification code section to match email section structure var verificationLabel = document.getElementById('VerificationCode_label'); var verificationInput = document.getElementById('VerificationCode'); if (verificationLabel) { verificationLabel.innerHTML = `Verification code *`; verificationLabel.style.display = 'block'; } // Copy styles from email input to verification input if (emailInput && verificationInput) { var emailStyles = window.getComputedStyle(emailInput); verificationInput.style.cssText = emailStyles.cssText; // Ensure specific styles are copied verificationInput.style.width = emailStyles.width; verificationInput.style.border = emailStyles.border; verificationInput.style.borderRadius = emailStyles.borderRadius; verificationInput.style.backgroundColor = emailStyles.backgroundColor; verificationInput.style.padding = emailStyles.padding; verificationInput.style.margin = emailStyles.margin; verificationInput.style.height = emailStyles.height; verificationInput.style.fontSize = emailStyles.fontSize; verificationInput.style.color = emailStyles.color; // Update placeholder text verificationInput.placeholder = 'Code'; } // Clear and update verification instructions var verificationIntro = document.getElementById('emailVerificationControl_info_message'); if (verificationIntro) { verificationIntro.style.display = 'none'; verificationIntro.setAttribute('aria-hidden', 'true'); } // Update verification info var verificationInfo = document.querySelector('.verificationSuccessText div'); if (verificationInfo) { verificationInfo.style.display = 'inline'; verificationInfo.innerHTML = `Check your inbox and enter the code you received below. The email may be in your spam or junk folder. If you don't receive an email within 10 minutes, Request a new code.`; // Watch for any changes to the verification info visibility var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'style' && verificationInfo.style.display === 'none') { // Keep verification info visible in Stage 2 verificationInfo.style.display = 'inline'; verificationInfo.setAttribute('aria-hidden', 'false'); } }); }); observer.observe(verificationInfo, { attributes: true, attributeFilter: ['style'] }); } // Show send code button, show verify code button, and hide send new code button var sendCodeButton = document.getElementById('emailVerificationControl_but_send_code'); var verifyCodeButton = document.getElementById('emailVerificationControl_but_verify_code'); var sendNewCodeButton = document.getElementById('emailVerificationControl_but_send_new_code'); if (sendCodeButton) sendCodeButton.style.display = 'none'; if (verifyCodeButton) { verifyCodeButton.style.display = 'inline'; verifyCodeButton.innerHTML = 'Submit Code'; } if (sendNewCodeButton) sendNewCodeButton.style.display = 'none'; } function handleStage3() { // Update heading var heading = document.querySelector('h2'); if (heading) { heading.textContent = 'Email Verified'; } // Show email label and input var emailLabel = document.getElementById('email_label'); var emailInput = document.getElementById('email'); if (emailLabel) { emailLabel.style.display = 'block'; } if (emailInput) { emailInput.style.display = 'inline'; emailInput.disabled = true; } // Show continue button and its container var continueButton = document.getElementById('continue'); var changeButton = document.getElementById('emailVerificationControl_but_change_claims'); if (continueButton) { continueButton.style.display = 'inline'; // Also show the parent buttons container var buttonsContainer = continueButton.parentElement; if (buttonsContainer) { buttonsContainer.style.display = 'block'; } } if (changeButton) { changeButton.innerHTML = 'Change e-mail'; } } // Handle resend code click window.handleResendCode = function () { var sendNewCodeButton = document.getElementById('emailVerificationControl_but_send_new_code'); if (sendNewCodeButton) { sendNewCodeButton.click(); } }; function setupQRCodePage(retryCount = 0, maxRetries = 20) { const form = document.getElementById('attributeVerification'); if (!form) { if (retryCount < maxRetries) { setTimeout(() => setupQRCodePage(retryCount + 1, maxRetries), 100); } return; } // Check if we're on the QR code setup page const authenticatorControl = form.querySelector('.authenticatorAppIconControl_li'); if (!authenticatorControl) return; // Hide "User Details" heading and intro const heading = document.querySelector('.heading h1'); const intro = document.querySelector('.intro'); if (heading) heading.style.display = 'none'; if (intro) intro.style.display = 'none'; // Add MFA setup header if not exists if (!document.getElementById('mfaMessageTitle')) { const headerDiv = document.createElement('div'); headerDiv.className = 'attrEntry'; headerDiv.innerHTML = `

Set Up Multi-Factor Authentication

`; form.insertBefore(headerDiv, form.firstChild); } // Update app download instructions const appTitle = document.getElementById('authenticatorAppIconControl-title'); if (appTitle) { appTitle.textContent = 'Download the Microsoft Authenticator using the download links for iOS or Android, or use another authenticator app of your choice.'; } // Hide the instruction label var instructionLabel = document.getElementById('QrCodeScanInstruction_label'); if (instructionLabel) { instructionLabel.style.display = 'none'; } // Update QR code instructions const qrTitle = document.getElementById('totpQrCodeControl-title'); if (qrTitle) { qrTitle.textContent = 'Scan the QR code below.'; } // Update the "Having trouble?" message as a clickable div with spacing var qrCodeInfo = document.getElementById('totpQrCodeControl_info_message'); if (qrCodeInfo) { // qrCodeInfo.innerHTML = ` //
// Having trouble?
Enter the details in your authenticator app manually
//
// `; qrCodeInfo.style.display="none"; } // Hide the original "Can't scan?" link var cantScanLink = document.querySelector('#totpQrCodeControl a[href^="otpauth"]'); if (cantScanLink) { cantScanLink.style.display = 'none'; } var appStore = document.querySelector("#authenticatorAppIconControl"); if (appStore !== null) { var div = document.createElement('div'); var header = document.createElement('h2'); header.textContent = "Step 1"; header.style.cssText = "font-weight: 700; font-size:20px;"; appStore.prepend(div) div.appendChild(header); } var qrCode = document.getElementById("totpQrCodeControl"); if (qrCode !== null) { var div2 = document.createElement('div'); var header2 = document.createElement('h2'); header2.textContent = "Step 2"; header2.style.cssText = "font-weight: 700; font-size:20px;"; qrCode.prepend(div2) div2.appendChild(header2); } } function setupPhoneVerification(retryCount = 0, maxRetries = 20) { var form = document.querySelector('div[data-name="Phonefactor"]'); if (!form) { if (retryCount < maxRetries) { setTimeout(() => setupPhoneVerification(retryCount + 1, maxRetries), 100); } return; } var countryCode = document.getElementById("countryCode"); if(countryCode !== null){ countryCode.ariaRequired = true; } var heading = form.querySelector('.heading h1'); if (heading) { heading.ariaLevel = "1"; } // Check which page we're on var phoneEntry = form.querySelector('#phoneEntry'); var phoneNumbers = form.querySelector('#phoneNumbers'); // Handle Phone Selection screen (Screen1) if (phoneNumbers && !phoneEntry) { var heading = form.querySelector('.heading h1'); if (heading) { heading.textContent = "Multi-Factor Authentication"; heading.style.cssText = "color: rgb(26, 71, 110); font-size: 40px; font-weight: 600; font-family: Tahoma;"; heading.ariaLevel = "1"; } // Update phone number display var phoneNumberDiv = phoneNumbers.querySelector('.phoneNumber'); if (phoneNumberDiv) { var typeDiv = phoneNumberDiv.querySelector('.type'); var numberDiv = phoneNumberDiv.querySelector('.number'); if (typeDiv && numberDiv) { // Combine phone number into the first line typeDiv.textContent = "A code will be sent to the following phone number: " + numberDiv.textContent; typeDiv.style.cssText = "font-family: Tahoma; color: rgb(26, 71, 110);"; numberDiv.style.display = 'none'; // Hide the original number div } // Add second line var howToReceiveDiv = document.createElement('div'); howToReceiveDiv.textContent = "How would you like to receive your code?"; howToReceiveDiv.style.cssText = "font-family: Tahoma; color: rgb(26, 71, 110); margin-top: 10px;"; phoneNumberDiv.appendChild(howToReceiveDiv); } // Update Send Code button text and hide cancel button var sendCodeBtn = form.querySelector('#sendCode'); var cancelBtn = form.querySelector('#cancel'); if (sendCodeBtn) { sendCodeBtn.textContent = 'Text me'; } if (cancelBtn) { cancelBtn.style.cssText = "display: none !important;"; } } // Create observer for verification page changes const verificationObserver = new MutationObserver((mutations) => { // Check if we're on verification page var verifyCodeBtn = form.querySelector('#verifyCode'); var sendCodeBtn = form.querySelector('#sendCode'); if (!verifyCodeBtn || !sendCodeBtn || getComputedStyle(verifyCodeBtn).display !== 'inline-block' || getComputedStyle(sendCodeBtn).display !== 'none') { return; } console.log("On verification page - applying changes"); // Update heading with specific styling var heading = form.querySelector('.heading h1'); if (heading) { heading.textContent = "Enter Multi-Factor Authentication Code"; heading.style.cssText = "color: rgb(26, 71, 110); font-size: 40px; font-weight: 600; font-family: Tahoma;"; heading.ariaLevel = "1"; } // Hide phone numbers section on verification page if (phoneNumbers) { phoneNumbers.style.display = 'none'; } // Hide phone number and keep it hidden with observer var readonlyDiv = form.querySelector('.phoneEntry .readonly'); if (readonlyDiv) { readonlyDiv.style.cssText = "display: none !important;"; // Create observer to ensure phone number stays hidden const phoneObserver = new MutationObserver(() => { if (readonlyDiv.style.display !== 'none') { readonlyDiv.style.cssText = "display: none !important;"; } }); phoneObserver.observe(readonlyDiv, { attributes: true, attributeFilter: ['style'] }); } // Update verification code section var actionLabel = form.querySelector('.actionLabel'); if (actionLabel) { var verifyCodeLabel = actionLabel.querySelector('label[for="verificationCode"]'); if (verifyCodeLabel) { var retryCode = document.getElementById('retryCode'); verifyCodeLabel.removeAttribute("for"); if (retryCode) { retryCode.style.cssText = "font-weight: 700; font-size:14px; font-family: Tahoma; color:#1a476e; text-decoration:underline; cursor: pointer;"; } verifyCodeLabel.innerHTML = `Enter the 6-digit code you received below. Didn't receive a code? `; verifyCodeLabel.appendChild(retryCode); verifyCodeLabel.style.marginBottom = "10px"; if (retryCode) { retryCode.textContent = 'Request a new code'; } // Add Authentication Code label var authCodeLabel = document.createElement("label"); authCodeLabel.setAttribute("for", "verificationCode"); authCodeLabel.innerHTML = 'Authentication Code *'; verifyCodeLabel.insertAdjacentElement("afterend", authCodeLabel); } } // Update verify button if (verifyCodeBtn) { verifyCodeBtn.innerHTML = 'Submit Code'; } // Hide cancel button var cancelButton = form.querySelector('#cancel'); if (cancelButton) { cancelButton.style.cssText = "display: none !important;"; } // Disconnect main observer once we're done verificationObserver.disconnect(); }); // Start observing the form verificationObserver.observe(form, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); } function setupAuthenticatorVerificationPage(retryCount = 0, maxRetries = 20) { const form = document.getElementById('attributeVerification'); if (!form) { if (retryCount < maxRetries) { setTimeout(() => setupAuthenticatorVerificationPage(retryCount + 1, maxRetries), 100); } return; } // Check if we're on verification page (not QR setup page) const otpCodeInput = form.querySelector('#otpCode'); const qrSetupPage = form.querySelector('.authenticatorAppIconControl_li'); if (!otpCodeInput || qrSetupPage) return; // Hide "User Details" heading and intro const heading = document.querySelector('.heading h1'); const intro = document.querySelector('.intro'); if (heading) heading.style.display = 'none'; if (intro) intro.style.display = 'none'; // Add MFA verification header if not exists if (!document.getElementById('mfaHeader')) { const headerDiv = document.createElement('div'); headerDiv.className = 'attrEntry'; headerDiv.innerHTML = `

Enter Multi-Factor Authentication Code

`; form.insertBefore(headerDiv, form.firstChild); } // Update instruction text const instruction = document.querySelector('#QrCodeVerifyInstruction_label'); if (instruction) { instruction.textContent = 'Enter the code from your Authenticator App.'; } // Update OTP code label const otpLabel = document.querySelector('#otpCode_label'); if (otpLabel) { otpLabel.innerHTML = 'Authentication Code'; } // Update input placeholder and continue button if (otpCodeInput) { otpCodeInput.placeholder = 'Code'; otpCodeInput.setAttribute('aria-label', 'Code'); } const continueButton = form.querySelector('#continue'); if (continueButton) { continueButton.innerHTML = 'Submit Code'; continueButton.setAttribute('aria-label', 'Submit Code'); } } function setupLoginForm(retryCount = 0, maxRetries = 20) { var form = document.getElementById("localAccountForm"); if (!form) { if (retryCount < maxRetries) { setTimeout(() => setupLoginForm(retryCount + 1, maxRetries), 100); } return; } if (form !== null) { var header = form.querySelector("h2"); if (header !== null) { header.style.cssText = "font-weight: 700;"; header.innerText = "Log in to the LEARN Portal"; } } var continueButton = document.getElementById("continue"); if (continueButton !== null) { continueButton.innerHTML = "Next"; } // Hide "User Details" heading var headTags = document.querySelectorAll('[role="heading"]'); for (let headTag of headTags) { if (headTag.innerHTML == "User Details") { headTag.style.cssText = "display: none;" } } var email = document.getElementById("signInName"); if (email !== null) { email.required = true; } // Add password validation error handling var passwordField = document.getElementById("password"); if (passwordField !== null) { // Make sure the password is required passwordField.required = true; // Get the parent div that contains the error message div var passwordParentDiv = passwordField.parentElement.parentElement; // Get the error message div for password var passwordErrorDiv = passwordParentDiv.querySelector(".error.itemLevel"); // Create MutationObserver to watch for class changes on password field const passwordObserver = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (mutation.attributeName === 'class') { // Check if highlightError class is present if (passwordField.classList.contains('highlightError')) { // Show error message if (passwordErrorDiv) { // Set the error message var errorParagraph = passwordErrorDiv.querySelector("p"); if (errorParagraph) { errorParagraph.textContent = "Please enter your password"; errorParagraph.setAttribute("role", "alert"); } // Make the error visible passwordErrorDiv.style.display = "block"; passwordErrorDiv.setAttribute("aria-hidden", "false"); } } else { // Hide error message when highlightError is removed if (passwordErrorDiv) { passwordErrorDiv.style.display = "none"; passwordErrorDiv.setAttribute("aria-hidden", "true"); } } } }); }); // Start observing the password field for class changes passwordObserver.observe(passwordField, { attributes: true, attributeFilter: ['class'] }); } } function setupExpiredInvitation() { var expiredEmailMessage_label = document.getElementById("expiredInviteMessage_label"); var expiredInviteMessage = document.getElementById("expiredInviteMessage"); if (expiredEmailMessage_label !== null) { expiredInviteMessage_label.innerHTML = "Your Invitation Has Expired"; expiredInviteMessage_label.style.cssText = "font-weight: 700; font-size:40px; font-family: Tahoma; color:#1a476e; "; expiredInviteMessage.innerHTML = "The invitation you were sent has expired. Please request a new invitation using the button below."; document.getElementById("continue").innerText = "Send a new invitation"; } } function setupCaseResponse() { var caseResponse_label = document.getElementById("caseResponse_label"); if (caseResponse_label !== null) { var caseResponse = document.getElementById("caseResponse"); if (caseResponse.innerText.includes("Check your email inbox")) { caseResponse_label.innerHTML = "Invitation Code Resent"; caseResponse_label.style.cssText = "font-weight: 700; font-size:40px; font-family: Tahoma; color:#1a476e; "; addCloseButton(); } else { caseResponse_label.innerHTML = "Your Invitation Has Expired"; caseResponse_label.style.cssText = "font-weight: 700; font-size:40px; font-family: Tahoma; color:#1a476e; "; addCloseButton(); } } } function addCloseButton() { var existingButton = document.getElementById("closeButtonCustom"); if (existingButton == null) { var closeButton = document.createElement("button"); closeButton.innerText = "Close"; closeButton.ariaLabel = "Close"; closeButton.setAttribute("id", "closeButtonCustom"); closeButton.style.marginLeft = "32px"; closeButton.onclick = function () { location.href = portalURL; }; var buttonDiv = document.querySelector("#attributeList"); buttonDiv.appendChild(closeButton); } } function setupEmailValidation() { var existingEmailMismatch = document.querySelectorAll("#emailMismatch"); if (existingEmailMismatch.length == 0) { /* var errorDiv = document.createElement("div"); errorDiv.classList.add('error', 'pageLevel'); errorDiv.setAttribute("id", "emailMismatch"); errorDiv.style.display = "none"; var pdiv = document.createElement("p"); var mainErrorDiv = document.getElementById("attributeList"); if (mainErrorDiv !== null) { const logoSpan = document.createElement('span'); logoSpan.setAttribute('role', 'presentation'); logoSpan.classList.add('fa', 'fa-info-circle'); logoSpan.textContent = "The form could not be submitted for the following reasons:"; logoSpan.style.fontSize = "20px"; logoSpan.style.fontFamily = "Tahoma"; logoSpan.style.color = "#1a476e"; mainErrorDiv.insertAdjacentElement('beforebegin', errorDiv); errorDiv.appendChild(logoSpan); logoSpan.insertAdjacentElement('afterend', pdiv); pdiv.insertAdjacentText('afterend', "The email addresses do not match"); }*/ setupEmailValidationEvents(); // ErrorHandler.setupB2CErrorObserver(); } } function setupEmailValidationEvents() { var secondEmail = document.getElementById("secondEmail"); var confirmEmail = document.getElementById("confirmSecondEmail"); var confirmSecondEmailLabel = document.getElementById("confirmSecondEmail_label"); if (secondEmail !== null) { document.getElementById('secondEmail').onchange = function () { if (secondEmail.value !== "") { confirmSecondEmailLabel.innerHTML = "Confirm Recovery Email Address *"; confirmEmail.required = true; } else { confirmSecondEmailLabel.innerHTML = "Confirm Recovery Email Address"; confirmEmail.required = false; } } /* document.getElementById('continue').addEventListener("click", function (event) { event.stopImmediatePropagation(); event.preventDefault(); if (secondEmail.value !== "" && confirmEmail.value == "") { event.preventDefault(); ErrorHandler.showError('requiredFieldMissing'); return false; } else if (secondEmail.value !== null && confirmEmail.value !== secondEmail.value) { event.preventDefault(); ErrorHandler.showError('emailMismatch'); return false; } else { ErrorHandler.hideAllErrors(); document.getElementById('continue').click(); return true; } });*/ } } function setUpChangeMFA(){ var prof = document.querySelector(".profile-info"); if(prof !== null){ var mfaDiv = document.getElementById("extension_authenticationMethod"); if(mfaDiv !== null){ var formTop = document.getElementById("attributeList"); var header = document.createElement("h1"); header.innerText = "Change Multi Factor Authentication Options"; header.style.paddingLeft = "32px"; formTop.insertAdjacentElement("beforebegin",header); } } }