PageSourceSearch

https://www.strongbytamko.com/wp-content/plugins/custom-forms16//js/ajax-scripts.js?1791580219

js strongbytamko.com collected 2026-10-09 22:40:06 UTC 43,814 bytes, 1,381 lines download raw bytes

1jQuery(document).ready(function($) {
2
3	const cf_data = [];
4
5	var status_btn = 0;
6	var status_btn_email = 0;
7
8	function getRandomAlphanumericString(length) {
9		const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
10		let result = '';
11		for (let i = 0; i < length; i++) {
12			result += chars.charAt(Math.floor(Math.random() * chars.length));
13		}
14		return result;
15	}
16
17	function checkLocalStorageKeyExists(key) {
18		return localStorage.getItem(key) !== null;
19	}
20
21	$('.step-number input').on('keyup blur', function() {
22		// Remove non-numeric characters
23		$(this).val($(this).val().replace(/[^0-9]/g, ''));
24	});
25
26	$('#step-minor-4 input').on('keyup', function() {
27		var email = $(this).val();
28		var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
29
30		if (!regex.test(email)) {
31			$(this).parent().parent().find('#required-form').remove();
32			$(this).parent().parent().append("<div id='required-form'>Invalid email address</div>");
33			status_btn = 1;
34			status_btn_email = 1;
35		} else {
36			$(this).parent().parent().find('#required-form').remove();
37			status_btn = 0;
38			status_btn_email = 0;
39		}
40	});
41
42	$('.openFormBtn').click(function(){
43		$('#popupForm').fadeIn().css('display','block');
44		showStep(1);
45	});
46
47	$('#closeFormBtn , #popupForm-overlay').click(function(){
48		$('#popupForm').fadeOut().css('display','block');
49	});
50
51	function showStep(step,type) {
52		if(type == "role_2"){
53			$('.form-step').removeClass('active');
54			$('#step-' + step + '.form-owner').addClass('active');
55		}else{
56			$('.form-step').removeClass('active');
57			$('#step-' + step + '.form-sales').addClass('active');
58		}	
59	}
60
61	$('input[name=select_role]').on('click', function(e) {
62		if ($(this).val() === 'role_1') {
63			$("#step-1-btn .btn.next").hide();
64			$("#step-1-btn .btn.final").show();
65			$("#form_role_type").val('form-sales');
66			$("#step-1 .step-checkbox").show();
67		}
68		if ($(this).val() === 'role_2') {
69			$("#step-1-btn .btn.next").show();
70			$("#step-1-btn .btn.final").hide();
71			$("#step-1 .step-checkbox").show();
72			$("#form_role_type").val('form-owner');
73		}
74	});
75
76	$("#form input, #form select").each(function(index) {
77		var cf_data_all = "";
78		var cf_data_html_all = "";
79		var thisHeading = "";
80		var thisFormType = "";
81		var current_date_time = $('#current_date_time').val();
82		var cookie_id = "";
83
84		$(this).on("keyup change ", function() {
85
86			cookie_id = $('#cookie_id').val();
87
88			var thisValue = "";
89
90			cf_data_all = "";
91			cf_data_html_all = "";
92
93			$('.form-required.form-imp').each(function(index, element) {
94				if ( $(this).hasClass('steps-1') ) {
95					thisValue = $(this).find('input:checked').val();
96					if(thisValue == "role_1"){
97						thisValue = "Sales Rep";
98						thisFormType = "form-sales";
99					}
100					if(thisValue == "role_2"){
101						thisValue = "Owner/Manager";
102						thisFormType = "form-owner";
103					}
104				}else if ($(this).find('input').is(':radio')){
105					thisValue = $(this).find('input:checked').val();
106				}else if ($(this).find('select').length) {
107					thisValue = $(this).find('select').val();
108				}else{
109					thisValue = $(this).find('input').val();
110				}
111// 				console.log($(this))
112				thisHeading = $(this).find('h2').html();
113				if (thisValue && thisValue.includes(',')) {
114					thisValue = thisValue.replace(/,/g, '&#44;');
115				}
116				cf_data_all += thisValue + ",";
117				cf_data_html_all += "<div><b>"+thisHeading+": </b>"+thisValue+"</div>"
118			});
119
120			
121			var cf_database = $('#form_database').val();
122			
123			$.ajax({
124				type: 'POST',
125				url: ajax_object.ajax_url,
126				data: {
127					action: 'rsra_step_one',
128					current_date_time: current_date_time,
129					cookie_id: cookie_id,
130					cf_data: cf_data_all,
131					cf_data_html_all: cf_data_html_all,
132					cf_data_step: '1',
133					cf_database: cf_database,
134					role_type: thisFormType
135				},
136				success: function(response) {
137
138				},
139				error: function(xhr, status, error) {
140					// $('#response').html('An error occurred: ' + error);
141				}
142			});
143		});
144	});
145
146	$(' .openFormBtn ').on('click', function(e) {
147		e.preventDefault();
148
149		if (checkLocalStorageKeyExists('rsraform_cookies')) {
150			console.log('Key exists in localStorage');
151		} else {
152			console.log('Key does not exist in localStorage');
153			localStorage.setItem('rsraform_cookies', getRandomAlphanumericString(20) );
154		}
155
156		let cookie_key = localStorage.getItem('rsraform_cookies');
157
158		$('#cookie_id').val(cookie_key);
159
160		var current_date_time = $('#current_date_time').val();
161		var cookie_id = $('#cookie_id').val();
162		$("#popupForm").addClass('loading');
163		
164		var cf_database = $('#form_database').val();
165
166		$.ajax({
167			type: 'POST',
168			url: ajax_object.ajax_url,
169			data: {
170				action: 'rsra_open_form',
171				current_date_time: current_date_time,
172				cf_database: cf_database,
173				cookie_id: cookie_id
174			},
175			dataType: "json",
176			success: function(response) {
177
178				// 				console.log(response)
179
180				$('.form-step').removeClass('active');
181
182				if(response[0] != "none"){
183					let stepActive = parseInt(response[0]);
184
185					$("#form_role_type").val(response[1]);
186
187					var form_data_array = response[2].split(",");
188					let stepCountTotal = 0;
189					// console.log(form_data_array)
190					$.each(form_data_array,function(i){
191						stepCountTotal++;
192						let stepCount = [i];
193						stepCount = parseInt(stepCount) + 1;
194
195						// console.log(form_data_array[i])
196
197						if ( $("#step-minor-" + stepCount).hasClass('steps-1') ) {
198							if(form_data_array[i] == 'Owner/Manager'){
199								$("input[name=select_role][value=role_1]").attr('checked', false);
200								$("input[name=select_role][value=role_2]").attr('checked', true);
201								$("#step-1-btn .btn.next").show();
202								$("#step-1-btn .btn.final").hide();
203								$("#step-1 .step-checkbox").show();
204								// console.log(form_data_array[i])
205							}
206							if (form_data_array[i] == 'Sales Rep'){
207								$("input[name=select_role][value=role_1]").attr('checked', true);
208								$("input[name=select_role][value=role_2]").attr('checked', false);
209								$("#step-1-btn .btn.next").hide();
210								$("#step-1-btn .btn.final").show();
211								$("#step-1 .step-checkbox").show();
212								// console.log(form_data_array[i])
213							}
214						}else{
215							if ( $("#step-minor-" + stepCount + " input").is(':radio') ) {
216								var radioName = $("#step-minor-" + stepCount + " input").attr('name');
217								var selectedValue = form_data_array[i]; 
218								$('#step-minor-' + stepCount + ' input[name="'+radioName+'"]').each(function() {
219									// 									console.log($(this).val())
220									// 									console.log(selectedValue)
221									if ($(this).val() === selectedValue) {
222										$(this).prop('checked', true);
223										$(this).attr('checked', true);
224									}
225								});
226							}
227							else if ($("#step-minor-" + stepCount + " select").length) {
228								var selectedValue = form_data_array[i]; 
229								var selectElement = $("#step-minor-" + stepCount + " select");
230								if (selectedValue.includes("&#44;")) {
231									selectedValue = selectedValue.replace(/&#44;/g, ',');
232								}
233								selectElement.val(selectedValue);
234							}
235							else{
236								var confirm_data = form_data_array[i];
237								if (confirm_data.includes("&#44;")) {
238									confirm_data = confirm_data.replace(/&#44;/g, ',');
239								}
240								$("#step-minor-" + stepCount + " input").val(confirm_data);
241							}
242
243						}
244
245
246
247					});
248
249					// 					console.log(stepCountTotal + "TESTESTGSET");
250					if(stepCountTotal <= 5){
251						$('#step-1').addClass('active');
252					}else{
253						$('#step-1').addClass('active');
254					}
255
256				}else{
257					$('#step-1').addClass('active');
258				}
259				$("#popupForm").removeClass('loading');
260
261
262
263			},
264			error: function(xhr, status, error) {
265				// $('#response').html('An error occurred: ' + error);
266			}
267		});
268	});
269
270
271	$('#step-1 button.btn').on('click', function(e) {
272		e.preventDefault();
273		var inStatus = 0;
274		var val_radio = "";
275		$('#step-1 .form-required').each(function(index, element) {
276			var checkInput = "";
277			if ( $(this).find('input').is(':radio') ) {
278				if( $(this).find('input').is(":checked") ){
279					checkInput = 1;
280					var selectedRadio = $('input:checked');
281					if (selectedRadio.length > 0) {
282						val_radio = selectedRadio.val();
283					}
284				} else {
285					checkInput = "";
286				}
287// 				console.log(checkInput)
288			}else if ( $(this).find('input').is(':checkbox') ) {
289// 				if( val_radio == "role_1"){
290					if( $(this).find('input').is(":checked") ){
291						checkInput = 1;
292					} else {
293						checkInput = "";
294					}
295// 				}else{
296// 					checkInput = 1;
297// 				}
298			}else{
299				checkInput = $(this).find('input').val();
300			}
301			
302			if(checkInput === ""){
303				$(this).find('#required-form').remove();
304				$(this).append("<div id='required-form'>This field is required</div>");
305				inStatus = 1;
306			}else{
307				$(this).find('#required-form').remove();
308			}
309
310			if ($(this).hasClass('step-email')){
311				var email = $("#step-minor-4 input").val();
312				var regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
313
314				if (!regex.test(email)) {
315					$(this).find('#required-form').remove();
316					$(this).append("<div id='required-form'>Invalid email address</div>");
317					status_btn = 1;
318					status_btn_email = 1;
319					inStatus = 1;
320					console.log("TEST11");
321				} 
322			}
323
324		});
325// 		console.log(status_btn)
326		if(inStatus === 1 || status_btn_email === 1){
327			status_btn = 1;
328		}else{
329			$("#required-form").remove();
330			status_btn = 0;
331		}
332	});
333
334
335
336
337
338
339
340
341
342
343
344	$('.form-step.form-input button.btn-form').on('click', function(e) {
345		e.preventDefault();
346		// console.log("LAST 1");
347		if(status_btn == 1 ){
348			return false;
349		}else{
350			e.preventDefault(1)
351		}
352
353		let dataVersion = $('#popupForm').attr('data-version');
354
355		if($(this).hasClass('next')){
356			var checkInput = "";
357			if ( $(this).parent().parent().find('input').is(':radio') ) {
358				checkInput = $(this).parent().parent().find('input:checked').val();
359				console.log("GITS1")
360			}else{
361				checkInput = $(this).parent().parent().find('input').val();
362			}
363			if(checkInput == ""){
364				$(this).parent().parent().find('#required-form').remove();
365				$(this).parent().parent().find('.form-btnmain').before("<div id='required-form'>This field is required 1</div>");
366				return false;
367			}else{
368				// 				$("#required-form").remove();
369			}
370		}
371
372		if($(this).hasClass('final-owner')){
373
374
375			var checks_vales = 0;
376
377			if ( dataVersion == 'v2' ){
378				if( $("#step-minor-6 input").val().trim() === '' ){
379					checks_vales = 1;
380					$("#step-minor-6").find('#required-form').remove();
381					$("#step-minor-6").append("<div id='required-form'>This field is required</div>");
382				}else{
383					$("#step-minor-6").find('#required-form').remove();
384				}
385				
386				if( $('#step-minor-7 input[name="reps"]:checked').length === 0 ){
387					checks_vales = 1;
388					$("#step-minor-7").find('#required-form').remove();
389					$("#step-minor-7").append("<div id='required-form'>This field is required</div>");
390				}else{
391					$("#step-minor-7").find('#required-form').remove();
392				}
393				
394				if( $('#step-minor-8 input[name="financial"]:checked').length === 0 ){
395					checks_vales = 1;
396					$("#step-minor-8").find('#required-form').remove();
397					$("#step-minor-8").append("<div id='required-form'>This field is required</div>");
398				}else{
399					$("#step-minor-8").find('#required-form').remove();
400				}
401				
402				if( $("#step-minor-9 input").val().trim() === '' ){
403					checks_vales = 1;
404					$("#step-minor-9").find('#required-form').remove();
405					$("#step-minor-9").append("<div id='required-form'>This field is required</div>");
406				}else{
407					$("#step-minor-9").find('#required-form').remove();
408				}
409				
410				if( $('#step-minor-10 input[name="investing"]:checked').length === 0 ){
411					checks_vales = 1;
412					$("#step-minor-10").find('#required-form').remove();
413					$("#step-minor-10").append("<div id='required-form'>This field is required</div>");
414				}else{
415					$("#step-minor-10").find('#required-form').remove();
416				}
417			}
418
419			if ( dataVersion == 'v3' ){
420				if( $("#step-minor-6 input").val().trim() === '' ){
421					checks_vales = 1;
422					$("#step-minor-6").find('#required-form').remove();
423					$("#step-minor-6").append("<div id='required-form'>This field is required</div>");
424				}else{
425					$("#step-minor-6").find('#required-form').remove();
426				}
427				
428				if( $('#step-minor-7 input[name="annual"]:checked').length === 0 ){
429					checks_vales = 1;
430					$("#step-minor-7").find('#required-form').remove();
431					$("#step-minor-7").append("<div id='required-form'>This field is required</div>");
432				}else{
433					$("#step-minor-7").find('#required-form').remove();
434				}
435				
436				if( $('#step-minor-8 input[name="years"]:checked').length === 0 ){
437					checks_vales = 1;
438					$("#step-minor-8").find('#required-form').remove();
439					$("#step-minor-8").append("<div id='required-form'>This field is required</div>");
440				}else{
441					$("#step-minor-8").find('#required-form').remove();
442				}
443				
444			}
445
446
447
448			if ( dataVersion == 'v4' ){
449				if( $("#step-minor-6 input").val().trim() === '' ){
450					checks_vales = 1;
451					$("#step-minor-6").find('#required-form').remove();
452					$("#step-minor-6").append("<div id='required-form'>This field is required</div>");
453				}else{
454					$("#step-minor-6").find('#required-form').remove();
455				}
456				
457				if( $('#step-minor-7 input[name="annual"]:checked').length === 0 ){
458					checks_vales = 1;
459					$("#step-minor-7").find('#required-form').remove();
460					$("#step-minor-7").append("<div id='required-form'>This field is required</div>");
461				}else{
462					$("#step-minor-7").find('#required-form').remove();
463				}
464				
465				if( $('#step-minor-8 input[name="years"]:checked').length === 0 ){
466					checks_vales = 1;
467					$("#step-minor-8").find('#required-form').remove();
468					$("#step-minor-8").append("<div id='required-form'>This field is required</div>");
469				}else{
470					$("#step-minor-8").find('#required-form').remove();
471				}
472				
473// 				if( $('#step-minor-9 input[name="interest"]:checked').length === 0 ){
474// 					checks_vales = 1;
475// 					$("#step-minor-9").find('#required-form').remove();
476// 					$("#step-minor-9").append("<div id='required-form'>This field is required</div>");
477// 				}else{
478// 					$("#step-minor-8").find('#required-form').remove();
479// 				}
480				if( $('#step-minor-9 select[name="interest"]').val() === "" ){
481					checks_vales = 1;
482					$("#step-minor-9").find('#required-form').remove();
483					$("#step-minor-9").append("<div id='required-form'>This field is required</div>");
484				}else{
485					$("#step-minor-9").find('#required-form').remove();
486				}
487// 				if( $('#step-minor-10 input[name="financeStanding"]:checked').length === 0 ){
488// 					checks_vales = 1;
489// 					$("#step-minor-10").find('#required-form').remove();
490// 					$("#step-minor-10").append("<div id='required-form'>This field is required</div>");
491// 				}else{
492// 					$("#step-minor-10").find('#required-form').remove();
493// 				}
494				if( $('#step-minor-10 select[name="financeStanding"]').val() === "" ){
495					checks_vales = 1;
496					$("#step-minor-10").find('#required-form').remove();
497					$("#step-minor-10").append("<div id='required-form'>This field is required</div>");
498				}else{
499					$("#step-minor-10").find('#required-form').remove();
500				}
501
502			}
503
504
505			
506			if(checks_vales){
507				return false;
508			}
509			
510		}
511
512
513		$("#popupForm").addClass('loading');
514
515		var current_date_time = $('#current_date_time').val();
516		var cookie_id = $('#cookie_id').val();
517
518		var thisBtnType = "";
519		const cf_data_inside = [];
520		var thisValue = "";
521		var thisHeading = "";
522		var cf_data_all = "";
523		var cf_data_html_all = "";
524		var thisFindDataStep = "";
525		var thisFormType = $("#form_role_type").val();
526
527		if($(this).hasClass('next')){
528			thisBtnType = "next";
529			thisFindDataStep = $(this).data('next-step');
530			$('.form-required').each(function(index, element) {
531				const cfArrayNew = [];
532				if ( $(this).hasClass('steps-1') ) {
533					thisValue = $(this).find('input:checked').val();
534					if(thisValue == "role_1"){
535						thisValue = "Sales Rep";
536					}
537					if(thisValue == "role_2"){
538						thisValue = "Owner/Manager";
539					}
540				}else if ($(this).find('input').is(':radio')){
541					thisValue = $(this).find('input:checked').val();
542				}else if ($(this).find('select').length) {
543					thisValue = $(this).find('select').val();
544				}else if ( $(this).find('input').is(':checkbox') ) {
545				
546				}else{
547					thisValue = $(this).find('input').val();
548				}
549				if ( $(this).find('input').is(':checkbox') ) {
550				
551				}else{
552					thisHeading = $(this).find('h2').html();
553					if (thisValue && thisValue.includes(',')) {
554						thisValue = thisValue.replace(/,/g, '&#44;');
555					}
556					cf_data_all += thisValue + ",";
557					cf_data_html_all += "<div><b>"+thisHeading+": </b>"+thisValue+"</div>";
558					cfArrayNew.push(thisHeading);
559					cfArrayNew.push(thisValue);
560					cf_data.push(cfArrayNew);
561				}
562			});
563		}
564		else if($(this).hasClass('final')){
565			
566			
567			
568// 			console.log("FINALS")
569			var maxIndex = 10;
570			var currentIndex = 0;
571			thisBtnType = "final";
572			thisFindDataStep = $(this).data('next-step');
573			$('.form-required').each(function(index, element) {
574				const cfArrayNew = [];
575				if ( $(this).hasClass('steps-1') ) {
576					thisValue = $(this).find('input:checked').val();
577					if(thisValue == "role_1"){
578						thisValue = "Sales Rep";
579						thisFormType = "form-sales";
580						maxIndex = 4;
581					}
582					if(thisValue == "role_2"){
583						thisValue = "Owner/Manager";
584						thisFormType = "form-owner";
585					}
586				}else if ( $(this).find('input').is(':checkbox') ) {
587				
588				}else if ($(this).find('input').is(':radio')){
589					thisValue = $(this).find('input:checked').val();
590				}else if ($(this).find('select').length) {
591					thisValue = $(this).find('select').val();
592				}else{
593					thisValue = $(this).find('input').val();
594				}
595				if ( $(this).find('input').is(':checkbox') ) {
596				
597				}else{
598					thisHeading = $(this).find('h2').html();
599					if (thisValue && thisValue.includes(',')) {
600						thisValue = thisValue.replace(/,/g, '&#44;');
601					}
602					cf_data_all += thisValue + ",";
603					cf_data_html_all += "<div><b>"+thisHeading+": </b>"+thisValue+"</div>";
604					cfArrayNew.push(thisHeading);
605					cfArrayNew.push(thisValue);
606					cf_data.push(cfArrayNew);
607					if(index === maxIndex){
608						// console.log(index)
609						return false;
610					}
611					
612				}
613				
614				
615				
616			});
617		}else{
618			thisBtnType = "prev";
619			thisFindDataStep = $(this).data('prev-step');
620			$('.form-required').each(function(index, element) {
621				const cfArrayNew = [];
622				if ( $(this).hasClass('steps-1') ) {
623					thisValue = $(this).find('input:checked').val();
624					if(thisValue == "role_1"){
625						thisValue = "Sales Rep";
626					}
627					if(thisValue == "role_2"){
628						thisValue = "Owner/Manager";
629					}
630				}else if ( $(this).find('input').is(':checkbox') ) {
631				
632				}else if ($(this).find('input').is(':radio')){
633					thisValue = $(this).find('input:checked').val();
634				}else if ($(this).find('select').length) {
635					thisValue = $(this).find('select').val();
636				}else{
637					thisValue = $(this).find('input').val();
638				}
639				
640				if ( $(this).find('input').is(':checkbox') ) {
641				
642				}else{
643					thisHeading = $(this).find('h2').html();
644					if (thisValue && thisValue.includes(',')) {
645						thisValue = thisValue.replace(/,/g, '&#44;');
646					}
647					cf_data_all += thisValue + ",";
648					cf_data_html_all += "<div><b>"+thisHeading+": </b>"+thisValue+"</div>";
649					cfArrayNew.push(thisHeading);
650					cfArrayNew.push(thisValue);
651					cf_data.push(cfArrayNew);
652				}
653			});
654		}
655		console.log(thisFindDataStep);
656		console.log("UPSS");
657		
658
659		function addDynamicKey(arr, key, value) {
660			arr.forEach(obj => {
661				obj[key] = value;
662			});
663			console.log(key);
664			console.log(value);
665		}
666		
667		
668		function removeLastKey(arr) {
669			arr.forEach(obj => {
670				let keys = Object.keys(obj);          // Get all keys of the object
671				let lastKey = keys[keys.length - 1];  // Get the last key
672				delete obj[lastKey];                  // Delete the last key
673			});
674		}
675		
676		
677
678		var cf_database = $('#form_database').val();
679		
680		$.ajax({
681			type: 'POST',
682			url: ajax_object.ajax_url,
683			data: {
684				action: 'rsra_all_step',
685				cf_data: cf_data_all,
686				cf_data_html_all: cf_data_html_all,
687				cf_data_step: thisFindDataStep,
688				cookie_id: cookie_id,
689				role_type: thisFormType,
690				cf_database: cf_database,
691				status_type: thisBtnType
692			},
693			success: function(response) {
694
695
696				let zapier_steps;
697
698				if (dataVersion === 'v3') {
699				    zapier_steps = [
700				        "Role", "First Name", "Last Name", "Email", "Contact Number", 
701				        "Company Website", "What was your annual revenue last year?", 
702				        "How many years have you been in business?"
703				    ];
704
705				} else if ( dataVersion === 'v4' ){
706				    zapier_steps = [
707				        "Role", "First Name", "Last Name", "Email", "Contact Number", 
708				        "Company Website", "What was your annual revenue last year?", 
709				        "How many years have you been in business?", 
710				        "Which of these describes your level of interest in RSRA?", 
711				        "Are You in Good Financial Standing?"
712				    ];
713				} else {
714				    zapier_steps = [
715				        "Role", "First Name", "Last Name", "Email", "Contact Number", 
716				        "Company Website", "How Many Sales Reps On Your Team?", 
717				        "Are Your Financial Relationships in Good Standing?", 
718				        "Why Do You Want to Join RSRA?", 
719				        "Are you comfortable investing $997/mo into your business, team, and endorsement?"
720				    ];
721				}
722
723				
724				if(thisBtnType == "final"){
725
726					cf_data_all.slice(0, -1);
727					var form_data_array = cf_data_all.split(",");
728					var getTypeRedirect = 1;
729					var checkType = 0;
730					var checkTypeLeads = 0;
731					var checkTypeSR = 0;
732					var first_name = "";
733					var last_name = "";
734					var email = "";
735					var a1 = "";
736					var a2 = "";
737					var a3 = "";
738					var a4 = 3;
739					var a5 = "";
740					const data = [];
741					const data_all = [];
742					var count_int =  0;
743					let arr = [
744						{ form: "rsra-custom-form", unique_id: cookie_id }
745					];
746					var why_join = "";
747					$.each(form_data_array,function(i){
748  						var total = $(form_data_array).length;
749						total = total - 2;
750						count_int = i;
751						count_int++;
752						let dynamicKey = zapier_steps[i];
753						let dynamicSpecificKey = zapier_steps[8];
754						let dynamicSpecificKeyLast = zapier_steps[9];
755						let dynamicValue = form_data_array[i];
756						let dynamicLastValue = form_data_array[total];
757
758
759						// if( dataVersion == 'v4' ){
760						// 	getTypeRedirect = 6;
761						// 	console.log(total + " THIS IS TOTAL");
762						// 	if(i <= 7){
763						// 		if (dynamicValue.includes("&#44;")) {
764						// 			dynamicValue = dynamicValue.replace(/&#44;/g, ',');
765						// 		}
766						// 		addDynamicKey(arr, dynamicKey, dynamicValue);
767						// 	}
768						// 	if(i >= 8 && i != total){
769						// 		why_join += ',' + form_data_array[i];
770						// 	}
771						// 	if(i === total){
772						// 		console.log(form_data_array[i]);
773						// 	}
774						// 	if(i === total){
775						// 		why_join = why_join.slice(1);
776						// 		if (why_join.includes("&#44;")) {
777						// 			why_join = why_join.replace(/&#44;/g, ',');
778						// 		}
779						// 		if (dynamicLastValue.includes("&#44;")) {
780						// 			dynamicLastValue = dynamicLastValue.replace(/&#44;/g, ',');
781						// 		}
782						// 		addDynamicKey(arr, dynamicSpecificKey, why_join);
783						// 		addDynamicKey(arr, dynamicSpecificKeyLast, dynamicLastValue);
784						// 	}
785						// 	if(i === 1){
786						// 		first_name = form_data_array[i];
787						// 	}
788						// 	if(i === 2){
789						// 		last_name = form_data_array[i];
790						// 	}
791						// 	if(i === 3){
792						// 		email = form_data_array[i];
793						// 	}
794						// 	if(i === 4){
795						// 		var itiDialCode = $('.iti__selected-dial-code').text();
796						// 		itiDialCode = itiDialCode.replace("+", "");
797						// 		a1 = itiDialCode + "" + form_data_array[i];
798						// 	}
799						// 	if(i === 5){
800						// 		a2 = form_data_array[i];
801						// 	}
802						// }else{
803
804						
805							if(i <= 7){
806								if (dynamicValue.includes("&#44;")) {
807									dynamicValue = dynamicValue.replace(/&#44;/g, ',');
808								}
809								addDynamicKey(arr, dynamicKey, dynamicValue);
810							}
811							if(i >= 8 && i != total){
812								why_join += ',' + form_data_array[i];
813							}
814							if(i === total){
815								console.log(form_data_array[i]);
816							}
817							if(i === total){
818								why_join = why_join.slice(1);
819								if (why_join.includes("&#44;")) {
820									why_join = why_join.replace(/&#44;/g, ',');
821								}
822								if (dynamicLastValue.includes("&#44;")) {
823									dynamicLastValue = dynamicLastValue.replace(/&#44;/g, ',');
824								}
825								addDynamicKey(arr, dynamicSpecificKey, why_join);
826								addDynamicKey(arr, dynamicSpecificKeyLast, dynamicLastValue);
827							}
828
829							if(i == 0){
830								a5 = form_data_array[i];
831								if(form_data_array[i] == "Sales Rep"){
832									getTypeRedirect = 1;
833									checkTypeSR = 1;
834								}else{
835									if( dataVersion != 'v3' || dataVersion != 'v4' ){
836										getTypeRedirect = 2;
837									}
838									checkTypeSR = 0;
839								}
840							}
841							if(getTypeRedirect == 2 && i == 6){
842								if(form_data_array[i] == "40+"){
843									if( dataVersion != 'v3' || dataVersion != 'v4' ){
844										getTypeRedirect = 3;
845									}
846								}
847							}
848
849							if(i === 1){
850								first_name = form_data_array[i];
851							}
852							if(i === 2){
853								last_name = form_data_array[i];
854							}
855							if(i === 3){
856								email = form_data_array[i];
857							}
858							if(i === 4){
859								var itiDialCode = $('.iti__selected-dial-code').text();
860								itiDialCode = itiDialCode.replace("+", "");
861								a1 = itiDialCode + "" + form_data_array[i];
862							}
863							if(i === 5){
864								a2 = form_data_array[i];
865							}
866
867							if( dataVersion == 'v3' || dataVersion == 'v4' ){
868
869								if(i === 6){
870									if(form_data_array[i] === "<$1m" ){
871										checkType = 1;
872										checkTypeLeads = 1;
873									}
874								}
875
876								if(i === 7 ){
877									if(form_data_array[i] === "<1 year" ){
878										checkType = 1;
879									}
880								}
881
882							}else{
883								if(i === 6){
884									a3 = form_data_array[i];
885								}
886							}
887
888						// }
889						
890
891					});
892
893					if( dataVersion == 'v3' || dataVersion == 'v4' ){
894						if( checkTypeLeads == 1 ){
895							getTypeRedirect = 7;
896						}
897						else if( checkType == 1 ){
898							getTypeRedirect = 4;
899						}else{
900							if( checkTypeSR == 1 ){
901							   	getTypeRedirect = 1;
902							}else{
903								getTypeRedirect = 5;
904							}
905						}
906					}
907
908					if( dataVersion == 'v4' ){
909						if( checkTypeLeads == 1 ){
910							
911						}else{
912							const financialStanding = arr[0]["Are You in Good Financial Standing?"].trim().toLowerCase();
913							const badStandings = ["no", "working on it"];
914							if (badStandings.includes(financialStanding)) {
915								getTypeRedirect = 6;
916							}
917						}
918// 						console.log(financialStanding + " << TEST 22222");
919						// remove this after demo
920						// getTypeRedirect = 6;
921					}
922
923					
924					// removeLastKey(arr);
925// 					var_dump(arr);
926					console.log(arr);
927					localStorage.setItem('rsraform_cookies', getRandomAlphanumericString(20) );
928					
929					$('.form-entry input[type="radio"]').prop('checked', false);
930					$('.form-entry input[type="checkbox"]').prop('checked', false);
931					$('.form-entry input[type="text"]').val('');
932					$('.form-entry input[type="email"]').val('');
933					cf_data.length = 0;
934
935
936					console.log(getTypeRedirect + " << FINAL REDIRECT");
937
938
939				if ( window.location.href.indexOf("old-join-v4-page") > -1 ) {
940
941						console.log("Test Page Detected: Starting Zapier submission to ur7u7t1...");
942					
943						console.log("Data sending to Zapier:", arr);
944
945						fetch('https://hooks.zapier.com/hooks/catch/809273/ur7u7t1/', {
946							method: 'POST',
947							body: JSON.stringify(arr)
948						})
949						.then(response => {
950							
951							console.log("Zapier Response Status:", response.status);
952
953							if (response.ok) {
954								console.log("Zapier Success! Redirecting now...");
955
956								$('.form-step').removeClass('active');
957								$("#popupForm").removeClass('loading');
958								$('#popupForm').fadeOut().css('display','block');
959								
960								var destination = "https://calendly.com/roof-strategist/book-your-application-call-rsra12?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
961								
962								console.log("Destination URL:", destination);
963								window.location = destination;
964
965							} else {
966								console.log("error submitted to new test zapier");
967							}
968						})
969						.catch(error => {
970							console.error('Test Zapier Error:', error);
971						});
972
973						return false; 
974					}
975
976						
977						if( getTypeRedirect == 7 ){
978							
979							fetch('https://hooks.zapier.com/hooks/catch/809273/ubrs9s5/', {
980								method: 'POST',
981								body: JSON.stringify(arr)
982							})
983								.then(response => {
984
985								if (response.ok) {
986
987									$('.form-step').removeClass('active');
988									$("#popupForm").removeClass('loading');
989									$('#popupForm').fadeOut().css('display','block');
990									
991									var destination = "https://www.rsra.org/thank-you-for-applying/";
992									window.location = destination;
993
994								} else {
995									console.log("error submitted to zapier");
996								}
997
998							})
999								.catch(error => {				
1000							});
1001							
1002						}
1003						else if( getTypeRedirect == 6 ){
1004
1005							fetch('https://hooks.zapier.com/hooks/catch/809273/2ws7lrm/', {
1006								method: 'POST',
1007								body: JSON.stringify(arr)
1008							})
1009								.then(response => {
1010
1011								if (response.ok) {
1012
1013									$('.form-step').removeClass('active');
1014									$("#popupForm").removeClass('loading');
1015									$('#popupForm').fadeOut().css('display','block');
1016
1017									
1018									if ( window.location.href.includes("join-olm") ) {
1019											var destination = "https://calendly.com/roof-strategist/rsra6?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1020											window.location = destination;
1021									}
1022									else if ( window.location.href.includes("join-rmr") ){
1023											var destination = "https://calendly.com/roof-strategist/rsra11?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1024											window.location = destination;
1025									} else {
1026										if( cf_database == 'joinv4' ){
1027											var destination = "https://calendly.com/roof-strategist/book-your-application-call-rsra12?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1028											window.location = destination;
1029										} else {
1030											var destination = "https://calendly.com/roof-strategist/book-your-application-call-rsra13?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1031											window.location = destination;
1032										}
1033									}
1034									
1035
1036									
1037									
1038									
1039									
1040
1041								} else {
1042									console.log("error submitted to zapier");
1043								}
1044
1045							})
1046								.catch(error => {				
1047							});
1048
1049						} 
1050						else if( getTypeRedirect == 5 ){
1051							fetch('https://hooks.zapier.com/hooks/catch/809273/2ws7lrm/', {
1052								method: 'POST',
1053								body: JSON.stringify(arr)
1054							})
1055								.then(response => {
1056								if (response.ok) {
1057							$('.form-step').removeClass('active');
1058							$("#popupForm").removeClass('loading');
1059							$('#popupForm').fadeOut().css('display','block');
1060									
1061									if ( window.location.href.includes("join-olm") ) {
1062											var destination = "https://calendly.com/roof-strategist/rsra5?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1063											window.location = destination;
1064									}
1065									else if ( window.location.href.includes("join-rmr") ){
1066											var destination = "https://calendly.com/roof-strategist/rsra2?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1067											window.location = destination;
1068									} else {
1069										if( cf_database == 'joinv3' || cf_database == 'joinv4' ){
1070											var destination = "https://calendly.com/roof-strategist/rsra1?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1071											window.location = destination;
1072										} else {
1073	// 										ftcv3
1074											var destination = "https://calendly.com/roof-strategist/rsra3?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1075											window.location = destination;
1076										}
1077									}
1078								} else {
1079									console.log("error submitted to zapier");
1080								}
1081							})
1082								.catch(error => {				
1083							});
1084							
1085						} 
1086						else if( getTypeRedirect == 4 ){
1087							// removeLastKey(arr);
1088							fetch('https://hooks.zapier.com/hooks/catch/809273/2ws7lrm/', {
1089								method: 'POST',
1090								body: JSON.stringify(arr)
1091							})
1092								.then(response => {
1093								if (response.ok) {
1094							$('.form-step').removeClass('active');
1095							$("#popupForm").removeClass('loading');
1096							$('#popupForm').fadeOut().css('display','block');
1097// 									joinv3 
1098// 									ftcv3
1099									if ( window.location.href.includes("join-olm") ) {
1100											var destination = "https://calendly.com/roof-strategist/rsra6?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1101											window.location = destination;
1102									}
1103									else if ( window.location.href.includes("join-rmr") ){
1104											var destination = "https://calendly.com/roof-strategist/rsra11?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1105											window.location = destination;
1106									} else {
1107										if( cf_database == 'joinv3' || cf_database == 'joinv4' ){
1108											var destination = "https://calendly.com/roof-strategist/book-your-application-call-rsra12?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1109											window.location = destination;
1110										} else {
1111	// 										ftcv3
1112											var destination = "https://calendly.com/roof-strategist/book-your-application-call-rsra13?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1113											window.location = destination;
1114										}
1115									}
1116
1117								} else {
1118									console.log("error submitted to zapier");
1119								}
1120							})
1121								.catch(error => {				
1122							});
1123							
1124						}
1125						else if( getTypeRedirect == 3 ){
1126							fetch('https://hooks.zapier.com/hooks/catch/809273/22s6wdx/', {
1127								method: 'POST',
1128								body: JSON.stringify(arr)
1129							})
1130								.then(response => {
1131								if (response.ok) {
1132									$('.form-step').removeClass('active');
1133									$("#popupForm").removeClass('loading');
1134									$('#popupForm').fadeOut().css('display','block');
1135									
1136									if( cf_database == 'ftc' || cf_database == 'ftcv2' ){
1137										var destination = "https://calendly.com/roof-strategist/rsra3?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"&a4="+a5+"";
1138										window.location = destination;
1139									}else{
1140										var destination = "https://calendly.com/roof-strategist/rsra1?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1141										window.location = destination;
1142									}
1143	// 									var destination = "https://calendly.com/bensman/rsra-enterprise?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1144	// 									window.location = destination;
1145
1146								} else {
1147									console.log("error submitted to zapier");
1148								}
1149							})
1150								.catch(error => {						
1151								// REMOVE THIS AFTER CONNECTING TO ZAPIER
1152	// 							var destination = "https://calendly.com/bensman/rsra-enterprise?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1153	// 							window.location = destination;
1154							});
1155						}
1156						else if ( getTypeRedirect == 2 ){
1157							fetch('https://hooks.zapier.com/hooks/catch/809273/22s6wdx/', {
1158								method: 'POST',
1159								body: JSON.stringify(arr)
1160							})
1161								.then(response => {
1162								if (response.ok) {
1163									$('.form-step').removeClass('active');
1164									$("#popupForm").removeClass('loading');
1165									$('#popupForm').fadeOut().css('display','block');
1166									if( cf_database == 'ftc' || cf_database == 'ftcv2' ){
1167										var destination = "https://calendly.com/roof-strategist/rsra3?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1168										window.location = destination;
1169									}else{
1170										var destination = "https://calendly.com/roof-strategist/rsra1?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1171										window.location = destination;
1172									}
1173								} else {
1174									console.log("error submitted to zapier");
1175								}
1176							})
1177								.catch(error => {
1178								console.error('Error:', error);
1179								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');
1180								// REMOVE THIS AFTER CONNECTING TO ZAPIER
1181	// 							var destination = "https://calendly.com/roof-strategist/rsra1?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"&a2="+a2+"&a3="+a3+"";
1182	// 							window.location = destination;
1183								
1184								
1185							});
1186						}else{
1187							fetch('https://hooks.zapier.com/hooks/catch/809273/229ct24/', {
1188								method: 'POST',
1189								body: JSON.stringify(arr)
1190							})
1191								.then(response => {
1192								if (response.ok) {
1193									$('.form-step').removeClass('active');
1194									$("#popupForm").removeClass('loading');
1195									$('#popupForm').fadeOut().css('display','block');
1196									var destination = "https://secure.rsra.org/joining-rsra-sales-rep";
1197									window.location = destination;
1198
1199								} else {
1200									console.log("error submitted to zapier");
1201								}
1202							})
1203								.catch(error => {
1204								console.error('Error:', error);
1205								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');// REMOVE THIS AFTER CONNECTING TO ZAPIER
1206	// 							var destination = "https://secure.rsra.org/joining-rsra-sales-rep";
1207	// 							window.location = destination;
1208							});
1209						}
1210
1211
1212				}
1213				else if(thisBtnType == "prev" && thisFindDataStep == 1){
1214					$('.form-step').removeClass('active');
1215					$('#step-' + thisFindDataStep).addClass('active');
1216					$("#popupForm").removeClass('loading');
1217					console.log(thisBtnType)
1218					console.log("THIS IS PREV")
1219				}else{
1220					if(thisBtnType == "next" && thisFindDataStep == 2){
1221						cf_data_all.slice(0, -1);
1222						var form_data_array = cf_data_all.split(",");
1223						var getTypeRedirect = 1;
1224						var first_name = "";
1225						var last_name = "";
1226						var email = "";
1227						var a1 = "";
1228						var a2 = "";
1229						var a3 = "";
1230						var a4 = 3;
1231						const data = [];
1232						const data_all = [];
1233						var count_int =  0;
1234						let arr = [
1235							{ form: "rsra-custom-form", unique_id: cookie_id }
1236						];
1237						$.each(form_data_array,function(i){
1238							count_int = i;
1239							count_int++;
1240							let dynamicKey = zapier_steps[i];
1241							let dynamicValue = form_data_array[i];
1242							
1243							if(i <= 5){
1244								if (dynamicValue.includes("&#44;")) {
1245									dynamicValue = dynamicValue.replace(/&#44;/g, ',');
1246								}
1247								addDynamicKey(arr, dynamicKey, dynamicValue);
1248							}
1249							
1250							if(i === 1){
1251								first_name = form_data_array[i];
1252							}
1253							if(i === 2){
1254								last_name = form_data_array[i];
1255							}
1256							if(i === 3){
1257								email = form_data_array[i];
1258							}
1259							if(i === 4){
1260								var itiDialCode = $('.iti__selected-dial-code').text();
1261								itiDialCode = itiDialCode.replace("+", "");
1262								a1 = itiDialCode + "" + form_data_array[i];
1263							}
1264							
1265						});
1266// 						removeLastKey(arr);
1267								
1268						console.log(dataVersion);
1269						// Add Condition Here to submit and remove cache cookie id to reset form
1270						if ( dataVersion == 'v2' ){
1271							console.log('v3 = dont1');
1272							localStorage.setItem('rsraform_cookies', getRandomAlphanumericString(20) );
1273							fetch('https://hooks.zapier.com/hooks/catch/809273/2iym58r/', {
1274								method: 'POST',
1275								body: JSON.stringify(arr)
1276							})
1277								.then(response => {
1278								if (response.ok) {
1279									$('.form-step').removeClass('active');
1280									$("#popupForm").removeClass('loading');
1281									$('#popupForm').fadeOut().css('display','block');
1282
1283									if (cf_database == 'ftc' || cf_database == 'ftcv2' ){
1284										var destination = "https://calendly.com/roof-strategist/rsra3?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"";
1285										window.location = destination;
1286									}else{
1287										var destination = "https://calendly.com/roof-strategist/rsra1?first_name="+first_name+"&last_name="+last_name+"&email="+email+"&a1="+a1+"";
1288										window.location = destination;
1289									}
1290
1291								} else {
1292									console.log("error submitted to zapier");
1293								}
1294							})
1295								.catch(error => {
1296								console.error('Error:', error);
1297								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');
1298							});
1299
1300						} else if( dataVersion == 'v3' ){
1301							console.log('v3 = next');
1302
1303							fetch('https://hooks.zapier.com/hooks/catch/809273/2iym58r/', {
1304								method: 'POST',
1305								body: JSON.stringify(arr)
1306							})
1307								.then(response => {
1308								if (response.ok) {
1309									console.log("submitted to zapier");
1310								} else {
1311									console.log("error submitted to zapier");
1312								}
1313							})
1314								.catch(error => {
1315								console.error('Error:', error);
1316								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');
1317							});
1318							
1319							
1320							$('.form-step').removeClass('active');
1321							$('#step-' + thisFindDataStep + '.' + thisFormType).addClass('active');
1322							$("#popupForm").removeClass('loading');
1323
1324						} else if( dataVersion == 'v4' ){
1325							console.log('v4 = next');
1326
1327							fetch('https://hooks.zapier.com/hooks/catch/809273/2iym58r/', {
1328								method: 'POST',
1329								body: JSON.stringify(arr)
1330							})
1331								.then(response => {
1332								if (response.ok) {
1333									console.log("submitted to zapier");
1334								} else {
1335									console.log("error submitted to zapier");
1336								}
1337							})
1338								.catch(error => {
1339								console.error('Error:', error);
1340								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');
1341							});
1342							
1343							
1344							$('.form-step').removeClass('active');
1345							$('#step-' + thisFindDataStep + '.' + thisFormType).addClass('active');
1346							$("#popupForm").removeClass('loading');
1347
1348						}else{
1349
1350							fetch('https://hooks.zapier.com/hooks/catch/809273/22s4ah1/', {
1351								method: 'POST',
1352								body: JSON.stringify(arr)
1353							})
1354								.then(response => {
1355								if (response.ok) {
1356									console.log("submitted to zapier");
1357								} else {
1358									console.log("error submitted to zapier");
1359								}
1360							})
1361								.catch(error => {
1362								console.error('Error:', error);
1363								console.error('Zappier Connection Error - Maybe zapier fetch connection is off or wrong fetch link');
1364							});
1365							
1366							
1367							$('.form-step').removeClass('active');
1368							$('#step-' + thisFindDataStep + '.' + thisFormType).addClass('active');
1369							$("#popupForm").removeClass('loading');
1370
1371						}
1372					}
1373					
1374				}
1375			},
1376			error: function(xhr, status, error) {
1377				console.log(error)
1378			}
1379		});
1380	});
1381});

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.