1const mask = (selector) => { 2 function setMask() { 3 let matrix = '+###############'; 4 5 maskList.forEach(item => { 6 let code = item.code.replace(/[\s#]/g, ''), 7 phone = this.value.replace(/[\s#-)(]/g, ''); 8 9 if (phone.includes(code)) { 10 console.log(phone, code); 11 matrix = item.code; 12 } 13 }); 14 15 let i = 0, 16 val = this.value.replace(/\D/g, ''); 17 18 this.value = matrix.replace(/(?!\+)./g, function(a) { 19 return /[#\d]/.test(a) && i < val.length ? val.charAt(i++) : i >= val.length ? '' : a; 20 }); 21 } 22 23 let inputs = document.querySelectorAll(selector); 24 25 inputs.forEach(input => { 26 if (input.getAttribute('name') === 'phone') { // Verifica se o atributo 'name' é 'phone' 27 if (!input.value) input.value = ''; 28 input.addEventListener('input', setMask); 29 input.addEventListener('focus', setMask); 30 input.addEventListener('blur', setMask); 31 } 32 }); 33}; 34 35 36
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.