<commit_before>// Prevent form from being submitted. This is being done manually in on click paymentButton
onSubmit(eventForm, () => null)

// Clear form
onClick('#form-clear', () => {
	clearForm(page())
	resetForm()
})

// Load form
onClick('#form-load', () => repopulateForm(page()))

// Invite-only
onClick(eventInviteButton, () => e => {
	e.preventDefault()
	// Show errors, if any
	inviteOnlyCodeVerification()
	// Adjust prices
	setEventPrices()
})

// Affiliate yes/no?
for (elem of [eventAffiliateYes, eventAffiliateNo]) {
	onChange(elem, () => {
		// If affiliate code, show code input field...
		if (isChecked(eventAffiliateYes)) showAndScrollTo(eventAffiliateCodeContainer)
		// ...otherwise, hide it.
		else {
			emptyValue(eventAffiliateCodeContainer)
			hideElement(eventAffiliateCodeContainer)
		}
	})
}

// Affiliate box
onChange(eventAffiliateCode, () => {
	// Show errors, if any
	affiliateCodeVerification()
	// Adjust prices
	setEventPrices()
})

// Personal
onChange(eventFirstName, () => setValue(billingFirstName, getValue(eventFirstName)))
onChange(eventLastName, () => setValue(billingLastName, getValue(eventLastName)))

// Details
for (elem of [eventExperienceYes, eventExperienceNo]) {
	onChange(elem, () => {
		if (isChecked(eventExperienceYes)) showAndScrollTo(eventExperienceContainer)
		if (isChecked(eventExperienceNo)) {
			emptyValue(eventExperienceDetails)
			hideElement(eventExperienceContainer)
		}
	})
}
for (elem of [eventDietYes, eventDietNo]) {
	onChange(elem, () => {
		if (isChecked(eventDietYes)) showAndScrollTo(eventDietContainer)
		if (isChecked(eventDietNo)) {
			emptyValue(eventDietDetails)
			hideElement(eventDietContainer)
		}
	})
}
for (elem of [eventSpecialYes, eventSpecialNo]) {
	onChange(elem, () => {
		if (isChecked(eventSpecialYes)) showAndScrollTo(eventSpecialContainer)
		if (isChecked(eventSpecialNo)) {
			emptyValue(eventSpecialDetails)
			hideElement(eventSpecialContainer)
		}
	})
}

// Partner
onChange(eventStatus, () => participants() === 2 ? showPartner() : hidePartner())
onChange(eventPayBoth, () => setEventPrices())
onChange(eventPayMe, () => setEventPrices())

// All non-discount code input fields: make proper case
for (elem of [eventFirstName, eventLastName, eventPartnerFirstName, eventPartnerLastName, billingFirstName, billingLastName, billingStreet, billingCity, billingPostal]) {
	onChange(elem, () => {
		// Proper case
		let value = properCase(getValue(elem))
		// Remove empty spaces
		if (value.includes(' ') && elem !== billingStreet && elem !== billingCity && elem !== billingPostal) {
			value = value.replace(' ', '')
		}
		setValue(elem, value)
	})
}

// All reg fields
for (elem of [eventFirstName, eventLastName, eventEmail, eventMobile, eventBirthdate, eventFemale, eventMale, eventOther, eventReferral, eventExperienceYes, eventExperienceNo, eventExperienceDetails, eventDietYes, eventDietNo, eventDietDetails, eventSpecialYes, eventSpecialNo, eventSpecialDetails, eventStatus, eventPartnerFirstName, eventPartnerLastName, eventPartnerFemale, eventPartnerMale, eventPartnerOther, eventPayBoth, eventPayMe, eventSelect, eventTerms, billingFirstName, billingLastName, billingStreet, billingCity, billingState, billingPostal, billingCountry]) {
	onChange(elem, () => {
		// Save form whenever a single field has changed...
		saveForm(page())<commit_msg>Simplified code in progress.<commit_after>// Prevent form from being submitted. This is being done manually in on click paymentButton
onSubmit(eventForm, () => null)

// Clear form
onClick('#form-clear', () => {
	clearForm(page())
	resetForm()
})

// Load form
onClick('#form-load', () => repopulateForm(page()))

// Invite-only
onClick(eventInviteButton, () => e => {
	e.preventDefault()
	// Show errors, if any
	inviteOnlyCodeVerification()
	// Adjust prices
	setEventPrices()
})

// Affiliate yes/no?
for (elem of [eventAffiliateYes, eventAffiliateNo]) {
	onChange(elem, () => {
		// If affiliate code, show code input field...
		if (isChecked(eventAffiliateYes)) showAndScrollTo(eventAffiliateCodeContainer)
		// ...otherwise, hide it.
		else {
			emptyValue(eventAffiliateCodeContainer)
			hideElement(eventAffiliateCodeContainer)
		}
	})
}

// Affiliate box
onChange(eventAffiliateCode, () => {
	// Show errors, if any
	affiliateCodeVerification()
	// Adjust prices
	setEventPrices()
})

// Personal
onChange(eventFirstName, () => setValue(billingFirstName, getValue(eventFirstName)))
onChange(eventLastName, () => setValue(billingLastName, getValue(eventLastName)))

// Details
for (elem of [eventExperienceYes, eventExperienceNo]) {
	onChange(elem, () => {
		if (isChecked(eventExperienceYes)) showAndScrollTo(eventExperienceContainer)
		if (isChecked(eventExperienceNo)) {
			emptyValue(eventExperienceDetails)
			hideElement(eventExperienceContainer)
		}
	})
}
for (elem of [eventDietYes, eventDietNo]) {
	onChange(elem, () => {
		if (isChecked(eventDietYes)) showAndScrollTo(eventDietContainer)
		if (isChecked(eventDietNo)) {
			emptyValue(eventDietDetails)
			hideElement(eventDietContainer)
		}
	})
}
for (elem of [eventSpecialYes, eventSpecialNo]) {
	onChange(elem, () => {
		if (isChecked(eventSpecialYes)) showAndScrollTo(eventSpecialContainer)
		if (isChecked(eventSpecialNo)) {
			emptyValue(eventSpecialDetails)
			hideElement(eventSpecialContainer)
		}
	})
}

// Partner
onChange(eventStatus, () => participants() === 2 ? showPartner() : hidePartner())
onChange(eventPayBoth, () => setEventPrices())
onChange(eventPayMe, () => setEventPrices())

// All reg fields
for (elem of [eventFirstName, eventLastName, eventEmail, eventMobile, eventBirthdate, eventFemale, eventMale, eventOther, eventReferral, eventExperienceYes, eventExperienceNo, eventExperienceDetails, eventDietYes, eventDietNo, eventDietDetails, eventSpecialYes, eventSpecialNo, eventSpecialDetails, eventStatus, eventPartnerFirstName, eventPartnerLastName, eventPartnerFemale, eventPartnerMale, eventPartnerOther, eventPayBoth, eventPayMe, eventSelect, eventTerms, billingFirstName, billingLastName, billingStreet, billingCity, billingState, billingPostal, billingCountry]) {
	onChange(elem, () => {
		// All non-discount code input fields: make proper case
		if ([eventFirstName, eventLastName, eventPartnerFirstName, eventPartnerLastName, billingFirstName, billingLastName, billingStreet, billingCity, billingPostal].includes(elem)) {
			// Proper case
			let value = properCase(getValue(elem))
			// Remove empty spaces
			if (value.includes(' ') && elem !== billingStreet && elem !== billingCity && elem !== billingPostal) {
				value = value.replace(' ', '')
			}
			setValue(elem, value)
		}
		// Save form whenever a single field has changed...
		saveForm(page())
{'fraction_non_alphanumeric': 0.1284116331096197, 'fraction_numerical': 0.0002982848620432513, 'mean_word_length': 5.821973550356053, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5256489', 'n_tokens_mistral': 2213, 'n_tokens_neox': 2055, 'n_words': 443}