1import { 2 capitalizeFirstLetter, 3 calculateTotalDebt, 4 state, 5 title, 6 email, 7 mobileNumber, 8 amountRequired, 9 purposeOfLoan, 10 describeLoan, 11 propertyType, 12 propertyDebt, 13 propertyValue, 14 firstMortgageInput, 15 secondMortgageInput, 16 otherChargesInput, 17 bankAccountConfirmation, 18 propertyConfirmation, 19 propertyAddress, 20} from "../common.js"; 21import { highlightErrors } from "./Validation.js"; 22 23export const gatherFormData = () => { 24 const companyUrl = 25 state.company.links && state.company.links.self 26 ? "https://find-and-update.company-information.service.gov.uk" + 27 state.company.links.self 28 : ""; 29 30 propertyAddress.value = state.securityPropertyAddress ?? ""; 31 companyname.value = state.company.title ?? ""; 32 33 const formData = { 34 title: title.value, 35 firstname: capitalizeFirstLetter("firstname"), 36 lastname: capitalizeFirstLetter("lastname"), 37 email: email.value, 38 mobilenumber: mobileNumber.value, 39 amountrequired: amountRequired.value, 40 purposeofloan: purposeOfLoan.value, 41 descloan: describeLoan.value, 42 propertytype: propertyType.value, 43 securitypropertyaddressone: state.securityPropertyAddress.addressOne, 44 securitypropertyaddresstwo: state.securityPropertyAddress.addressTwo, 45 securitypropertyaddressthree: state.securityPropertyAddress.addressThree, 46 securitypropertypostcode: state.securityPropertyAddress.postcode, 47 securitypropertyformattedaddress: 48 state.securityPropertyAddress.formattedAddress ?? 49 "Formatted Address Not Found", 50 propertydebt: propertyDebt.value, 51 propertyvalue: Number(propertyValue.value.replace(/\,/g, "")), 52 firstmortgage: Number(firstMortgageInput.value.replace(/\,/g, "")), 53 secondmortgage: Number(secondMortgageInput.value.replace(/\,/g, "")), 54 othercharges: Number(otherChargesInput.value.replace(/\,/g, "")), 55 totaldebt: calculateTotalDebt(), 56 companyname: state.company.title ?? "", 57 companynumber: state.company.company_number ?? "", 58 companystatus: state.company.company_status ?? "", 59 companytype: state.company.company_type, 60 companydescription: state.company.description ?? "", 61 companyurl: companyUrl, 62 companyaddress: state.companyAddressSnippet ?? "", 63 natureofbusiness: "", 64 sourcepage: window.location.hash ? window.location.hash.substring(1) : "", 65 confirmations: [ 66 bankAccountConfirmation.checked, 67 propertyConfirmation.checked, 68 ], 69 }; 70 71 return formData; 72}; 73 74export const submitForm = async (formData) => { 75 try { 76 const response = await fetch( 77 "https://sea-lion-app-lccwh.ondigitalocean.app/jotform/submitmidform", 78 { 79 headers: { "Content-Type": "application/json" }, 80 method: "POST", 81 body: JSON.stringify(formData), 82 } 83 ); 84 85 if (!response.ok) { 86 if (response.status === 400) { 87 const errorResponse = await response.json(); 88 highlightErrors(errorResponse.errors); 89 //document.getElementById("error-header").scrollIntoView(); 90 } else { 91 throw new Error(`Server responded with ${response.status}`); 92 } 93 } else { 94 const res = await response.json(); 95 //const successMessage = await response.text(); 96 const redirectURL = res.redirecturl; 97 window.top.location.href = redirectURL; 98 //alert(successMessage); 99 } 100 } catch (error) { 101 //console.error("Error:", error.message); 102 alert("Error: Please try again later"); 103 } 104};
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.