1dxp.ready(function () { 2 const $submit = $("button.submit"); 3 const validated = "validation-success"; 4 const hasReasonToContact = guideBridge.resolveNode('reasonToContact') !== null; 5 const formLabel = hasReasonToContact?"multi-purpose-form":"contact"; 6 const contactLabel = "contact-details"; 7 const selectedTopic = "selected-topic"; 8 const formSubmitLabel = "form-submit"; 9 const formStep = "form-step"; 10 const formEvent = "formevent"; 11 const forms = "forms"; 12 let reasonToContact = "contact"; 13 const reasonToContactMap = { 14 'general request': 'contact', 15 'complaint': 'complaint-form', 16 }; 17 18 var tabValue = document.querySelectorAll(".guideRadioButtonItem.tabs input"); 19 var reasonToContactValue = document.querySelectorAll( 20 ".guideRadioButtonItem.reasonToContact input, .guideRadioButtonItem.complaintOrQuery input" 21 ); 22 23 async function hashValue(email) { 24 const encoder = new TextEncoder(); 25 const data = encoder.encode(email); 26 const hashBuffer = await crypto.subtle.digest("SHA-256", data); 27 const hashArray = Array.from(new Uint8Array(hashBuffer)); 28 return hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); 29 } 30 31 function getFieldValue(fieldName) { 32 let node = guideBridge.resolveNode(fieldName); 33 return node && node.value; 34 } 35 36 triggerFormLoad(); 37 38 tabValue.forEach((item, index) => { 39 item.addEventListener("click", () => { 40 triggerFormLoad(); 41 }); 42 }); 43 44 reasonToContactValue.forEach((item) => { 45 item.addEventListener("click", () => { 46 const reasonToContactValue = reasonToContactMap[item.dataset.value]; 47 if (reasonToContactValue) { 48 reasonToContact = reasonToContactValue; 49 } else { 50 reasonToContact = "contact"; 51 } 52 triggerReasonToContactSelect(); 53 }); 54 }); 55 56 //On form load 57 function triggerFormLoad() { 58 setTimeout(() => { 59 T1.channels.statistics.publish(dxp.constants.TOPICS_T1.STATS_TRACK, { 60 extraData: { 61 event: { 62 name: formEvent, 63 componentName: formLabel, 64 componentGroup: forms, 65 action: formStep, 66 label: contactLabel, 67 }, 68 form: { 69 name: formLabel, 70 step: contactLabel, 71 variant: getFieldValue("tabs"), 72 conversion: 0, 73 }, 74 }, 75 }); 76 }, 0); 77 } 78 79 function triggerReasonToContactSelect() { 80 T1.channels.statistics.publish(dxp.constants.TOPICS_T1.STATS_TRACK, { 81 extraData: { 82 event: { 83 name: formEvent, 84 componentName: reasonToContact, 85 componentGroup: forms, 86 action: formStep, 87 label: selectedTopic, 88 }, 89 form: { 90 name: reasonToContact, 91 step: selectedTopic, 92 variant: getFieldValue("tabs"), 93 conversion: 0, 94 }, 95 }, 96 }); 97 } 98 99 //On form submission 100 async function triggerFormSubmit() { 101 if (guideBridge.resolveNode("guideRootPanel").validate()) { 102 let userEmail = getFieldValue("email").trim().toLowerCase(); 103 const hashEmail = userEmail ? await hashValue(userEmail) : ""; 104 105 if (getFieldValue("dealer")) { 106 T1.channels.statistics.publish(dxp.constants.TOPICS_T1.STATS_TRACK, { 107 extraData: { 108 event: { 109 name: formEvent, 110 componentName: reasonToContact, 111 componentGroup: forms, 112 action: formStep, 113 label: formSubmitLabel, 114 }, 115 form: { 116 name: reasonToContact, 117 step: formSubmitLabel, 118 variant: getFieldValue("tabs"), 119 conversion: 1, 120 }, 121 dealer: { 122 name: getFieldValue("dealerName"), 123 dealerId: getFieldValue("dealer"), 124 city: getFieldValue("dealerCity"), 125 zipCode: getFieldValue("dealerZip"), 126 region: getFieldValue("dealerRegion"), 127 }, 128 ...(userEmail.length > 0 && { userinfo: { em: await hashValue(userEmail) } }) 129 }, 130 }); 131 } else { 132 T1.channels.statistics.publish(dxp.constants.TOPICS_T1.STATS_TRACK, { 133 extraData: { 134 event: { 135 name: formEvent, 136 componentName: reasonToContact, 137 componentGroup: forms, 138 action: formStep, 139 label: formSubmitLabel, 140 }, 141 form: { 142 name: reasonToContact, 143 step: formSubmitLabel, 144 variant: getFieldValue("tabs"), 145 conversion: 1, 146 }, 147 ...(hashEmail.length > 0 && { userinfo: { em: hashEmail } }) 148 }, 149 }); 150 } 151 } 152 } 153 154 $submit.eq(0).on("click", triggerFormSubmit); 155});
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.