1jQuery(document).ready(function($) { 2 3 // see https://github.com/jackocnr/intl-tel-input 4 // let input = document.querySelector(".frm-inter-phone"); 5 if (!window.intlTelInput || !$('.frm-inter-phone').length) return; 6 console.log('intlTelInput', $('.frm-inter-phone').length) 7 8 $('.frm-inter-phone').each(function() { 9 10 let input = $(this)[0] 11 12 let countryOrder = ['fr', 'be', 'de', 'it', 'es', 'pl', 'gb', 'cz', 'hu'] 13 countryOrder = jQuery(input).data('preferred-prefixes').split(/\s*[\;\,]\s*/g).map(c => c.trim().toLowerCase()).filter(c => c) 14 // console.log('COUNTRY ORDER', countryOrder, jQuery(input)) 15 16 let iti = window.intlTelInput(input, { 17 autoHideDialCode: true, 18 separateDialCode: true, 19 // excludeCountries: [] 20 // utilsScript: 'https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js', 21 loadUtils: () => import("https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js"), 22 countryOrder, //: ['fr', 'be', 'de', 'it', 'es', 'pl', 'gb', 'cz', 'hu'], 23 initialCountry: countryOrder[0] || 'fr', 24 // initialCountry: 'auto', 25 // geoIpLookup: async function(success, failure) { 26 // try { 27 // let loc = await ccn_get_ip_location() 28 // console.log('loc tel intl', loc) 29 // success(loc.country_code?.toLowerCase() || countryOrder[0] || 'fr') 30 // } catch(e) { 31 // success(countryOrder[0] || 'fr') 32 // } 33 // }, 34 }) 35 36 // When the phone number changes we update the hidden field value 37 $(this).on('change', function() { 38 let country = iti.getSelectedCountryData() 39 console.log('phone changed', $(this).data('for'), $(this).val(), country) 40 $(`[name="${$(this).data('for')}"]`).val(iti.getNumber().replace(/\s+/g, '')) 41 }) 42 43 // When the country has changed, change the value in the hidden input 44 $(this)[0].addEventListener("countrychange", function() { 45 let country = iti.getSelectedCountryData() 46 console.log('country changed', $(this).data('for'), $(this).val(), country) 47 $(`[name="${$(this).data('for')}"]`).val(iti.getNumber()) 48 }); 49 50 // Validate on blur 51 $(this)[0].addEventListener('blur', function() { 52 // reset(); 53 if (this.value.trim()) { 54 if (iti.isValidNumber()) { 55 $(this).next('.frm_error').show(); 56 } else { 57 this.classList.add("error"); 58 var errorCode = iti.getValidationError(); 59 console.log('validating', errorCode) 60 //errorMsg.innerHTML = errorMap[errorCode]; 61 $(this).next('.frm_error').html(errorCode).show() 62 } 63 } 64 }); 65 66 // Set the value of the hidden field 67 let hidden_field = $(this).closest('.frm_form_field').find('.frm-inter-phone-hidden') 68 if (hidden_field.length) { 69 console.log('setting number', hidden_field.val(), $(this)) 70 iti.setNumber(hidden_field.val().replace(/\s+/g, '')) 71 } 72 73 hidden_field.on('change', function() { 74 iti.setNumber($(this).val().replace(/\s+/g, '')) 75 }) 76 77 }) 78 79})
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.