1jQuery(document).ready(function($) { 2 // When the range input slider value changes 3 $('.wcu-commission-range').on('input', function() { 4 var coupon_id = $(this).attr('id').replace('commission_percent_', ''); // Get coupon_id from input id 5 var commission_percent = $(this).val(); // Get new commission percent value 6 7 // Update the displayed value next to the slider 8 $('#commission_value_' + coupon_id).text(commission_percent + '%'); 9 10 // Send the updated value via AJAX to WordPress 11 $.ajax({ 12 url: ajaxurl, // WordPress AJAX URL, defined by wp_localize_script() 13 type: 'POST', 14 data: { 15 action: 'update_coupon_commission', // Action to handle in PHP 16 coupon_id: coupon_id, 17 commission_percent: commission_percent, 18 }, 19 success: function(response) { 20 // Optionally, you can show a success message or handle the response here 21 if(response.success) { 22 console.log('Commission updated successfully.'); 23 } else { 24 console.log('Failed to update commission.'); 25 } 26 }, 27 error: function() { 28 console.log('There was an error with the request.'); 29 } 30 }); 31 }); 32 if($('.wcu_form_affiliate_register').length){ 33 console.log('Affiliate register form detected.') 34 const bankFields = { 35 "wcu_bank_name" : "payee_name", 36 "wcu_bank_sort" : 'iban', 37 "wcu_bank_account" : 'bic', 38 "wcu_bank_other" : 'bank_name', 39 "wcu_bank_other2" : 'company_name', 40 } 41 const handleChangingPayoutSelect = () => { 42 43 const select = document.querySelector('select[name=wcu_payout_type]') 44 const form = $(select.closest('form')) 45 const value = select.value.toLowerCase().trim().replace(' ', '') 46 if(value === 'banktransfer'){ 47 for(const field of Object.keys(bankFields)){ 48 $(`input[name=${field}]`).closest('p').show() 49 $(`input[name=${field}]`).attr('required', '') 50 } 51 $('input[name=wcu_paypalapi]').closest('p').hide() 52 $('input[name=wcu_paypalapi]').removeAttr('required') 53 54 }else if(value === 'paypal'){ 55 for(const field of Object.keys(bankFields)){ 56 $(`input[name=${field}]`).closest('p').hide() 57 $(`input[name=${field}]`).removeAttr('required') 58 } 59 $('input[name=wcu_paypalapi]').closest('p').show() 60 $('input[name=wcu_paypalapi]').attr('required', '') 61 62 } 63 64 } 65 $('.wcu-register-field-col').each(function(){ 66 if($(this).children('label').attr('for').toString().match('custom')){ 67 let name = $(this).children('label').text().replaceAll(' ', '_').replaceAll('*', '').toLowerCase() 68 name = name.replace('address_line', 'address') 69 70 if(name.match('operating_business_name')){ 71 name = 'wcu_billing_company' 72 }else if(name.match('paypal_payout_email')){ 73 name = 'wcu_paypalapi' 74 }else if(Object.values(bankFields).includes(name)){ 75 name = Object.keys(bankFields).find(k => bankFields[k] === name) 76 }else if(name.match('payout_type')){ 77 name = 'wcu_payout_type' 78 }else if(name.match('tax')){ 79 name = 'wcu_billing_taxid' 80 }else{ 81 name = "wcu_billing_" + name 82 } 83 $(this).children('input').attr('name', name) 84 $(this).children('select').attr('name', name) 85 if(name === 'wcu_payout_type'){ 86 $(this).children('select').on('change', handleChangingPayoutSelect) 87 } 88 } 89 }) 90 handleChangingPayoutSelect() 91 } 92 const handleRegisterPayoutChanging = () => { 93 const select = document.querySelector('.select2-single._payout_type') 94 if(select){ 95 const value = select.value 96 console.log(value) 97 const banktransfer = $('#listeo-registration-custom-_bank_transfer_details') 98 const paypal = $('#listeo-registration-custom-_paypal_email') 99 if(value === 'paypal_payout'){ 100 banktransfer.hide() 101 paypal.show() 102 }else if(value === 'banktransfer'){ 103 paypal.hide() 104 banktransfer.show() 105 }else{ 106 paypal.hide() 107 banktransfer.hide() 108 } 109 110 } 111 } 112 handleRegisterPayoutChanging() 113 $('.select2-single._payout_type').on('change', handleRegisterPayoutChanging) 114 /** 115 * 116 * @param fields {[]} 117 * @return [] 118 */ 119 const registerValidation = (fields ) => { 120 const errors = [] 121 for(const key in fields){ 122 console.log(key, /tax_number/.test(key)) 123 if(/(tax_number|wcu_billing_taxid)/.test(key) && fields[key].length < 6){ 124 errors.push({key, error: 'Minimum 6 character'}) 125 } 126 } 127 return errors 128 } 129 $(document).on('submit', '.register.listeo-registration-form,.wcu_form_affiliate_register', function(e){ 130 131 try{ 132 $(this).find('.custom-error').remove() 133 const fd = new FormData(this) 134 const validate = registerValidation(Object.fromEntries(fd.entries())) 135 if(validate.length){ 136 for(const error of validate){ 137 138 $(this).find(`[name="${error.key}"]`).before(`<span class="custom-error" style="color: #e85e68">${error.error}</span>`) 139 } 140 e.preventDefault() 141 $('html, body').animate({ 142 scrollTop: $(this).find(`[name="${validate[0].key}"]`).offset().top - 100 143 }, 500); 144 } 145 }catch(e){ 146 console.log(e) 147 } 148 149 }) 150 if($('.creatives-box').length){ 151 const parent = $('.creatives-box').parent(); 152 console.log(parent) 153 parent.hide() 154 $('.wcusage_custom_ref_url_creative').on('change', async function(){ 155 console.log('Testing...') 156 const tag = this.value; 157 const result = await fetch(`${ajaxurl}?action=get_custom_creatives&tag=${tag}` ) 158 if(await result.ok){ 159 const html = await result.text() 160 parent.html(html); 161 parent.show() 162 } 163 $('.creatives-box a').each(function(){ 164 this.href += `&custom_url=${tag}` 165 }) 166 }) 167 } 168 if($('select.custom-order')){ 169 $('select.custom-order').on('select2:select', function(e){ 170 $('#listeo-listings-container').addClass('loading') 171 $.ajax({ 172 url : `${ajaxurl}?action=custom_listeo_ordering&filter=${e.params.data.id}`, 173 success: function(response){ 174 $('.custom-listing-item').remove() 175 $('#listeo-listings-container').html(response.content) 176 $('#listeo-listings-container').removeClass('loading') 177 $('[data-rating]').starRating(); 178 } 179 }) 180 }) 181 } 182 console.log("testing") 183});
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.