const SOURCE = 'USCRED' const FORM_URL = 'https://bremus4-v1-218915104282.us-east1.run.app//form-intake' function getCookieValue(name) { const cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { const cookie = cookies[i].trim(); if (cookie.startsWith(name + '=')) { return cookie.substring(name.length + 1); } } return null; } function SetLFUUID() { var LFUUID = uuidv4(); const cookies = document.cookie.split(';'); for (let i = 0; i < cookies.length; i++) { let cookie = cookies[i].trim(); if (cookie.startsWith("LFUUID=")) { console.log("Overwriting existing LFUUID cookie"); break; }} document.cookie = "LFUUID=" + LFUUID + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/"; return LFUUID; } function checkInputs(inputIds) { const emptyFields = []; inputIds.forEach(id => { const input = document.getElementById(id); if (input && input.value.trim() === '') { emptyFields.push(id); } }); return { allFilled: emptyFields.length === 0, emptyFields: emptyFields }; } function shiftSteps(cur, next) { document.getElementById('loader').style.display = 'block'; setTimeout(function() { document.getElementById('loader').style.display = 'none'; document.getElementById(cur).style.display = 'none'; document.getElementById(next).style.display = 'block'; }, 400); } function step1() { if (checkInputs(['RequestedAmount']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['RequestedAmount']).emptyFields) return 'nah' } shiftSteps(1,2) document.cookie = `form_step=2; path=/`; SetLFUUID() const data = { source: SOURCE, requested_amount: document.getElementById("RequestedAmount").value, trk: getCookieValue('trk'), sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:1 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step1_h() { if (checkInputs(['RequestedAmount']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['RequestedAmount']).emptyFields) return 'nah' } // shiftSteps(1,2) document.cookie = `form_step=2; path=/`; SetLFUUID() const data = { source: SOURCE, requested_amount: document.getElementById("RequestedAmount").value, trk: getCookieValue('trk'), sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:1 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); window.location = '/app/apply-continue-rq' }) .catch(error => { console.error('Error:', error); }); } function step1_inline() { if (checkInputs(['RequestedAmount-2']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['RequestedAmount']).emptyFields) return 'nah' } // shiftSteps(1,2) document.cookie = `form_step=2; path=/`; SetLFUUID() const data = { source: SOURCE, requested_amount: document.getElementById("RequestedAmount-2").value, trk: getCookieValue('trk'), sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:1 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); window.location = '/apply-continue' }) .catch(error => { console.error('Error:', error); }); } function step2() { if (checkInputs(['UseOfFunds']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['UseOfFunds']).emptyFields) return 'nah' } shiftSteps(2,3) document.cookie = `form_step=3; path=/`; const data = { source: SOURCE, use_of_funds: document.getElementById("UseOfFunds").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:2 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step3() { if (checkInputs(['corporate_name','State']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['corporate_name', 'State']).emptyFields) return 'nah' } shiftSteps(3,"contactstep") document.cookie = `form_step=4; path=/`; const data = { source: SOURCE, corporate_name: document.getElementById("corporate_name").value, state: document.getElementById("State").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:3 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step3_alt() { if (checkInputs(['MostImportant']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['corporate_name', 'State']).emptyFields) return 'nah' } shiftSteps(3,"contactstep") document.cookie = `form_step=4; path=/`; const data = { source: SOURCE, corporate_name: document.getElementById("corporate_name").value, state: document.getElementById("State").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:3 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step4() { if (checkInputs(['Phone','Email', 'Full_Name']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Phone','Email', 'Full_Name']).emptyFields) return 'nah' } shiftSteps("contactstep","business") document.cookie = `form_step=5; path=/`; const data = { source: SOURCE, phone: document.getElementById("Phone").value, email: document.getElementById("Email").value, full_name: document.getElementById("Full_Name").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:4 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step4_alt() { if (checkInputs(['Phone','Email', 'Name', 'Company']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Phone','Email', 'Full_Name']).emptyFields) return 'nah' } // shiftSteps("contactstep","business") document.cookie = `form_step=5; path=/`; const data = { source: SOURCE, phone: document.getElementById("Phone").value, email: document.getElementById("Email").value, full_name: document.getElementById("Name").value, company: document.getElementById("Company").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:4 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); window.location = '/app/apply-continue-b4' }) .catch(error => { console.error('Error:', error); }); } function step1_eidl_lookup() { if (checkInputs(['Phone','Email', 'Full_Name']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Phone','Email', 'Full_Name']).emptyFields) return 'nah' } // shiftSteps(4,6) SetLFUUID() document.cookie = `form_step=1; path=/`; const data = { source: SOURCE, company: document.getElementById("Company").value, email: document.getElementById("Email").value, full_name: document.getElementById("Full_Name").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:1 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); window.location = '/apply-continue' }) .catch(error => { console.error('Error:', error); }); } function step1_ref_p() { if (checkInputs(['Phone','Email', 'Full_Name', 'Company']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Phone','Email', 'Full_Name']).emptyFields) return 'nah' } // shiftSteps(4,6) SetLFUUID() document.cookie = `form_step=1; path=/`; const data = { source: 'FASTWAY-REFERRAL-SIGNUP', company: document.getElementById("Company").value, email: document.getElementById("Email").value, name: document.getElementById("Name").value, phone: document.getElementById("Phone").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:1 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); window.location = '/thank-you' }) .catch(error => { console.error('Error:', error); }); } function step5() { if (checkInputs(['Tax_ID','Monthly_Gross', 'Business_Start_Year', 'Business_Address_Raw']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Tax_ID','Monthly_Gross', 'Business_Start_Year', 'Business_Address_Raw']).emptyFields) return 'nah' } shiftSteps("business","owner") document.cookie = `form_step=6; path=/`; const data = { source: SOURCE, tax_id: document.getElementById("Tax_ID").value, monthly_gross: document.getElementById("Monthly_Gross").value, business_start_year: document.getElementById("Business_Start_Year").value, business_address: document.getElementById("Business_Address_Raw").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:5 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function step6() { if (checkInputs(['Full_Name_C','Home_Address_Raw', 'DOB', 'SSN']).allFilled == true) { console.log('All Filled') } else { console.log(checkInputs(['Full_Name_C','Home_Address_Raw', 'DOB', 'SSN']).emptyFields) return 'nah' } shiftSteps("owner","uploadstep") document.cookie = `form_step=7; path=/`; const data = { source: SOURCE, full_name: document.getElementById("Full_Name_C").value, home_address: document.getElementById("Home_Address_Raw").value, dob: document.getElementById("DOB").value, ssn: document.getElementById("SSN").value, sid: getCookieValue('id'), form_instance: getCookieValue('LFUUID'), location: document.location.href, step:6 }; // Send data using fetch fetch(FORM_URL, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => { console.log('Success:', data); }) .catch(error => { console.error('Error:', error); }); } function showElementAfterDelay(elementId, delay) { setTimeout(() => { const element = document.getElementById(elementId); if (element) { element.style.display = 'block'; // Show the element } }, delay); } function triggerTimer() { showElementAfterDelay('uplater', 5000); // Set timer for 5 seconds } function send_file(file_send) { url_string = window.location.href var url = new URL(url_string); const formData = new FormData(); formData.append('file', file_send); formData.append('form',getLFUUIDFromCookie()) formData.append('name',file_send.name) formData.append('seed_id', getIdFromCookie()) formData.append('form_instance', getCookieValue('LFUUID')) const xhr = new XMLHttpRequest(); xhr.open('POST', 'https://bremus4-v1-218915104282.us-east1.run.app//file-intake'); xhr.send(formData); } // mask for requested amount currency //var inputElement = document.getElementById('RequestedAmount'); //inputElement.addEventListener('input', function (e) { // // Get the input value // var inputValue = e.target.value; // inputValue = inputValue.replace('$', ''); // // // Remove any non-numeric characters except for commas // inputValue = inputValue.replace(/[^0-9,]/g, ''); // // // Remove leading zeros // inputValue = inputValue.replace(/^0+/, ''); // // // Replace commas with an empty string to remove them // inputValue = inputValue.replace(/,/g, ''); // // // Format the number with commas and add the dollar sign // inputValue = Number(inputValue).toLocaleString(); // // // Update the input value // e.target.value = '$'+inputValue; //});