1document.addEventListener('alpine:init', () => { 2 Alpine.data('warrantyTransfer', () => ({ 3 form1: {}, 4 form2: {}, 5 creditCardInfo: {}, 6 warrantyInfo: {}, 7 ownershipTransferDate: null, 8 errors: null, 9 submiting: false, 10 step: 1, 11 init () { 12 window.setupDatePicker(this.$refs.ownership_transfer_date, undefined, new Date()); 13 }, 14 15 initRecaptcha() { 16 grecaptcha.render(this.$refs.recaptcha, { 17 sitekey: window.env.RECAPTCHA_KEY 18 }) 19 }, 20 21 async startTransfer() { 22 this.submiting = true 23 this.errors = null 24 let url = window.env.PORTAL_API_URL + '/1.0/Warranties/transferStart'; 25 26 try { 27 const rawResponse = await fetch(url, { 28 method: 'POST', 29 body: new URLSearchParams(this.form1), 30 }) 31 const response = await rawResponse.json() 32 33 if(rawResponse.status == 200 && response?.success == 1) { 34 this.warrantyInfo = response?.data?.old 35 this.step = !!this.warrantyInfo ? 2 : 1 36 this.errors = null 37 this.initRecaptcha() 38 } else if(rawResponse.status == 200 && response?.success != 1) { 39 this.errors = response?.messages?.errors 40 } else { 41 alert('An error occured!') 42 } 43 } catch (error) { 44 console.error({ error }) 45 } finally { 46 this.submiting = false 47 } 48 }, 49 50 formatDate(date) { 51 const parts = date.split('/'); 52 return `${parts[2]}-${parts[0]}-${parts[1]}`; 53 }, 54 55 formatDate2(date) { 56 const parts = date.split('/'); 57 return `${parts[0]}-${parts[1]}-${parts[2]}`; 58 }, 59 60 async processTransfer() { 61 this.submiting = true 62 this.errors = null 63 const recaptcha = document.getElementById('g-recaptcha-response').value 64 65 if(!recaptcha) { 66 alert('Please validate the Recaptcha!'); 67 this.submiting = false; 68 return; 69 } 70 71 this.ownershipTransferDate = this.formatDate2(this.$refs.ownership_transfer_date.value) 72 const data = { 73 ...this.form2, 74 old_warranty_id: this.warrantyInfo.warranty_id, 75 ownership_transfer_date: this.formatDate(this.$refs.ownership_transfer_date.value), 76 'g-recaptcha-response': recaptcha 77 } 78 79 if(this.form2.payment_type === 'credit') { 80 data.cc_expiration = this.$refs.cc_expiration_month.value + '' + this.$refs.cc_expiration_year.value 81 data.transaction_name_on_card = this.creditCardInfo.transaction_name_on_card 82 data.card_number = this.creditCardInfo.card_number 83 data.cvv = this.creditCardInfo.cvv 84 data.transfer_fee = 100 85 } 86 console.log(data, this.form2, this.form); 87 88 let url = window.env.PORTAL_API_URL + '/1.0/Warranties/transferDetails'; 89 90 try { 91 const rawResponse = await fetch(url, { 92 method: 'POST', 93 body: new URLSearchParams(data), 94 }) 95 const response = await rawResponse.json() 96 97 if(rawResponse.status == 200 && response?.success == 1) { 98 // this.$refs.successModalBtn.click() 99 this.step = 3 100 } else if(rawResponse.status == 200 && response?.success != 1) { 101 this.errors = response?.messages?.errors 102 setTimeout(() => { 103 this.$refs.errors.scrollIntoView({behavior: "smooth", block: "end", inline: "nearest"}) 104 }, 500) 105 } else { 106 alert('An error occured!') 107 } 108 } catch (error) { 109 console.error({ error }) 110 } finally { 111 this.submiting = false 112 } 113 }, 114 })) 115})
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.