1function toggleCheckbox() { 2 const registrationCheckbox = document.getElementById('checkbox-input'); 3 const submitButton = document.getElementById('primary-btn'); 4 5 if (registrationCheckbox.checked) { 6 submitButton.textContent = submitButton.getAttribute('data-register-text') || 'Register'; 7 } else { 8 submitButton.textContent = submitButton.getAttribute('data-guest-text') || 'Continue as Guest'; 9 } 10 11 toggleBenefits(); 12} 13 14function toggleBenefits() { 15 const registrationCheckbox = document.getElementById('checkbox-input'); 16 const benefitsList = document.getElementById('benefitsList'); 17 const firstNameField = document.getElementById('firstName-wrapper'); 18 const lastNameField = document.getElementById('lastName-wrapper'); 19 const passwordField = document.getElementById('password-wrapper'); 20 const messagesContainer = document.querySelector('.messages-container'); 21 22 if (benefitsList) { 23 if (registrationCheckbox.checked) { 24 benefitsList.classList.remove('crossed'); 25 benefitsList.querySelectorAll('#benefitsList i.icon').forEach(icon => { 26 icon.className = 'v5-icon--check-circle-mid icon'; 27 }); 28 firstNameField.classList.remove('form-fields-hidden'); 29 lastNameField.classList.remove('form-fields-hidden'); 30 passwordField.classList.remove('form-fields-hidden'); 31 32 if (messagesContainer) { 33 messagesContainer.style.display = 'none'; 34 } 35 } else { 36 benefitsList.classList.add('crossed'); 37 benefitsList.querySelectorAll('#benefitsList i.icon').forEach(icon => { 38 icon.className = 'v5-icon--cross-circle-mid icon'; 39 }); 40 firstNameField.classList.add('form-fields-hidden'); 41 lastNameField.classList.add('form-fields-hidden'); 42 passwordField.classList.add('form-fields-hidden'); 43 44 if (messagesContainer) { 45 messagesContainer.style.display = 'block'; 46 } 47 } 48 } 49} 50 51function handleFormSubmit(event) { 52 const emailInput = document.getElementById('email'); 53 const registrationCheckbox = document.getElementById('checkbox-input'); 54 const newsletterCheckboxInput = document.getElementById('newsletter-checkbox-input'); 55 const form = event.target; 56 57 if (!registrationCheckbox.checked && emailInput.value.trim() && isEmailValid(emailInput.value)) { 58 const guestRedirectionPath = form.getAttribute('data-guest-redirect-path'); 59 const guestFlowPath = form.getAttribute('data-guest-flow-path'); 60 61 if (guestRedirectionPath) { 62 event.preventDefault(); 63 64 showLoadingSpinner(); 65 66 fetch(guestFlowPath, { 67 method: 'PATCH', 68 credentials: 'include', 69 headers: { 70 'Content-Type': 'application/json' 71 }, 72 body: JSON.stringify({ 73 email: emailInput.value.trim(), 74 subscribeToNewsletter: newsletterCheckboxInput?.checked ?? false 75 }) 76 }).then(response => { 77 window.location.href = guestRedirectionPath; 78 }).catch(error => { 79 console.error('Error calling guest soft-login API:', error); 80 window.location.href = guestRedirectionPath; 81 }) 82 83 return false; 84 } 85 } 86 return validateRegistrationForm(); 87} 88 89function showLoadingSpinner() { 90 const submitButton = document.getElementById('primary-btn'); 91 submitButton.disabled = true; 92 submitButton.innerHTML = ` 93 <div class="spinner-wrapper"> 94 <div class="spinner"></div> 95 </div> 96 `; 97} 98 99document.addEventListener('DOMContentLoaded', function () { 100 toggleBenefits(); 101 102 const form = document.getElementById('form-register'); 103 if (form) { 104 form.addEventListener('submit', handleFormSubmit); 105 } 106});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.